DEV Community

Cover image for What is Ingress Controller in Kubernetes?
Sagar Jadhav
Sagar Jadhav

Posted on • Originally published at developersthought.in

What is Ingress Controller in Kubernetes?

In Deploy phpMyAdmin application on kubernetes blog I used NodePort service type to expose application to external world but disadvantage with that approach is port needs to be exposed on each node and there is a dependency on external load balancer for load balancing requests, custom hostname and SSL/TLS encryption support etc. With the help of Ingress controllers I can eliminate dependency on external load balancer. In this blog I am using Nginx Ingress controller to expose PHPMyAdmin application to external world. Learn more about ingress controller here

Architecture

Alt Text

Prerequisites:

Deploy PHPMyAdmin Application

Follow Deploy phpMyAdmin application on kubernetes blog

Go to session_2 directory

cd ../session_3/
Enter fullscreen mode Exit fullscreen mode

Step 1: Enable Nginx ingress controller

minikube addons enable ingress
Enter fullscreen mode Exit fullscreen mode
kubectl get pods --watch -n kube-system
Enter fullscreen mode Exit fullscreen mode

Exit once controller pod goes into running state

This step is valid only for Minikube. Check steps to enable Nginx Ingress controller on Kubernetes here

Step 2: Delete PHPMyAdmin NodePort service

kubectl delete svc phpmyadmin
Enter fullscreen mode Exit fullscreen mode

Step 3: Deploy PHPMyAdmin ClusterIP service

kubectl create -f phpmyadmin-service.yaml
Enter fullscreen mode Exit fullscreen mode

Step 4: Deploy PHPMyAdmin Ingress rule

kubectl create -f phpmyadmin-ingress.yaml
Enter fullscreen mode Exit fullscreen mode
kubectl get ingress --watch
Enter fullscreen mode Exit fullscreen mode

Exit once address gets populated

Step 5: Update hosts file custome hostname

Add below entry in /etc/hosts

<INGRESS_ADDRESS> myapp.xyz
Enter fullscreen mode Exit fullscreen mode

Get INGRESS_ADDRESS from kubectl get ingress

Demo

Top comments (0)