Exercise Overview: Traffic from the Internet Setup with AKS and Ingress Controller. This exercise guides participants through the process of setting up an Azure Kubernetes Service (AKS) cluster with a Standard External Load Balancer and an Ingress Controller. The goal is to expose applications to the internet and test connectivity. Key steps include:
- Azure Kubernetes Service (AKS) Cluster (Perform steps 1 to 4 if not already running)
- Basic Load Balancer
Solution
Creates an Azure Resource Group for organizing and managing resources.
az group create --location westeurope --resource-group demo-weu-rg
Generates a Service Principal for AKS with the necessary permissions.
az ad sp create-for-rbac --skip-assignment -n "spn-aks"
NOTE: Replace placeholders in --subscription
, --service-principal
, and --client-secret
with actual values.
Deploys an AKS cluster with specified configurations.
az aks create \
--location westeurope \
--subscription <Your-Subscription-ID> \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--ssh-key-value $HOME/.ssh/id_rsa.pub \
--service-principal "<Your-Service-Principal-ID>" \
--client-secret "<Your-Client-Secret>" \
--network-plugin kubenet \
--load-balancer-sku standard \
--outbound-type loadBalancer \
--node-vm-size Standard_B2s \
--node-count 1 \
--tags 'ENV=Demo' 'OWNER=Corporation Inc.'
Retrieves and merges the AKS cluster's kubeconfig into the local environment.
az aks get-credentials \
--resource-group demo-weu-rg \
--name <Your-AKS-Cluster-Name> \
--admin
Sets up an Ingress Controller using Helm charts, ensuring proper configuration for Linux nodes and Azure Load Balancer health checks.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx --version 4.1.3 --namespace ingress-nginx --create-namespace --set controller.replicaCount=1 --set controller.nodeSelector."kubernetes\.io/os"=linux --set controller.admissionWebhooks.patch.nodeSelector."kubernetes\.io/os"=linux --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz --set defaultBackend.nodeSelector."kubernetes\.io/os"=linux
Monitors the Ingress Controller service to ensure successful deployment and obtain relevant details.
kubectl get services --namespace ingress-nginx -o wide -w ingress-nginx-controller
Deploys a sample application on the AKS cluster with associated services and ingress resources.
kubectl apply -f files/deployment.yaml
kubectl apply -f files/service.yaml
kubectl apply -f files/ingress.yaml
- http://IP-FROM-OUR-INGRESS/
- http://IP-FROM-OUR-INGRESS/hello-world-two
- http://IP-FROM-OUR-INGRESS/static
Deletes the resource group and associated resources.
az group delete -n demo-weu-rg --yes --no-wait