In this example we deploy the NGINX or NGINX Plus Ingress controller, a simple web application and then configure load balancing for that application using the Ingress resource.
-
Follow the installation instructions to deploy the Ingress controller.
-
Save the public IP address of the Ingress controller into a shell variable:
$ IC_IP=XXX.YYY.ZZZ.III
-
Save the HTTPS port of the Ingress controller into a shell variable:
$ IC_HTTPS_PORT=<port number>
Create the coffee and the tea deployments and services:
$ kubectl create -f cafe.yaml
-
Create a secret with an SSL certificate and a key:
$ kubectl create -f cafe-secret.yaml
-
Create an Ingress resource:
$ kubectl create -f cafe-ingress.yaml
-
To access the application, curl the coffee and the tea services. We'll use
curl
's --insecure option to turn off certificate verification of our self-signed certificate and the --resolve option to set the Host header of a request withcafe.example.com
To get coffee:
$ curl --resolve cafe.example.com:$IC_HTTPS_PORT:$IC_IP https://cafe.example.com:$IC_HTTPS_PORT/coffee --insecure Server address: 10.12.0.18:80 Server name: coffee-7586895968-r26zn ...
If your prefer tea:
$ curl --resolve cafe.example.com:$IC_HTTPS_PORT:$IC_IP https://cafe.example.com:$IC_HTTPS_PORT/tea --insecure Server address: 10.12.0.19:80 Server name: tea-7cd44fcb4d-xfw2x ...
-
You can view an NGINX status page, either stub_status for NGINX, or the Live Activity Monitoring Dashboard for NGINX Plus:
- Follow the instructions to access the status page.
- For NGINX Plus, If you go to the Upstream tab, you'll see: