Kubernetes is a container orchestration and management system that deploys containerized applications inside a cluster. Sometimes developers need to expose applications outside the cluster. For this purpose, cluster IP, nodeport, load balancer and ingress can be used. Ingress is a Kubernetes API object used to expose a containerized application or service outside the cluster.
Managing application traffic is one of the essential parts of application deployment and Kubernetes Ingress is used to manage the incoming traffic of the application. Traffic management rules are defined in the ingress resource (yaml file). To use the ingress resource, the cluster will need to be running an ingress controller.
This blog will display:
What is ingress controller?
The ingress controller is considered the brain of ingress. Kubernetes Ingress relies entirely on the Ingress Controller and enables us to make hosting applications interactive. Moving applications to a Kubernetes cluster will introduce traffic management challenges. The ingress controller eliminates complexity and acts as a bridge between the external entity and the Kubernetes service.
When a request comes from an external entity outside the cluster, the ingress controller reads instructions from the ingress resource and redirects the request to the pod.
In the above scenario, the request is received from an external source, so it is the first “hit”.entry 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?
A variety of ingress controllers can be used within a Kubernetes cluster to manage and process ingress resources, such as Nginx Ingress Controller, HAProxy Ingress Controller, ASK Application Gateway, Contour, and many others. Minikube provides a built-in Nginx ingress controller.
To deploy the MiniCube Built-In Ingress Controller, go to the demonstration below.
Step 1: Launch Powershell
Launch Windows PowerShell with administrative rights. Using Hyper V built into Windows and running a cluster on a virtual machine requires administrator rights:
Step 2: Start the Minikube Cluster
Start the Minikube Kubernetes cluster via “minikube start” Permission:
To check if the cluster is running, access the Kubernetes nodes:
Step 3: List Minikube's Additional Features
Now, let's list the additional features of a minikube cluster:
Here, you can see “Entry“Available and currently it is”disabled,
Step 4: Enable and Deploy the Built-in Ingress Controller
To enable Minikube Ingress Controller, use the command below:
minikube addon Able Entry
By doing this, the new namespace “login-nginx“will be activated and the ingress controller will start:
Step 5: Verification
For confirmation, list the pods of “login-nginxTo do this, use “namespace.”kubectl get pods -n
kubectl get pods -n login-nginx
Here, you can see that the ingress nginx controller is running:
How to disable ingress controller in Kubernetes?
Sometimes, the developer does not need an ingress controller because they are working with a containerized application that does not require interaction with any external entity. Running ingress controller takes different system resources as it will properly deploy ingress nginx, run pods and deploy replicasets.
To optimize Kubernetes cluster performance, the user can disable the ingress controller using the command below:
disable minikube addon login
After disabling the ingress controller, again “login-nginxPods for verification:
kubectl get pods -n login-nginx
The output shows that we have effectively disabled the ingress controller:
Bonus Tip: How to deploy an ingress controller in Kubernetes using the “kubectl apply” command?
Minikube is mostly used for testing purposes or deploying small applications. However, when users need to run multi-node clusters to deploy large-scale applications, they can run Kubernetes on different platforms such as Docker or any container runtime.
To run Kubernetes Ingress Controller on different Kubernetes platforms, execute the command below:
apply kubectl -F https:,raw.githubusercontent.com,kubernetes,login-nginx,main,deploy,steady,the provider,Cloud,deployment.yaml
This will install and deploy the ingress-nginx controller to the Kubernetes cluster:
To verify, first access the cluster's namespace:
Here, you can see “login-nginx“The new namespace is activated. This will run the ingress controller inside the cluster:
To access all Kubernetes resourceslogin-nginx” namespace, run the command below. right here”-nThe ” option defines the namespace:
kubectl get all -n login-nginx
The output below shows that the entry nginx controller is executing the deployment, replicaset, and pod:
To access only ingress-nginx pods, run the command below:
kubectl get pods -n login-nginx
That's all about deploying the Kubernetes Ingress Controller.
conclusion
Minikube offers a built-in admission controller. To run ingress in a minikube Kubernetes cluster, use “minikube addons enable entry, It'll startlogin-nginxController in the cluster. To run an ingress controller in Kubernetes that is running on other platforms instead of Minikube, use “kubectl apply -f