This practical sheet provides a step by step procedure to install Contour Ingress Controller on workload clusters.
It is given as an example about how to use an Ingress Controller, but others Ingress Controller can be used. It is just for information and to help starting using an Ingress Controller.
This practical sheets is given as information only, Contour is not mandatory at all, you are free to install any other Ingress Controler on your clusters. No support can be provided on Contour.
Prerequisites
Before deploying Contour on the workload cluster, some prerequisite has to be installed either on the admin workstation or in the target workload cluster.
Get the correct version to install depending of the repository added in the above step. Use the LATEST-VERSION column and note the version, it will be required in next steps.
# tanzu package available list cert-manager.tanzu.vmware.com -A
- Retrieving available packages... NAMESPACE NAME VERSION RELEASED-AT packages cert-manager.tanzu.vmware.com 1.1.0+vmware.1-tkg.2 2020-11-24 18:00:00 +0000 UTC packages cert-manager.tanzu.vmware.com 1.1.0+vmware.2-tkg.1 2020-11-24 18:00:00 +0000 UTC packages cert-manager.tanzu.vmware.com 1.10.2+vmware.1-tkg.1 2023-01-11 12:00:00 +0000 UTC packages cert-manager.tanzu.vmware.com 1.5.3+vmware.2-tkg.1 2021-08-23 17:22:51 +0000 UTC packages cert-manager.tanzu.vmware.com 1.5.3+vmware.4-tkg.1 2021-08-23 17:22:51 +0000 UTC packages cert-manager.tanzu.vmware.com 1.5.3+vmware.7-tkg.1 2021-08-23 17:22:51 +0000 UTC packages cert-manager.tanzu.vmware.com 1.5.3+vmware.7-tkg.3 2021-08-23 17:22:51 +0000 UTC packages cert-manager.tanzu.vmware.com 1.7.2+vmware.1-tkg.1 2021-10-29 12:00:00 +0000 UTC packages cert-manager.tanzu.vmware.com 1.7.2+vmware.3-tkg.1 2021-10-29 12:00:00 +0000 UTC packages cert-manager.tanzu.vmware.com 1.7.2+vmware.3-tkg.3 2021-10-29 12:00:00 +0000 UTC
Install cert manager in desired namespace :
Replace NAMESPACE and VERSION using the version founded in the above step
tanzu package install cert-manager --package-name cert-manager.tanzu.vmware.com --namespace NAMESPACE --version VERSION
Get the correct version to install depending of the repository added in the above step. Use the LATEST-VERSION column and note the version, it will be required in next steps.
# tanzu package available list contour.tanzu.vmware.com -A
- Retrieving available packages... NAME DISPLAY-NAME SHORT-DESCRIPTION LATEST-VERSION NAMESPACE contour.tanzu.vmware.com contour An ingress controller 1.18.2+vmware.1-tkg.1 packages
Install contour in desired namespace :
Replace NAMESPACE and VERSION using the version founded in the above step
\ Retrieving installed packages... NAME PACKAGE-NAME PACKAGE-VERSION STATUS NAMESPACE contour contour.tanzu.vmware.com 1.18.2+vmware.1-tkg.1 Reconcile succeeded packages
Ingress controller sample usage
To test our Ingress Controller we will deploy two pods. One POD that will display a webpage with the text apple, and another POD that will display a webpage with the text banana.
Depending of the host url used to access the service the Ingress Controller will use the correct POD to give the answer to the web client.
This implementation require only one IP adress that are accessible outside the cluster (Envoy IP), it correspond to the service (type LoadBalancer) that we create during the contour installation process.
Please note !
For our demo we will use a public and free DNS service called nip.io. It will help and simplify our demo regarding the DNS resolution, but it is not mandatory at all, you can rely on your classical DNS resolution system.
nip.io will resolve the names by answering the IP provided in the name. Example for :
banana.100.10.12.2.nip.ip will return the ip : 100.100.12.2
apple.100.10.12.2.nip.ip will return the ip : 100.100.12.2
PODs creation
First we need to define our PODS and services, for that create these two files :
apple.yaml
kind: Pod apiVersion: v1 metadata: name: apple-app labels: app: apple spec: containers: - name: apple-app image: hashicorp/http-echo args: - "-text=apple"
---
kind: Service apiVersion: v1 metadata: name: apple-service spec: selector: app: apple ports: - port: 5678 # Default port for image
Verify that pods status are RUNNING after some times
kubectl get pods banana kubectl get pods apple
Ingress Deployment
Get the ingress controller service IP. For that use the EXTERNAL-IP value, note the IP it will be required for next step.
Please note !
if you just installed Contour recently the EXTERNAL-IP address can take some minutes to be affected to your Load Balancer.
kubectl get svc envoy -n tanzu-system-ingress NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE envoy LoadBalancer 100.65.98.108 100.101.191.4 80:30411/TCP,443:30934/TCP 4d3h
Create a file named ingress.yaml with the below content
replace the [IP] in the host parameter by the external-ip retrieved with the above command
you can also use your own dns extension instead of nip.io, but for test purpose it will be more easier to use nip.io.