An illustrated network operations room with a switch and a cable routing plan
Production notebook

Azure Kubernetes Service (AKS) + nginx-ingress with Static IP

September 27, 2023

A concise archive of assigning a stable public address to an nginx ingress controller on AKS.

KubernetesAzureIngress

Credit: Growtika (Unsplash)

Coming from a GCP background, it was straightforward to set static IPs for nginx-ingress-powered clusters on GKE using the kubernetes.io/ingress.global-static-ip-name annotation.

However, there is not much documentation on how to do this on Azure Kubernetes Service (AKS), hence this short document.

Steps

1. Create the Public IP Address on Azure Portal with your cluster’s resource group

Azure portal form for creating a Public IP Address with the cluster resource group selected

2. Install nginx-ingress and set the loadBalancerIP to the IP you've created in step 1

STATIC_IP=<your static IP here>

helm upgrade --install ingress-nginx ingress-nginx \
 --repo https://kubernetes.github.io/ingress-nginx \
 --namespace ingress-nginx \
 --create-namespace \
 --set rbac.create=true \
 --set controller.stats.enabled=true \
 --set controller.metrics.enabled=true \
 --set controller.service.externalTrafficPolicy="Local" \
 --set controller.service.loadBalancerIP=$STATIC_IP

3. Monitor the new LoadBalancer resource. The static IP from step 1 should show up after a few seconds

Terminal output showing the new LoadBalancer resource with the static external IP

Other Notes

  • If you use kubectlto install nginx-ingress , you can simply update the load balancer IP in the ingress-nginx-controllerservice’s spec.loadBalancerIP
  • There is a way to specify a custom resource group, but this is the most straightforward way to do it since we’re adjusting the public IP to follow the k8s cluster instead of the other way around

References