Kubernetes Ingress provides a very simple way to route external traffic to your internal services. You’ll define ingress objects to control the routing mechanism of the Ingress and Nginx Ingress controller will handle the traffic routing for you.
In this post, I’ll show you how to install Nginx Ingress controller on Kubernetes(K8s) cluster. I’ve deployed K8s cluster on DigitalOcean and connected my kubectl CLI client to the cluster using doctl command
doctl kubernetes cluster kubeconfig save <CLUSTER_ID>
If you don’t have a cluster already deployed then deploy a small cluster with two nodes on DigitalOcean.
Signup with DigitalOcean and get $100 credit. Pay only for worker nodes, master nodes are free on DigitalOcean
Now, that you are connected to the cluster. Install Nginx Ingress controller using helm
Install Helm on Mac
Helm is a package manager for Kubernetes. With Helm charts you deploy complex stack on the cluster without manually deploying each deployment and required services.
On Mac you can simply install helm using the brew installer.
brew install helm
For other operating systems please refer this link
Now, add the helm repo and update
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update
Install Nginx Ingress Controller
Finally, install the Nginx controller by entering following command in your terminal.
There are several other Nginx Ingresses.
Only the LoadBalancer Service knows the IP address of the automatically created Load Balancer. Some apps (such as ExternalDNS) need to know its IP address, but can only read the configuration of an Ingress. The Controller can be configured to publish the IP address on each Ingress by setting the
controller.publishService.enabled parameter to true during helm install. It is recommended to enable this setting to support applications that may depend on the IP address of the Load Balancer.
helm install ingress-nginx ingress-nginx/ingress-nginx --set controller.publishService.enabled=true
Once installed. You’ll get output something like this
NAME: ingress-nginx LAST DEPLOYED: Mon Feb 1 12:32:17 2021 NAMESPACE: kube-system STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: The ingress-nginx controller has been installed. It may take a few minutes for the LoadBalancer IP to be available. You can watch the status by running 'kubectl --namespace kube-system get services -o wide -w ingress-nginx-controller'
Verify the installation
You can verify the installation by following command on you terminal session. It will install two services of type LoadBalancer and ClusterIP. DigitalOcean will automatically create a new load balancer of size “small” which costs $10 per month. Once, the load balancer is created you can see an External IP assigned for your service.
kubectl get svc --all-namespaces