| by Arround The Web | No comments

How to Deploy Ingress Controller in Kubernetes?

Kubernetes is a container orchestration and management system that deploys the containerized application inside the cluster. Sometimes developers are required to expose the application outside the cluster. For this purpose, Cluster IP, Nodeport, Load balancer, and Ingress can be used. The Ingress is a Kubernetes API object used to expose the containerized application or service outside the cluster.

Management of application traffic is one of the essential parts of application deployment and Kubernetes Ingress is used to manage incoming traffic of the application. Traffic management rules are defined in the Ingress resource (yaml file). To use the Ingress resource, the cluster must need to run the ingress controller.

This blog will demonstrate:

What is Ingress Controller?

The Ingress controller is considered as a brain of ingress. The Kubernetes ingress completely relies on the ingress controller and enables us to mutualize the hosting applications. Moving the application to the Kubernetes cluster will bring traffic management challenges. The Ingress controller eliminates the complexity and acts as a bridge between an external entity and a kubernetes service.

When the request comes from an external entity outside the cluster, the ingress controller reads the instructions from the ingress resource and redirects the request to the pod.


In the above scenario, the request is received from an external source, then it first hits the “Ingress controller”. After that, the ingress controller reads the instructions and routing rules from the Ingress resource and will transfer the request or traffic to the desired pod running inside the cluster.

How to Deploy Minikube Built-In Ingress Controller?

Different kinds of Ingress controllers can be used within a Kubernetes cluster to manage and process the Ingress resource such as a Nginx ingress controller, HAProxy ingress controller, ASK application gateway, Contour, and many more. The minikube offers built-in Nginx ingress controller.

To deploy the minikube built-in Ingress controller, go through the below demonstration.

Step 1: Launch PowerShell

Launch the Windows PowerShell with administrative rights. The administrator rights are required to use Windows built-in Hyper V and run a cluster on the virtual machine:


Step 2: Start minikube Cluster

Start the minikube Kubernetes cluster through the “minikube start” command:

minikube start

 

To check if the cluster is running or not, access the Kubernetes nodes:

kubectl get nodes

 

Step 3: List the minikube Additional Features

Now, list down the additional features of the minikube cluster:

minikube addons list

 

Here, you can see “ingress” is available and currently it is “disabled”:


Step 4: Enable and Deploy Built-in Ingress Controller

To enable the minikube Ingress controller, utilize the below command:

minikube addons enable ingress

 
Upon doing so, the new namespace “ingress-nginx” will be activated and start the Ingress controller:


Step 5: Verification

For confirmation, list down pods of the “ingress-nginx” namespace. To do so, use the “kubectl get pods -n <name-space>” command:

kubectl get pods -n ingress-nginx

 
Here, you can see the ingress nginx controller is running:


How to Disable Ingress Controller in Kubernetes?

Sometimes, the developer does not require the Ingress controller as they are working with a containerized application that may not need interaction with any external entity. The running ingress controller takes separate system resources as it will properly deploy the deployment of ingress nginx, run pods, and ReplicaSet.

To optimize the Kubernetes cluster performance, the user can disable the Ingress controller using the below command:

minikube addons disable ingress

 

After disabling the ingress controller, again access the “ingress-nginx” pods for verification:

kubectl get pods -n ingress-nginx

 
The output shows that we have effectively disabled the ingress controller:

Bonus Tip: How to Deploy Ingress Controller in Kubernetes Using “kubectl apply” Command?

The minikube is mostly used for testing purposes or to deploy small applications. However, when users are required to run multi-node clusters to deploy applications on a larger scale, they may run Kubernetes on different platforms such as Docker or any container runtime.

To run the Kubernetes Ingress controller on different Kubernetes platforms, execute the below command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml

 
This will install and deploy the ingress-nginx controller in the Kubernetes cluster:


For verification, first access the namespace of the cluster:

kubectl get ns

 
Here, you can see the “ingress-nginx” new namespace is active. This will run the ingress controller inside the cluster:


To access all Kubernetes resources of the “ingress-nginx” namespace, run the below command. Here, the “-n” option defines the namespace:

kubectl get all -n ingress-nginx

 
The below output shows that the ingress nginx controller Deployment, ReplicaSet, and Pod are executing:


In order to access only pods of ingress-nginx, run the below command:

kubectl get pods -n ingress-nginx

 

That is all about deploying a Kubernetes ingress controller.

Conclusion

The minikube provides a built-in ingress controller. To run ingress in minikube kubernetes cluster, use the “minikube addons enable ingress”. This will start the “ingress-nginx” controller in the cluster. To run the ingress controller in Kubernetes that is running on other platforms rather than minikube, use the “kubectl apply -f <GitHub-ingress-controller-URL>” command. This post has illustrated how to deploy an ingress controller in Kubernetes.

Share Button

Source: linuxhint.com

Leave a Reply