Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now we create an Ingress resource, to make your HTTP web server application publicly accessible. The following command defines an Ingress resource that forwards traffic that requests http://webserver-bar.com to com to the webserver

Code Block
languageyml
titleConfigure Ingress resource
collapsetrue
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: lb
  annotations:
    kubernetes.io/ingress.class: "openstack"
    octavia.ingress.kubernetes.io/internal: "false"	# Set true, if you don't want your Ingress to be accessible from the public internet
spec:
  rules:
  - host: webserver-bar.com
    http:
      paths:
      - path: /tea				# Use webserver-bar.com/tea to target "tea" services
        pathType: Prefix		# This field is mandatory. Other values are "ImplementationSpecific" and "Exact"
        backend:
          service:
            name: tea-svc		# Enter the service name
            port:
              number: 80		# Enter the port number on which the service is listening
      - path: /coffee			# Use webserver-bar.com/coffee to target "coffee" services
        pathType: Prefix		# This field is mandatory. Other values are "ImplementationSpecific" and "Exact"
        backend:
          service:
            name: coffee-svc	# Enter the service name
            port:
              number: 80		# Enter the port number on which the service is listening

...

Code Block
languagebash
titleIngress Resource
$ kubectl get ing
NAME   CLASS    HOSTS               ADDRESS          PORTS   AGE
lb     <none>   webserver-bar.com   131.154.97.200   80      3d1h

Go to OpenStack and check that the LB has been created in the Project/Network/LoadBalancer tab. Using a browser or the curl command, you should be able to access the backend service by sending HTTP request to the domain name specified in the Ingress resource (remember to hook the hostname to the FIP in the /etc/hosts of the machine from which the request to the service starts)

Code Block
languagebash
titleConnect to the service
$ curl webserver-bar.com/coffee
Server address: 172.16.94.81:8080
Server name: coffee-6f4b79b975-25jrn
Date: 30/Oct/2020:17:34:39 +0000
URI: /coffee
Request ID: 448271f01b708f4bb1d92b31600be368

$ curl webserver-bar.com/tea
Server address: 172.16.141.44:8080
Server name: tea-6fb46d899f-47rtv
Date: 30/Oct/2020:17:34:46 +0000
URI: /tea
Request ID: 47f120d482f1236c4f5351b114d389a5

Let's move to openstack

Go to OpenStack and check that the LB has been created in the Project/Network/LoadBalancer tab. We navigate the LB to verify that its internal components were created and, in particular, how they were created. Let's analyze, by way of example, the L7 Rule that was automatically generated to reach the webserver-bar.com/tea address. Here we can get a taste of the convenience of using this approach. In addition to building and automatically configuring the components that make up the LB, this also generates the Policies and Rule on the basis of what is written in the configuration file of the Ingress Resource. This help is more appreciable the more complex the structure of our website is.Image Added