Ingress Controller in AKS
Many organizations are turning to software containers to facilitate their digital transformations, customer requirements, AI/ML adoption, and 5G technology.
It becomes difficult for them to achieve perform and resilience.
How this problem can be solved???
☹
Ingress Controller: An Ingress controller is a specialized load balancer for Kubernetes (and other containerized) environments. Kubernetes is the de facto standard for managing containerized applications. For many enterprises, moving production workloads into Kubernetes brings additional challenges and complexities around application traffic management. An Ingress controller abstracts away the complexity of Kubernetes application traffic routing and provides a bridge between Kubernetes services and external ones.
Kubernetes Ingress controllers:
- Accept traffic from outside the Kubernetes platform, and load balance it to pods (containers) running inside the platform
- Can manage egress traffic within a cluster for services which need to communicate with other services outside of a cluster
- Are configured using the Kubernetes API to deploy objects called “Ingress Resources”
- Monitor the pods running in Kubernetes and automatically update the load‑balancing rules when pods are added or removed from a service
An ingress controller probably seems like just another technology widget in the Kubernetes realm. Many people view them as low-value commodities, but in reality, they can be a powerful tool in your stack. When deployed and configured properly, ingress controllers can radically simplify operation of Kubernetes clusters while enhancing security and improving performance and resilience.
Ingress Controller in AKS: -
Ø Create Static Public IP
# Get the resource group name of the AKS cluster
az aks show — resource-group <aks rg name> — name <aks name> — query nodeResourceGroup -o tsv
# TEMPLATE — Create a public IP address with the static allocation
az network public-ip create — resource-group <REPLACE-OUTPUT-RG-FROM-PREVIOUS-COMMAND> — name myAKSPublicIPForIngress — sku Standard — allocation-method static — query publicIp.ipAddress -o tsv
# Make a note of Public IP created for Ingress
Ø Install Ingress Controller
# Create a namespace for your ingress resources
kubectl create namespace ingress-basic
# Add the official stable repository
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm repo update
# Customizing the Chart Before Installing.
helm show values ingress-nginx/ingress-nginx
# Use Helm to deploy a NGINX ingress controller
helm install ingress-nginx ingress-nginx/ingress-nginx \
— namespace ingress-basic \
— set controller.replicaCount=2 \
— set controller.nodeSelector.”beta\.kubernetes\.io/os”=linux \
— set defaultBackend.nodeSelector.”beta\.kubernetes\.io/os”=linux \
— set controller.service.externalTrafficPolicy=Local \
— set controller.service.loadBalancerIP=”REPLACE_STATIC_IP”
# List Services with labels
kubectl get service -l app.kubernetes.io/name=ingress-nginx — namespace ingress-basic
# List Pods
kubectl get pods -n ingress-basic
kubectl get all -n ingress-basic
# Access Public IP
http://<Public-IP-created-for-Ingress>
# Output should be
404 Not Found from Nginx
Ø It’s time to deploy Application Manifest files
vi 01-NginxApp1-Deployment.yml
vi 02-NginxApp1-ClusterIP-Service.yml
vi 03-Ingress-Basic.yml
# Deploy all the Manifest files
kubectl apply -f kube-manifests/
# List deployed Pods
kubectl get pods
# List deployed Services
kubectl get svc
# List deployed Ingress
kubectl get ingress
# Access Application
http://<Public-IP-created-for-Ingress>/app1/index.html
http://<Public-IP-created-for-Ingress>
# Verify Ingress Controller Logs
kubectl get pods -n ingress-basic
kubectl logs -f <pod-name> -n ingress-basic
Context Path Based Routing:
GitHub source code link:
1. Create AKS Application Manifest
mkdir kube-manifest && cd kube-manifest
vi 01-NginxApp1-Manifests
vi 02-NginxApp2-Manifests
vi 03-UserMgmtmWebApp-Manifests
# Deploy Apps
kubectl apply -R -f kube-manifests/
# List Pods
kubectl get pods
# List Services the deployed services
kubectl get svc
# List Ingress record
kubectl get ingress
# Verify Ingress Controller Logs
kubectl get pods -n ingress-basic
kubectl logs -f <pod-name> -n ingress-basic
Now you can access Application :
# Access App1
http://<Public-IP-created-for-Ingress>/app1/index.html
# Access App2
http://<Public-IP-created-for-Ingress>/app2/index.html
# Access Usermgmt Web App
http://<Public-IP-created-for-Ingress>
Username: admin101
Password: password101