Ingress controller is used in kubernetes to direct external traffic to the relevant containers/pods running in the cluster. nginx is a very common and popular ingress controller used with kubernetes. This article guides through the steps involved in deploying nginx ingress controller.
helm is one of the popular ways of managing deployments into kubernetes environments. Use the below chocolatey command to install helm.
choco install kubernetes-helm -y
Register Repositories to helm
Add the default repository to helm using below command.
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
Add the bitnami repository to helm using the below command
helm repo add bitnami https://charts.bitnami.com/bitnami
Once the above repos are added to helm. Search for nginx using the below command to ensure that we have pulled the latest nginx charts into the repository. Use the below command to search
helm search repo nginx
Deploy nginx ingress controller
Run the following command to install bitnami nginx controller on to the default linux nodes in the cluster.
helm install <deployment-name> bitnami/nginx-ingress-controller ` --set replicaCount=1 ` --set nodeSelector."beta\.kubernetes\.io/os"=linux ` --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux ` --set-string controller.config.proxy-body-size=10m ` --set service.externalTrafficPolicy=Local `
Retrieve external ip for DNS
Run the following command to check the status of the ingress controller apps deployed into the cluster. Wait until the status changes to Running.
kubectl get pods -o wide -A
Run the below command to get the external ip of the ingress controller in the cluster. This returns a cname which can be used for managing the DNS entries going into the applications running in the cluster.
kubectl --namespace default get services -o wide -w bitnami-ingress-nginx-ingress-controller
Note: If you are working with a dummy DNS names you can perform a nslookup on the CNAME and extract the IP Address to add them to your local hosts file with the relevant host names.