AKS Hour 2: Networking
- Make an informed choice between Overlay (Azure CNI Overlay) and Flat (Azure CNI Pod Subnet / Node Subnet), and explain the impact of the kubenet retirement on 2028-03-31 and the migration commands.
- Build a non-overlapping, scalable address plan for
vnet-aks-lab(10.10.0.0/16): node subnet, Pod CIDR192.168.0.0/16, Service CIDR10.0.0.0/16, DNS10.0.0.10, API Server subnet, and AGC subnet. - Explain the eBPF data plane of Azure CNI powered by Cilium (no kube-proxy), its limits (Linux only; ipBlock cannot select Pod or node IPs), and which features require ACNS.
- Trace the outbound and inbound packet paths for a Pod: Overlay source NAT → node IP → load balancer outbound rules / NAT Gateway / UDR → firewall. Calculate SNAT port capacity.
- Compare a private cluster (Private Link) with API Server VNet integration (delegated subnet + internal load balancer). Know the valid values for
--private-dns-zoneand the hub-spoke DNS design. - Understand how the Ingress-NGINX retirement affects AKS. The NGINX in the application routing add-on receives critical security patches only until November 2026. Migrate to the application routing Gateway API (
approuting-istio) or Application Gateway for Containers. - Use Cilium to enforce a default-deny network policy, and know the Azure NPM retirement dates (Windows 2026-09-30, Linux 2028-09-30).
- Customize CoreDNS (
coredns-custom), LocalDNS (defaultPreferredon AKS Standard from 1.37), private DNS zones, and the UDP/TCP 53 requirements for custom DNS servers.
1-hour timetable
| # | Time | Module | Core content | Animation / interaction | Lab (rg-aks-lab · canadacentral) |
|---|---|---|---|---|---|
| 0 | Before class | Warm-up | Reuse the hour 1 variables. Create vnet-aks-lab, the subnets, and the cluster identity. Build the networking lab cluster aks-lab-net. | Address plan self-check | BYO VNet + Overlay + Cilium cluster |
| 1 | 00–06 | Network model selection | Overlay vs Flat, IPAM and data plane separation, kubenet retirement on 2028-03-31, reserved ranges, CIDR planning | IP capacity calculator + selection wizard | Read the networkProfile of both clusters; kubenet migration drill commands |
| 2 | 06–13 | Azure CNI Overlay and Cilium | /24 per node, 250-Pod limit, unencapsulated routing domain, SNAT to node IP, Cilium eBPF (no kube-proxy), ACNS | Cross-node Pod traffic and SNAT animation | Observe Pod IPs, node podCIDRs, and Cilium status |
| 3 | 13–21 | Outbound: LB / NAT Gateway / UDR | Five outboundType values, migration matrix, SNAT port formula, NAT Gateway StandardV2 default, UDR + firewall, outbound IP changes | Core animation: Pod outbound and inbound packet paths | Migrate LB → userAssignedNATGateway and verify the egress IP |
| 4 | 21–28 | Private clusters and API Server VNet integration | Private Link vs delegated-subnet ILB, --private-dns-zone, --disable-public-fqdn, command invoke, NSG ports | kubectl → API Server path comparison | Convert the lab cluster to VNet integration and enable private mode (optional) |
| 5 | 28–35 | Ingress: application routing and AGC | Ingress-NGINX retirement impact, application routing NGINX and Gateway API (approuting-istio), AGC (ALB Controller, frontend, association) | Inbound request path comparison | Expose myapp with Gateway + HTTPRoute |
| 6 | 35–42 | Network policy | Cilium / Azure NPM / Calico comparison and retirement, default deny, DNS allow rules, FQDN/L7 (ACNS) | Policy simulator: which connections are allowed | Zero-trust policy for the myapp namespace |
| 7 | 42–50 | DNS and private DNS zones | CoreDNS, coredns-custom, LocalDNS (169.254.10.10/11), ndots, 168.63.129.16, private zones and conditional forwarding | Full path of one DNS query | Forward custom domains, verify LocalDNS |
| 8 | 50–60 | Network readiness review and common errors | Review checklist, address overlap, SNAT exhaustion, subnet IP exhaustion, NSG false blocks, DNS failures | Review scorer + interactive troubleshooting tree | Fault injection and fixes |
| — | After class | Cheat sheet · Capstone lab | Deliver a “production network baseline” for myapp | Final quiz (12 questions) | Capstone lab |
Knowledge coverage matrix
| Target skills | M1 | M2 | M3 | M4 | M5 | M6 | M7 | M8 | Key commands | Lab |
|---|---|---|---|---|---|---|---|---|---|---|
| Choose a network model and plan CIDRs | ✓ | ✓ | · | ✓ | · | · | · | ✓ | az aks show --query networkProfile | Module 0 / 1 |
| Migrate kubenet / upgrade the Cilium data plane | ✓ | ✓ | · | · | · | ✓ | · | · | az aks update --network-plugin-mode overlay, --network-dataplane cilium | M1 drill |
| Explain Pod outbound SNAT and the inbound path | · | ✓ | ✓ | · | ✓ | · | · | ✓ | curl ifconfig.me, az network lb outbound-rule list | M3 egress IP verification |
| Choose and migrate the outbound type | · | · | ✓ | · | · | · | · | ✓ | az aks update --outbound-type | LB → NAT GW |
| Private control plane and API access | · | · | ✓ | ✓ | · | · | ✓ | ✓ | --enable-apiserver-vnet-integration, az aks command invoke | M4 conversion |
| Ingress controller selection and Ingress-NGINX migration | · | · | · | · | ✓ | · | · | ✓ | --enable-gateway-api --enable-app-routing-istio | Gateway + HTTPRoute |
| Zero-trust network policy | · | ✓ | · | · | · | ✓ | ✓ | ✓ | kubectl get netpol,cnp -A | Default deny + allow rules |
| DNS customization and private zone resolution | · | · | · | ✓ | · | ✓ | ✓ | ✓ | coredns-custom, --localdns-config, dig | M7 forwarding and LocalDNS |
| Network troubleshooting | · | · | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | kubectl debug, cilium-dbg, events | M8 fault injection |
What this hour leaves out (and where to learn it)
| Topic | Why it is not in this hour | Where to learn it |
|---|---|---|
| Kubernetes-generic semantics of Service / Ingress / Gateway API / NetworkPolicy | This hour covers only the AKS implementation and selection | Kubernetes course Hour 3 (networking); for an AKS introduction, see Kubernetes course Hour 6 |
| Cluster identity, Workload Identity, Key Vault CSI (including the identity authorization details for ingress TLS certificates) | Belongs to the identity and security topic | Hour 3 |
| Istio service mesh (sidecars, mTLS, traffic management) | This hour uses only its “sidecar-free Gateway API ingress” part | AKS Istio add-on documentation |
| In-depth troubleshooting of SNAT port exhaustion and subnet IP exhaustion | M8 in this hour only covers introductory diagnosis | Hour 7 (troubleshooting and optimization) |
| Deploy ingress and applications with Helm / GitHub Actions / Azure DevOps | Belongs to the delivery toolchain | Helm course Hour 3 · GitHub course · Azure DevOps course |
| Network observability metrics (Hubble flow logs, container network metrics) into Prometheus | Belongs to the monitoring topic | Prometheus & Grafana course Hour 3 |
How to use this course material
Principles · diagrams · animation · commands · lab · production case · troubleshooting · quiz · voice · video. Start with “Principles” and “Animation”. The module 3 “Animation” page is the core of this hour: follow every address translation on the outbound and inbound paths.
A module counts toward progress when your quiz score is ≥ 70% or when you click “Mark this module complete”. Progress is saved in this browser (if local storage is blocked, it is cleared on refresh).
The “Voice” tab reads the narration script aloud using the browser's built-in Web Speech API (en-US). If no English voice pack is installed, the narration script can still be read or passed to a TTS tool.
--network-plugin is not specified; starting with API version 2026-06-01, managedNATGateway defaults to the StandardV2 SKU (within availability zones); default outbound access for managed VMs has not been provided since 2026-03-31 (AKS managed VNet subnets are private by default); critical security patches for the application routing NGINX are supported until November 2026; Azure NPM stops being supported on Windows nodes on 2026-09-30 and on Linux nodes on 2028-09-30; starting with 1.37, AKS Standard node pools default to LocalDNS Preferred mode; the AKS add-on for the ALB Controller is still in preview. The lab commands have not been run in a real subscription; the outputs are examples.Module 0 · Warm-up (planning the VNet and address space)
- Completed Hour 1: the resource group
rg-aks-lab(canadacentral) exists in your subscription. The hour 1 clusteraks-labcan be kept (module 1 reads its network configuration for comparison), or it can be stopped or deleted. - Local machine or Cloud Shell: Azure CLI (
az version≥ 2.86.0, the official requirement for this hour's Gateway API lab), kubectl, and kubelogin (az aks install-cli). - Required Azure roles on
rg-aks-lab: Contributor + Role Based Access Control Administrator (or User Access Administrator), because you need to grant the cluster identity Network Contributor on the subnets. - Sample app: myapp from the Docker course (Flask + gunicorn + Redis, port 5000,
/healthz), with the image pushed to ACR$ACRin hour 1.
Step 1: Environment variables (used consistently across all hours)
RG=rg-aks-lab; LOC=canadacentral; CLUSTER=aks-lab
NETCLUSTER=aks-lab-net # dedicated lab cluster for this hour (aks-lab-<topic> naming convention)
VNET=vnet-aks-lab
ACR=$(az acr list -g $RG --query "[0].name" -o tsv) # ACR created in hour 1: acraks<suffix>
echo "ACR=$ACR"
az account show --query "{sub:name, user:user.name}" -o table
If ACR is empty, the hour 1 ACR has been deleted. Run ACR=acraks$RANDOM; az acr create -g $RG -n $ACR --sku Basic, then rebuild the image from the myapp source directory with az acr build -r $ACR -t myapp:1.0 ..
Step 2: Write the address plan first (conventions used throughout this hour)
| Purpose | Name | Address | Notes |
|---|---|---|---|
| VNet | vnet-aks-lab | 10.10.0.0/16 | Must not overlap the hub, local networks, or peered VNets |
| Node subnet | snet-nodes | 10.10.0.0/22 | 1024 addresses; Azure reserves 5 per subnet. With Overlay, only nodes and the internal load balancer use addresses. |
| API Server subnet (module 4) | snet-apiserver | 10.10.4.0/28 | Delegated to Microsoft.ContainerService/managedClusters; official minimum /28 |
| AGC subnet (module 5, optional) | snet-agc | 10.10.8.0/24 | Delegated to Microsoft.ServiceNetworking/trafficControllers; each association needs at least 256 addresses |
| Pod CIDR (Overlay) | — | 192.168.0.0/16 | Fixed /24 per node → up to 256 nodes; not within the VNet address space |
| Service CIDR | — | 10.0.0.0/16 | Only valid inside the cluster; must not overlap the VNet, the Pod CIDR, or peered networks |
| Cluster DNS | kube-dns Service | 10.0.0.10 | Within the Service CIDR; cannot use the first address (10.0.0.1 is assigned to the kubernetes Service) |
169.254.0.0/16, 192.0.2.0/24, 172.30.0.0/16, 172.31.0.0/16. That is why a large block such as 172.16.0.0/12 cannot be used as the Pod CIDR. Note that if you use 10.0.0.0/16 as the Service CIDR and your corporate network has real 10.0.x.x hosts, Pods will not be able to reach them. This is the classic failure in module 8.Step 3: Create the VNet, subnets, and cluster identity
az network vnet create -g $RG -n $VNET -l $LOC --address-prefixes 10.10.0.0/16 \ --subnet-name snet-nodes --subnet-prefixes 10.10.0.0/22 az network vnet subnet create -g $RG --vnet-name $VNET -n snet-apiserver \ --address-prefixes 10.10.4.0/28 --delegations Microsoft.ContainerService/managedClusters # User-assigned identity for the cluster (control plane): BYO VNet requires it to have Network Contributor on the subnets az identity create -g $RG -n id-aks-lab-net ID_RES=$(az identity show -g $RG -n id-aks-lab-net --query id -o tsv) ID_PRINCIPAL=$(az identity show -g $RG -n id-aks-lab-net --query principalId -o tsv) VNET_ID=$(az network vnet show -g $RG -n $VNET --query id -o tsv) az role assignment create --assignee-object-id $ID_PRINCIPAL --assignee-principal-type ServicePrincipal \ --role "Network Contributor" --scope $VNET_ID SUBNET_ID=$(az network vnet subnet show -g $RG --vnet-name $VNET -n snet-nodes --query id -o tsv) APISERVER_SUBNET_ID=$(az network vnet subnet show -g $RG --vnet-name $VNET -n snet-apiserver --query id -o tsv)
Here Network Contributor is granted on the entire VNet (a simplification for the lab). In production, grant the minimum permissions only on snet-nodes and snet-apiserver; the official requirement is that both have permissions, otherwise API Server VNet integration creation will fail. id-myapp is the application identity used for Workload Identity in hour 3. Do not mix it with the cluster identity here.
Step 4: Create the networking lab cluster aks-lab-net
az aks create -g $RG -n $NETCLUSTER -l $LOC \ --tier free --node-count 2 --node-vm-size Standard_D4ds_v5 \ --network-plugin azure --network-plugin-mode overlay --network-dataplane cilium \ --pod-cidr 192.168.0.0/16 --service-cidr 10.0.0.0/16 --dns-service-ip 10.0.0.10 \ --vnet-subnet-id $SUBNET_ID --assign-identity $ID_RES \ --outbound-type loadBalancer \ --enable-oidc-issuer --enable-workload-identity \ --attach-acr $ACR --generate-ssh-keys az aks get-credentials -g $RG -n $NETCLUSTER --overwrite-existing kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE aks-nodepool1-31214567-vmss000000 Ready <none> 4m v1.37.1 10.10.0.4 <none> Ubuntu 24.04.3 LTS aks-nodepool1-31214567-vmss000001 Ready <none> 4m v1.37.1 10.10.0.5 <none> Ubuntu 24.04.3 LTS
--network-plugin azure --network-plugin-mode overlay. If you specify only --network-plugin azure and omit the mode, AKS uses Node Subnet (flat) mode for backward compatibility; Overlay is the default only when nothing is specified. ② Use loadBalancer outbound first; module 3 migrates to NAT Gateway, so you can see the egress IP change for yourself. ③ The 4-vCPU Standard_D4ds_v5 meets the minimum requirement for LocalDNS (module 7). ④ Do not enable API Server VNet integration yet; module 4 demonstrates converting an existing cluster.az aks delete -g $RG -n $NETCLUSTER --yes --no-wait; when everything is finished, az group delete -n $RG --yes --no-wait. Pause: az aks stop -g $RG -n $NETCLUSTER.Step 5: Deploy myapp (the target of all labs in this hour)
apiVersion: v1
kind: Namespace
metadata: { name: myapp }
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: redis, namespace: myapp, labels: { app: redis } }
spec:
replicas: 1
selector: { matchLabels: { app: redis } }
template:
metadata: { labels: { app: redis } }
spec:
containers:
- name: redis
image: redis:7-alpine
ports: [{ containerPort: 6379 }]
---
apiVersion: v1
kind: Service
metadata: { name: redis, namespace: myapp }
spec:
selector: { app: redis }
ports: [{ port: 6379, targetPort: 6379 }]
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: myapp, namespace: myapp, labels: { app: myapp } }
spec:
replicas: 2
selector: { matchLabels: { app: myapp } }
template:
metadata: { labels: { app: myapp } }
spec:
containers:
- name: myapp
image: ACR_NAME.azurecr.io/myapp:1.0
env: [{ name: REDIS_HOST, value: redis }]
ports: [{ containerPort: 5000 }]
readinessProbe: { httpGet: { path: /healthz, port: 5000 } }
---
apiVersion: v1
kind: Service
metadata: { name: myapp, namespace: myapp }
spec:
selector: { app: myapp }
ports: [{ port: 80, targetPort: 5000 }]
sed "s/ACR_NAME/$ACR/" myapp.yaml | kubectl apply -f - kubectl -n myapp rollout status deploy/myapp kubectl -n myapp get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE myapp-7c9d6b8f5c-2kq8x 1/1 Running 0 40s 192.168.0.37 aks-nodepool1-31214567-vmss000000 myapp-7c9d6b8f5c-x7m4p 1/1 Running 0 40s 192.168.1.12 aks-nodepool1-31214567-vmss000001 redis-5b7c9d4f8-9wq2n 1/1 Running 0 41s 192.168.1.25 aks-nodepool1-31214567-vmss000001
Note: Pod IPs come from 192.168.0.0/24 and 192.168.1.0/24. Each node gets one /24, which is the focus of module 2. The environment variable name REDIS_HOST should follow your myapp implementation from the Docker course.
Warm-up: answer from memory (30 seconds)
In hour 1, when you ran az aks create, which network resources were created in the MC_* node resource group?
The managed VNet (when not BYO), the VMSS network interfaces, the Standard load balancer named kubernetes (with the outbound rule aksOutboundRule), the outbound public IP, the NSG, and (for private clusters) the private endpoint and private DNS zone. This hour opens each of them.
When a Pod accesses myapp.myapp.svc.cluster.local, which component receives the resolution request first?
The Pod's /etc/resolv.conf nameserver points to the kube-dns Service (10.0.0.10 in this hour; the backend is CoreDNS). If LocalDNS is enabled on the node pool, the request goes first to 169.254.10.10/11 on the node. Module 7 breaks this down in detail.
Module 1 · AKS network model selection: Overlay, VNet, and kubenet retirement
- Distinguish the IPAM mode (Overlay / Pod Subnet / Node Subnet / kubenet) from the data plane (Azure iptables / Cilium eBPF). These are two independent choices.
- Select a model based on five questions: how tight IP space is, whether external systems need direct access to Pods, scale, Windows, and virtual nodes.
- Calculate how many VNet addresses the Overlay and flat models each need, and know which ranges AKS reserves.
- Know that kubenet and Node Subnet are both legacy, and learn the one-time, irreversible migration command from kubenet to Overlay.
What: the two network models in AKS
Kubernetes only requires that “each Pod has its own IP, and Pods can reach each other without NAT.” Where Pod IPs come from and how they are routed is decided by the CNI plugin. AKS splits this decision into two layers:
- IPAM (IP address management) mode: where Pod IPs come from. In the Overlay model, Pod IPs come from a private CIDR that is logically isolated from the VNet. In the Flat model, Pod IPs come directly from the VNet subnet.
- Data plane: which component forwards packets on the node and enforces network policy. The traditional Azure data plane is based on iptables (with kube-proxy, Azure NPM, or Calico). Azure CNI powered by Cilium uses eBPF and does not deploy kube-proxy. Cilium can be layered on any of the Overlay, Pod Subnet, or Node Subnet IPAM modes.
| IPAM options | Model | Pod IP source | Can external traffic connect directly to Pods? | Status |
|---|---|---|---|---|
| Azure CNI Overlay | Overlay | Private Pod CIDR, fixed /24 per node | No (SNAT to the node IP when leaving the cluster) | Recommended; the best fit for most scenarios and the default when no plugin is specified |
| Azure CNI Pod Subnet | Flat | A dedicated Pod subnet in the VNet (dynamic or static block allocation) | Yes; Pod IPs are preserved across peered and on-premises networks | Recommended option for the flat model |
| Azure CNI Node Subnet | Flat | Same subnet as the nodes, reserved per maxPods | Pod IPs are visible inside the VNet; outside the VNet, the node IP is seen | Legacy; consider only when you need a managed VNet |
| kubenet | Overlay | Private CIDR + route table (UDR) | No | Legacy, retires 2028-03-31; limit of 400 nodes; Linux only |
Why: why Overlay became the default
In the flat model, every Pod consumes one VNet address. 100 nodes × 30 Pods is 3000 addresses, which enterprise IPAM often cannot approve, and the address ranges must be contiguous and not fragmented. Overlay gives VNet addresses only to nodes. Pods use a private range that can be reused across multiple clusters, and the scale ceiling is higher (Overlay supports 5000 nodes and 250 Pods per node, while kubenet supports 400 nodes). The official comparison table summarizes the benefits as: conserves VNet addresses, supports maximum cluster size, and is simple to configure. The trade-off is that external resources cannot reach Pod IPs directly.
How: the data path differences between the two models
- Overlay: Azure networking creates a separate routing domain for the Pod CIDR. Traffic between Pods on different nodes is forwarded without encapsulation (no VXLAN) and without UDRs, with performance comparable to VMs in the VNet. When the destination is outside the Pod CIDR (a peered VNet, on-premises, or the internet), the source address is SNATed to the node's primary IP.
- Pod Subnet: Pods get real VNet IPs. Every host in the VNet (including peered networks and on-premises networks behind ExpressRoute) sees the Pod IP, and connections can be initiated in both directions. This suits cases where on-premises firewalls allow traffic by Pod source, or where external systems need to connect back to Pods.
- kubenet: each node gets one /24, and traffic between Pods on different nodes takes an extra hop through a route table (UDR) maintained by AKS. BYO route tables, Windows, and AGC are either unsupported or cumbersome.
When: five questions decide the choice
| Question | Leans toward Overlay | Leans toward Pod Subnet (Flat) |
|---|---|---|
| Is VNet address space tight? | Tight → Overlay | Large contiguous ranges available |
| Do external systems need to connect directly to Pod IPs? | No; use Services or ingress | Yes (on-premises systems calling back, or firewall rules by Pod IP) |
| Is most traffic inside the cluster or outside it? | Inside the cluster | External resources |
| Do you need advanced features such as virtual nodes (ACI)? | No | Yes |
| Scale | Up to 5000 nodes | Depends on subnet size |
Comparison with similar technologies
| AKS Azure CNI Overlay | EKS (VPC CNI default) | GKE (VPC-native) | |
|---|---|---|---|
| Default Pod IP source | Private Pod CIDR, isolated from the VNet | VPC subnet IPs (ENI secondary IPs, Flat) | Secondary address range of the subnet (alias IPs) |
| Ways to save addresses | Overlay is the default | Custom networking / prefix delegation | Non-contiguous multiple Pod CIDRs |
| Cross-node forwarding | Azure routing domain, no encapsulation | VPC-native routing | VPC-native routing |
Architecture diagram: Overlay and flat within the same VNet
Flowchart: model selection decisions
Interactive calculator: the same workload, and how many VNet addresses each model needs
Adjust the number of nodes, the Pods per node, and the upgrade surge nodes. Calculation basis: Azure reserves 5 addresses per subnet; Overlay takes one fixed /24 per node from the Pod CIDR; Node Subnet mode reserves (maxPods + 1) × number of nodes VNet addresses; Pod Subnet (dynamic allocation) uses the Pod subnet according to the actual number of Pods. The log below shows the checks AKS actually performs.
60
110
3
Core commands and parameters
| Command / flag | Purpose | Notes |
|---|---|---|
--network-plugin azure|none | Choose Azure CNI or bring your own CNI (BYOCNI) | Defaults to Azure CNI Overlay when omitted; kubenet is already legacy |
--network-plugin-mode overlay | Enable Overlay IPAM | Specifying only --network-plugin azure and omitting this parameter = Node Subnet |
--pod-cidr / --pod-subnet-id | Private Pod CIDR for Overlay / Pod subnet for Pod Subnet mode | Overlay default 10.244.0.0/16 |
--service-cidr, --dns-service-ip | Service address range and kube-dns IP | The Service CIDR must be smaller than /12; the DNS IP cannot be the first address |
--network-dataplane cilium | Use the Cilium eBPF data plane | Independent of IPAM; replaces the old --enable-ebpf-dataplane |
--vnet-subnet-id | Node subnet for BYO VNet | The cluster identity needs Network Contributor on the subnet; the subnet cannot be a delegated subnet |
az aks update --network-plugin azure --network-plugin-mode overlay | kubenet / Node Subnet → Overlay | Irreversible; all node pools are reimaged together; cluster ≥ 1.27 |
Read the networking configuration of an existing cluster
for c in $CLUSTER $NETCLUSTER; do
echo "== $c"
az aks show -g $RG -n $c --query "networkProfile.{plugin:networkPlugin,mode:networkPluginMode,dataplane:networkDataplane,policy:networkPolicy,podCidr:podCidr,svcCidr:serviceCidr,dns:dnsServiceIp,outbound:outboundType}" -o table
done
== aks-lab Plugin Mode Dataplane Policy PodCidr SvcCidr Dns Outbound -------- ------- ----------- -------- -------------- ------------ ---------- ------------ azure overlay azure 10.244.0.0/16 10.0.0.0/16 10.0.0.10 loadBalancer == aks-lab-net Plugin Mode Dataplane Policy PodCidr SvcCidr Dns Outbound -------- ------- ----------- -------- -------------- ------------ ---------- ------------ azure overlay cilium cilium 192.168.0.0/16 10.0.0.0/16 10.0.0.10 loadBalancer
How to verify: if the hour 1 cluster was created without network parameters, it shows the default overlay and 10.244.0.0/16. The lab cluster shows Cilium, with networkPolicy set automatically to cilium. Common mistake: treating an empty networkPluginMode as Overlay. Empty means Node Subnet. Production use: use Azure Resource Graph to find kubenet and Node Subnet clusters in bulk for retirement planning (see below).
Find all kubenet clusters in the subscription (Azure Resource Graph)
az graph query -q "Resources | where type =~ 'microsoft.containerservice/managedclusters' | extend plugin=tostring(properties.networkProfile.networkPlugin), mode=tostring(properties.networkProfile.networkPluginMode) | where plugin =~ 'kubenet' or (plugin =~ 'azure' and isempty(mode)) | project name, resourceGroup, location, plugin, mode" -o table
Requires the resource-graph extension (you will be prompted to install it on first run). In the results, clusters with plugin=azure, mode empty are Node Subnet (legacy) clusters.
kubenet → Azure CNI Overlay (drill commands; do not run them on this hour's cluster)
# Prerequisites: cluster ≥ 1.27; use a user-assigned identity (the kubenet route table must be detached); no network policy engine enabled az aks update -g $RG -n <kubenet-cluster> \ --network-plugin azure --network-plugin-mode overlay \ --pod-cidr 192.168.0.0/16 # If you want Cilium afterward, it must be a second, separate operation: az aks update -g $RG -n <kubenet-cluster> --network-dataplane cilium
Common mistakes: if Calico or NPM is enabled, the migration is rejected. First uninstall it with --network-policy none, then add Cilium after the migration and re-verify policies. If you omit --pod-cidr during a kubenet migration, the original Pod CIDR is kept.
Lab 1: compare two clusters, calculate addresses, and rehearse migration checks (about 6 minutes, no extra cost)
az aks show loop from the “Commands” page, and record the plugin / mode / dataplane / podCidr for both clusters. If aks-lab has been deleted, look only at aks-lab-net.kubectl get nodes -o custom-columns=NAME:.metadata.name,IP:.status.addresses[0].address,PODCIDR:.spec.podCIDR
NAME IP PODCIDR aks-nodepool1-31214567-vmss000000 10.10.0.4 192.168.0.0/24 aks-nodepool1-31214567-vmss000001 10.10.0.5 192.168.1.0/24
Each node gets one /24, which is fixed and cannot be adjusted. So 192.168.0.0/16 supports at most 256 nodes (including upgrade surge nodes).
az network vnet subnet show -g $RG --vnet-name $VNET -n snet-nodes \
--query "{prefix:addressPrefix, ipConfigs:length(ipConfigurations)}" -o table
Prefix IpConfigs -------------- ----------- 10.10.0.0/22 2
2 IP configurations = 2 node NICs. In Node Subnet mode, this would be 2 × (110 + 1) = 222.
az aks create -g $RG -n aks-lab-bad --network-plugin azure --network-plugin-mode overlay \ --pod-cidr 172.16.0.0/12 --node-count 1 --generate-ssh-keys --no-wait 2>&1 | tail -3
(InvalidParameter) ... pod CIDR 172.16.0.0/12 overlaps with reserved address range 172.30.0.0/16 ...
If the command unexpectedly starts creating resources, run az aks delete -g $RG -n aks-lab-bad --yes --no-wait immediately.
aks-lab-bad does not appear in az aks list -g $RG -o table.Case 1: the enterprise IPAM approved only a /23
Problem: the platform team needs to build 6 AKS clusters in a hub-spoke design, and the network team gave each spoke only a /23 (512 addresses). In Node Subnet mode, one cluster with 30 nodes × 110 Pods needs 3330 addresses. Approach: use Azure CNI Overlay + Cilium for all clusters. A /24 node subnet is enough for 200+ nodes. All 6 clusters reuse the same Pod CIDR 192.168.0.0/16, which Microsoft allows for multiple independent clusters in the same VNet. Register this range in the enterprise IPAM as “cluster-internal only, do not route.” Limitation: on-premises systems cannot connect directly to Pods. All inbound traffic goes through an internal load balancer or the AGC private frontend.
Case 2: the on-premises firewall requires allowing source IPs by application
Problem: the on-premises Oracle database firewall allows source IPs from a whitelist. Under Overlay, all Pod egress becomes node IPs, so different applications on the same node cannot be told apart. Approach: two options. ① Create a dedicated node pool in a separate subnet for this application (Overlay supports node-pool-level --vnet-subnet-id), and have the firewall allow that subnet. ② Switch this cluster to Pod Subnet (Flat), so Pod IPs reach on-premises directly. The team chose ①, because it required the fewest changes. Limitation: the node pool subnet is still shared with other Pods in the same pool, so use taints and tolerations to keep it dedicated.
Case 3: kubenet retirement migration
Problem: a kubenet cluster built in 2019 uses a custom route table, Calico policies, and a system-assigned identity. Approach: ① switch to a user-assigned identity; ② during a maintenance window, uninstall Calico with --network-policy none (policies are temporarily ineffective, so assess the risk in advance); ③ run az aks update --network-plugin azure --network-plugin-mode overlay, which reimages all pools; ④ add --network-dataplane cilium. Cilium only begins enforcing policies after all nodes are reimaged; ⑤ run regression tests on your policies. Limitations: the migration is irreversible. A custom azure-ip-masq-agent configuration can break connectivity to additional ranges, so check for and delete the legacy azure-ip-masq-agent-config before migrating.
Common errors and fixes
(InvalidParameter) ... overlaps with reserved address range / The pod CIDR ... overlaps with the cluster subnet
Cause: the Pod or Service CIDR overlaps a reserved range (169.254/16, 192.0.2/24, 172.30/16, 172.31/16), the node subnet, or the VNet address space.
az network vnet show -g $RG -n $VNET --query addressSpace.addressPrefixes az network vnet peering list -g $RG --vnet-name $VNET --query "[].remoteAddressSpace.addressPrefixes" -o tsv
Fix: choose an RFC 1918 or RFC 6598 (100.64.0.0/10) range that does not overlap the VNet, peered networks, on-premises ranges, or reserved ranges.
LinkedAuthorizationFailed / does not have authorization to perform action 'Microsoft.Network/virtualNetworks/subnets/join/action'
Cause: with BYO VNet, the cluster identity lacks subnet permissions, or the creator does not have permission to make role assignments.
az role assignment list --assignee $ID_PRINCIPAL --all -o table
Fix: grant the cluster identity Network Contributor, or a custom role that includes subnets/join/action and subnets/read. Wait 1–2 minutes for role replication, then retry.
New nodes cannot join: an Overlay cluster reports that the Pod CIDR is exhausted when scaling to node 257
Cause: each node gets a fixed /24, and a /16 holds only 256 /24s (surge nodes count too).
Fix: only Overlay clusters with Linux nodes can expand the Pod CIDR to a contiguous superset that contains the original range (for example, 192.168.0.0/16 → 192.168.0.0/15). The range cannot be shrunk or replaced. Expansion is not supported for Windows or mixed clusters, IPv6, or multiple Pod CIDRs. When planning, reserve space for the maximum node count plus surge from the start.
kubenet migration fails: route table must be detached / system-assigned identity not supported
Cause: the kubenet route table must be detached, and this step requires the cluster to use a user-assigned identity.
az aks show -g $RG -n <cluster> --query identity.type -o tsv
Fix: first run az aks update --assign-identity <uami-id> to switch to a user-assigned identity, and grant it permissions on the subnet and route table. Then run the migration.
Cluster created as Node Subnet: networkPluginMode is empty, and Pod IPs are in the node subnet
Cause: only --network-plugin azure was specified, and --network-plugin-mode overlay was omitted. For backward compatibility, AKS selects Node Subnet.
Fix: if the cluster was just created and has no workloads, deleting and recreating it is the cleanest option. If it already has workloads, migrate with az aks update --network-plugin azure --network-plugin-mode overlay --pod-cidr … (irreversible). Set both parameters explicitly in IaC templates.
1. Use one command to output the cluster's IPAM mode, data plane, and Pod CIDR.
az aks show -g $RG -n $NETCLUSTER --query "networkProfile.[networkPluginMode,networkDataplane,podCidr]" -o tsv
2. List the Pod segment assigned to each node, and count how many /24s of the Pod CIDR are in use.
kubectl get nodes -o jsonpath='{range .items[*]}{.spec.podCIDR}{"\n"}{end}' | sort | tee /dev/stderr | wc -lA team's cluster must be called back to specific Pods by an on-premises batch system (long-lived gRPC connections, addressed by Pod), and VNet address space is tight. What would you choose?
“External direct access to Pods” is a hard requirement of the Flat model. Overlay cannot do it, and can only expose Pods through Services or internal load balancers. There are two directions. ① If the callback can connect to a Service instead (exposing an internal load balancer for each instance that needs addressing, or switching to a reverse long-lived connection initiated by the Pod), refactor the application first and keep Overlay. ② If you must address Pods directly, use Azure CNI Pod Subnet and place only this one cluster in a dedicated, larger Pod subnet. Keep the other clusters on Overlay to save addresses. Do not move every cluster to Flat for one requirement.
Verified teaching videos
Official documentation
- CNI networking in AKS (model and IPAM comparison, reserved ranges)
- Overview of Azure CNI Overlay
- Update Azure CNI IPAM mode and data plane
- kubenet retirement GitHub issue #4859
Video storyboard (about 90 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
Visual: a /23 subnet fills up quickly with Pod blocks, with a red alert “Subnet IP exhausted.”
Narration: In a flat network, every Pod needs a VNet address, and the enterprise network runs out quickly.
Visual: the nodes stay in the VNet, and the Pods move to a separate translucent plane, 192.168.0.0/16, with a /24 label under each node.
Narration: Azure CNI Overlay gives VNet addresses only to nodes. Pods use a separate private range, and each node gets a fixed slash 24.
Visual: a Pod sends a packet to the on-premises data center, and the source address in the header changes from 192.168.0.37 to 10.10.0.4.
Narration: When traffic leaves the cluster, its source address is translated to the node IP. The outside world cannot see the Pod. That saves addresses, and it also adds a layer of isolation.
Visual: the calendar turns to March 31, 2028. The kubenet icon greys out, and an arrow points to Overlay.
Narration: kubenet retires on March 31, 2028. The migration is irreversible and rebuilds every node, so schedule it early.
Module 2 · Azure CNI Overlay and Azure CNI powered by Cilium
- Explain Overlay address allocation (a fixed /24 per node, up to 250 Pods per node, up to 5000 nodes in Overlay) and the rule that SNATs Pod traffic to the node's primary IP when it leaves the cluster.
- Understand the Cilium data plane. eBPF handles Service load balancing (the cluster does not deploy kube-proxy), and network policy is enforced based on identity.
- Remember Cilium's limits on AKS: Linux only;
ipBlockcannot select Pod or node IPs; hostNetwork Pods are not subject to policy; the identity limit is 65535. - Distinguish “basic Cilium” from Advanced Container Networking Services (ACNS). FQDN filtering, L7 policy, flow logs, and WireGuard require ACNS.
What: Overlay addressing and routing
- Addressing: when the cluster is created, you provide a private Pod CIDR (default
10.244.0.0/16; this hour uses192.168.0.0/16). Each node is assigned a fixed/24whose size cannot be changed. Newly added nodes automatically take another /24 from the same CIDR. maxPods defaults to 250, with a maximum of 250 and a minimum of 10 (Windows is recommended up to 110). - Routing: Azure networking creates a separate routing domain for the Pod CIDR. Pod-to-Pod traffic across nodes is not encapsulated, and no UDR is needed on the subnet. Because nothing is encapsulated, subnet NSG rules apply to Pod traffic. If an NSG has deny rules, allow node CIDR↔node CIDR, node CIDR→Pod CIDR, and Pod CIDR↔Pod CIDR for all ports and protocols.
- Leaving the cluster: traffic whose destination is outside the Pod CIDR (peered VNets, on-premises, the internet, Azure PaaS) has its source IP translated by Azure CNI from the Pod's Overlay IP to the primary IP of the node VM, and then handed to Azure networking. Traffic going to the internet then goes through a second translation, based on the outbound type (load balancer / NAT Gateway / UDR). That is the topic of module 3.
- Entering the cluster: external endpoints cannot connect to Pods directly. They must go through a Service (LoadBalancer), an ingress controller, or AGC.
What: the Cilium data plane
Azure CNI powered by Cilium = the Azure CNI control plane (IPAM, where the Container Network Service on each node assigns and programs addresses) + the Cilium eBPF data plane. eBPF programs attach to the Pod's veth and to the tc hook on the node NIC:
- Service load balancing: DNAT for ClusterIP, NodePort, and LoadBalancer is performed in eBPF maps. Cilium clusters do not run kube-proxy. When you upgrade to Cilium, workloads on existing nodes also move to running without kube-proxy.
- Network policy: Cilium assigns a numeric identity to Pods that share the same labels. Policies are enforced by identity rather than by IP lists, so frequent Pod changes do not require rewriting large numbers of iptables rules. It supports Kubernetes
NetworkPolicy,CiliumNetworkPolicy(L3/L4), andCiliumClusterwideNetworkPolicy, with no need to install NPM or Calico. - Observability: the basic version does not include flow logs. Container network metrics, Hubble flow logs, FQDN filtering, L7 (HTTP/gRPC/Kafka) policy, WireGuard encryption, and eBPF Host Routing belong to ACNS.
Why
iptables rules grow with the number of Services and policies, so in a large cluster a single Service change rewrites the entire table. eBPF map lookups are O(1). The official benefits are improved service routing, more efficient policy enforcement, better traffic observability, and support for larger clusters. AKS Automatic uses “Overlay + Cilium” by default.
How: Cilium versions and limits on AKS (verified 2026-11)
| Kubernetes | Minimum Cilium version |
|---|---|
| 1.34 / 1.35 | 1.18.12 |
| 1.36 | 1.19.6 |
| 1.37 | The official table does not list it as of the verification date. Check the actual value with kubectl -n kube-system get ds cilium -o jsonpath='{..image}' |
- Linux only. Clusters with a Windows node pool cannot upgrade to the Cilium data plane.
ipBlockin aNetworkPolicycannot select Pod or node IPs. Even0.0.0.0/0blocks Pods and nodes, so you must also addnamespaceSelector: {}/podSelector: {}. ipBlock cannot be used to allow node IPs.- Pods with
hostNetwork: trueuse the host identity and are not subject to policy. - Labels that change frequently (such as Spark job labels) generate many identities, with a limit of 65535. You can exclude labels in
cilium-config, which is the only supported ConfigMap change. - AKS does not set CPU or memory limits on the Cilium DaemonSet (it is a critical system component).
- Clusters with NAP (node auto-provisioning) enabled must disable NAP before upgrading to Cilium.
When
- New clusters: Overlay + Cilium is the default recommendation, unless you have a Windows node pool. (Windows uses Overlay + the Azure data plane + Calico policies.)
- If you need an FQDN egress allowlist (for example, allowing only
*.blob.core.windows.net) or L7 policy, use Cilium + ACNS. - For existing Azure NPM clusters: Linux NPM stops being supported on 2028-09-30. Migrate to Cilium (module 6).
Comparison with similar technologies
| Azure data plane (iptables) | Azure CNI powered by Cilium | BYOCNI (--network-plugin none) | |
|---|---|---|---|
| Service implementation | kube-proxy | eBPF, no kube-proxy | Determined by the CNI you install |
| Network policy | Azure NPM / Calico | Built into Cilium | Your responsibility |
| Windows | Supported | Not supported | Depends on the CNI |
| Microsoft support scope | Full | Full (Cilium components are managed and upgraded by AKS) | CNI-related issues are outside the support scope |
kubectl -n kube-system get ds kube-proxy will show it.” It does not exist; check Service issues with cilium-dbg service list. ② “Basic Cilium includes the Hubble UI and FQDN policies.” These are part of ACNS. ③ “Under Overlay, the source IP of Pod egress is the load balancer's public IP.” There is an extra step. The traffic is first SNATed to the node IP, and then the load balancer or NAT Gateway translates it to the public IP when it leaves the VNet. ④ “You can edit cilium-config freely.” Only label exclusion is supported.Architecture diagram: Overlay + Cilium inside one node
Data flow: the source address seen by three destinations
Step-by-step animation: cross-node Pod communication and SNAT when leaving the VNet (Cilium)
Select a scenario, then click “Next”. Each step highlights the component processing the packet. Below it, you can see the header changes and the real command output you would observe on the node (sample values).
Core commands and parameters
| Command | Purpose | Notes |
|---|---|---|
az aks create … --network-plugin-mode overlay --network-dataplane cilium | Create a new Overlay + Cilium cluster | CLI ≥ 2.48.1; Cilium automatically becomes the policy engine |
az aks update --network-dataplane cilium | Switch an existing Azure CNI cluster to the Cilium data plane | IPAM is unchanged; all node pools are reimaged together; not supported for Windows node pools |
az aks nodepool add --vnet-subnet-id | Put a node pool in a separate subnet in an Overlay cluster | Used to distinguish outbound source IPs by subnet |
kubectl -n kube-system exec ds/cilium -- cilium-dbg status | Cilium agent health status | From Cilium 1.15, the command name inside the container is cilium-dbg |
cilium-dbg service list / bpf lb list | View the Service → backend mapping in eBPF | Replaces iptables -t nat -L from the kube-proxy era |
cilium-dbg endpoint list / identity list | Pod endpoints, identities, and policy enforcement status | Always check this when troubleshooting policies |
kubectl -n kube-system get ds cilium -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
kubectl -n kube-system get ds kube-proxy 2>&1 | tail -1
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status --brief
mcr.microsoft.com/containernetworking/cilium/cilium:v1.18.x Error from server (NotFound): daemonsets.apps "kube-proxy" not found OK
How to verify: no kube-proxy + Cilium OK = eBPF has taken over Services. Common mistake: copying iptables troubleshooting steps onto a Cilium cluster and seeing nothing. Production use: include the image version in cluster baseline checks, and compare it against the “Minimum Cilium version” table.
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg service list | grep -E "ID|6379" kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg endpoint list | head -5
ID Frontend Service Type Backend 17 10.0.143.20:6379 ClusterIP 1 => 192.168.1.25:6379 (active) ENDPOINT POLICY (ingress) POLICY (egress) IDENTITY LABELS (source:key[=value]) IPv4 STATUS 512 Disabled Disabled 18342 k8s:app=myapp k8s:io.kubernetes... 192.168.0.37 ready
Observe SNAT: the source address when a Pod leaves the VNet
kubectl run nettest -n myapp --image=mcr.microsoft.com/azurelinux/base/core:3.0 --restart=Never --command -- sleep 3600 kubectl -n myapp exec nettest -- sh -c "tdnf install -y curl bind-utils >/dev/null 2>&1; curl -s https://ifconfig.me; echo" az network public-ip list -g $(az aks show -g $RG -n $NETCLUSTER --query nodeResourceGroup -o tsv) --query "[].ipAddress" -o tsv
The two IPs match: the Pod's packet is first SNATed to the node IP, then SNATed to the outbound public IP by the load balancer outbound rule. You can use any debugging image that includes curl or dig (for example nicolaka/netshoot). Production clusters should pull only from trusted ACR instances.
Lab 2: see the /24, identities, and eBPF Service in detail (about 7 minutes)
kubectl -n myapp get pod -o custom-columns=POD:.metadata.name,IP:.status.podIP,NODE:.spec.nodeName kubectl get nodes -o custom-columns=NODE:.metadata.name,PODCIDR:.spec.podCIDR
Verify that each Pod IP falls within the podCIDR of the node it runs on.
kubectl -n myapp exec nettest -- sh -c "tdnf install -y nmap-ncat >/dev/null 2>&1; printf 'CLIENT LIST\r\nQUIT\r\n' | nc redis 6379" | head -3
kubectl -n myapp get pod nettest -o jsonpath='{.status.podIP}{"\n"}'
$1234 id=7 addr=192.168.0.52:39814 laddr=192.168.1.25:6379 fd=8 name= age=0 ... 192.168.0.52
The client address redis sees is the nettest Pod IP. There is no SNAT inside the Pod CIDR.
cilium-dbg service list from the “Commands” page and confirm that the ClusterIP points to the redis Pod IP. After you delete the redis Pod, check again. The backend changes to the new Pod IP.curl ifconfig.me from the “Commands” page, compare the result with the outbound public IP in the node resource group, and record it. After you migrate to NAT Gateway in module 3, it will change.kubectl -n kube-system get pod -l k8s-app=azure-cns -o wide kubectl -n kube-system get cm | grep -Ei "cns|ip-masq|cilium-config"
ConfigMap names may differ depending on the data plane and version, so follow the actual output. Do not modify these managed configurations (cilium-config supports only label exclusion).
kubectl -n myapp delete pod nettest --now (module 3 recreates it).Case 1: iptables rule bloat causes latency jitter during releases
Problem: in a multi-tenant cluster with 8000 Services (Azure data plane + kube-proxy iptables), each large release made kube-proxy syncs take several seconds, and new connections occasionally timed out during that time. Approach: migrate with --network-dataplane cilium, so Service lookups use eBPF maps. Configuration: validate in a staging cluster first, then run the change in a maintenance window (all-pool reimage). Pause changes that depend on network policy until the reimage completes, because Cilium only starts enforcing policies after all nodes are reimaged. Limitation: a cluster with a Windows node pool cannot be migrated, so you need to split the cluster first.
Case 2: ipBlock 0.0.0.0/0 actually blocked in-cluster calls
Problem: after migrating from NPM to Cilium, a rule that allowed all egress to 0.0.0.0/0 caused Pods to fail to reach other Pods and nodes. Cause: Cilium's ipBlock cannot select Pod or node IPs. Approach: add namespaceSelector: {} and podSelector: {} to the same to. When access to nodes is needed (such as kubelet metrics), use toEntities: [host] in a CiliumNetworkPolicy instead. Limitation: validate each policy with a test matrix before migrating.
Case 3: Spark jobs exhaust Cilium identities
Problem: in a big data cluster, each Spark job carries a unique spark-app-selector label. After a month, identities were approaching the 65535 limit. Approach: exclude the spark-app-name and spark-app-selector labels in cilium-config. This is the only officially supported change, and it persists across restarts and upgrades. Limitation: excluded labels can no longer be used for policy selection.
Common errors and fixes
Pods can reach Pods on the same node, but all cross-node traffic times out (Overlay + custom NSG)
Cause: Overlay does not encapsulate, so subnet NSGs apply to Pod traffic. A deny rule in the custom NSG blocks the Pod CIDR.
az network vnet subnet show -g $RG --vnet-name $VNET -n snet-nodes --query networkSecurityGroup.id -o tsv az network nsg rule list -g $RG --nsg-name <nsg> -o table
Fix: add allow rules for node CIDR↔node CIDR, node CIDR→Pod CIDR, and Pod CIDR↔Pod CIDR (all ports and protocols, including DNS).
Error from server (NotFound): daemonsets.apps "kube-proxy" not found (the very first step of the troubleshooting playbook fails)
Cause: not a fault. The Cilium data plane does not deploy kube-proxy.
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg service list kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg bpf lb list | head
Fix: update the troubleshooting playbook to check Service backends with Cilium commands.
az aks update --network-dataplane cilium fails: Windows agent pools are not supported / node auto-provisioning is enabled
Cause: The Cilium dataplane is Linux-only. Clusters with NAP enabled must disable NAP first.
Fix: Move Windows workloads to a separate cluster. For NAP clusters, disable NAP first, then re-enable it after the upgrade completes.
Services in peered VNets see the client IP as the node IP, so access control based on Pod IPs no longer works.
Cause: This is by design in Overlay: traffic that leaves the Pod CIDR is SNAT'd to the node's primary IP.
Fix: Control access by node pool subnet (dedicated node pools + separate subnets). If you must keep Pod IPs, switch to Pod Subnet mode. Or replace source IP with identity at the application layer (mTLS / Entra tokens).
Pods cannot reach on-premises 10.244.5.20, but other on-premises addresses work fine
Cause: The Pod CIDR overlaps with the on-premises network range (for example, the default 10.244.0.0/16), so packets bound for that address are treated as internal Overlay traffic.
Fix: You cannot replace the Pod CIDR (you can only expand it to a superset). The long-term fix is to rebuild the cluster with a non-overlapping Pod CIDR. As a short-term option, have the peer send traffic through an SNAT gateway that translates it to a non-overlapping address.
1. On the Cilium cluster, find the current backend Pod IP for ClusterIP 10.0.143.20:6379.
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg service list | grep 10.0.143.20
2. Upgrade an existing Overlay (Azure dataplane) cluster to the Cilium dataplane.
az aks update -g $RG -n <cluster> --network-dataplane cilium
The team requires that "myapp can only reach one Azure Storage account and Redis; deny all other outbound traffic." The cluster uses Overlay + Cilium (ACNS not enabled). What is your approach?
Kubernetes NetworkPolicy can only control traffic by IP or label. Storage public IPs change, so maintaining ipBlock rules is unreliable. Options: (1) Enable ACNS and use toFQDNs in a CiliumNetworkPolicy (for example mystorage.blob.core.windows.net), and allow DNS to kube-dns/LocalDNS; (2) Or use a Storage private endpoint so the target becomes a fixed private IP inside the VNet, then allow it with ipBlock (note that ipBlock cannot select Pod or node IPs, but a private endpoint IP is fine); (3) Add Azure Firewall at the cluster egress with FQDN rules as a second line of defense.
Verified teaching videos
Official documentation
- Configure Azure CNI Overlay
- Configure Azure CNI Powered by Cilium (version table, limits, FAQ)
- Advanced Container Networking Services overview
Video storyboard (about 90 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
Visual: Two nodes, each with a label beneath it showing 192.168.0.0/24 and 192.168.1.0/24. Between them is a straight line labeled "Azure routing domain" (no tunnel icon).
Narration: Overlay assigns each node a fixed /24. Pod traffic between nodes is routed directly by the Azure network stack, with no encapsulation.
Visual: The kube-proxy icon is crossed out. A bee (eBPF) icon appears on the veth, and the ClusterIP is replaced with the Pod IP.
Narration: Cilium uses eBPF at the network interface hook to perform service load balancing, so the cluster has no kube-proxy.
Visual: As the packet leaves the node, its source address changes from 192.168.0.37 to 10.10.0.4.
Narration: Traffic going outside the Pod network is masqueraded to the node IP. Traffic going to the internet also passes through one more outbound translation.
Visual: Three cards: "Linux only", "ipBlock cannot select Pods or nodes", "FQDN and L7 require ACNS".
Narration: Remember these three limits. They prevent most migration incidents.
Module 3 · Outbound: load balancers, NAT Gateway, and UDR
- List the 5
outboundTypevalues:loadBalancer,managedNATGateway,userAssignedNATGateway,userDefinedRouting, andnone(plusblockin preview). Explain the prerequisites and migration path for each. - Use the formula
64,000 ports per IP ÷ ports per node × outbound IPs = maximum nodesto calculate load balancer SNAT capacity. Understand the port halving that happens with default automatic allocation when you go from 50 to 51 nodes. - Know that each NAT Gateway public IP provides 64,512 ports, with up to 16 IPs. From API version
2026-06-01, managed NAT Gateway defaults to StandardV2 (zone-redundant). - Design route tables and firewall rules for UDR outbound, and know that changing the outbound type changes the egress IP and breaks existing connections.
What: The five outbound types
| outboundType | Who performs the second SNAT | VNet | Key points |
|---|---|---|---|
loadBalancer (default) | The aksOutboundRule outbound rule on the AKS-managed standard load balancer kubernetes | Managed or BYO | Defaults to 1 managed public IP (can be 1–100, or bring your own IPs/prefix); allocatedOutboundPorts=0 means automatic allocation; idle timeout 30 minutes |
managedNATGateway | NAT Gateway created and managed by AKS | Managed VNet only | From API 2026-06-01, defaults to StandardV2 (zone-redundant, supports IPv6). You can upgrade from Standard to StandardV2, but not downgrade. |
userAssignedNATGateway | A NAT Gateway you attach to the node subnet in advance | BYO VNet only | Both Standard and StandardV2 are supported. StandardV2 requires StandardV2 public IPs. |
userDefinedRouting | Your NVA / Azure Firewall | BYO VNet | The subnet route table must have 0.0.0.0/0 pointing to the gateway/NVA. AKS does not create outbound public IPs. |
none | None (you provide the path yourself) | BYO or managed | Only for network-isolated clusters; the default route is not validated |
block (preview) | None; the NSG blocks public outbound | Managed VNet only | Network-isolated clusters only; requires the aks-preview extension |
Prerequisites: vm-set-type is VirtualMachineScaleSets and load-balancer-sku is Standard (Basic SKU retired on 2025-09-30).
Why: SNAT ports are a limited resource
Each outbound connection needs a (public IP, source port) pair. The load balancer provides about 64,000 SNAT ports per frontend IP, preallocated per node. With the default allocatedOutboundPorts=0, ports are allocated automatically based on backend pool size, giving 1024 ports per node at 50 nodes or fewer. When the node count crosses a boundary such as 50→51 or 100→101, each node's port count is halved and redistributed, which can break existing connections. NAT Gateway instead allocates ports dynamically on demand (64,512 per IP, up to 16 IPs) and does not split them by node, so NAT Gateway is the preferred choice for workloads with many outbound connections.
How: Load balancer outbound capacity formula
64,000 ports per IP / <outbound ports per node> * <number of outbound IPs> = <maximum number of nodes> Example: 4000 ports per node, 7 IPs → 64000/4000*7 = 112 nodes Don't forget the upgrade surge: leave room for maxSurge extra nodes × ports per node.
- Ports per node must be a multiple of 8. Adding IPs does not add ports per node; it only raises the maximum number of nodes.
- Outbound rule idle timeout: AKS sets this to 30 minutes (standard Azure load balancers default to 4 minutes outside AKS), and TCP Reset on idle is enabled by default. Workloads with many short-lived connections can lower it to 4 minutes to reclaim ports faster. Note that this is different from the Service annotation
azure-load-balancer-tcp-idle-timeout(inbound, default/minimum 4 minutes, maximum 100). - Do not edit the outbound rules of the
kubernetesload balancer directly in the portal. Cluster reconciliation (stop/start/upgrade/scale) overwrites them. Always useaz aks update.
How: UDR outbound
Associate a route table with the node subnet: 0.0.0.0/0 → virtual appliance (firewall private IP). The firewall must allow the outbound traffic AKS requires (application rules can use the FQDN tag AzureKubernetesService; see the "Limit egress traffic" document for the full endpoint list). Inbound trap: If you create a public LoadBalancer Service on a UDR cluster, return traffic is sent by the default route into the firewall, causing asymmetric routing. The correct approach is to route inbound traffic through firewall DNAT or AGC/ingress, or to add explicit routes for the relevant public IPs (follow the official egress-udr document).
When: How to choose
| Scenario | Recommended |
|---|---|
| Development/testing, low outbound volume | loadBalancer (default), with --load-balancer-outbound-ports set explicitly |
| Production, heavy outbound connections, fixed egress IP required | NAT Gateway (managed VNet → managedNATGateway; BYO → userAssignedNATGateway), StandardV2 preferred |
| Enterprise hub-spoke, all outbound traffic must be audited/filtered | userDefinedRouting → Azure Firewall in the hub (note that firewall SNAT provides only 2,496 ports per public IP; you can attach a NAT Gateway to the firewall subnet) |
| Fully isolated, no public outbound | Network-isolated cluster + none (BYO) or block (managed, preview) |
Comparison with similar technologies
| Load balancer outbound rules | NAT Gateway | Azure Firewall (UDR) | |
|---|---|---|---|
| Port allocation | Preallocated per node | On demand, 64,512 per IP | 2,496 per public IP (extensible with NAT GW) |
| Maximum IPs | Managed IPs up to 100 | 16 | Depends on SKU |
| Filtering / logging | None | None (NAT only) | FQDN/network rules, threat intelligence, logs |
| Cost | Included in the LB | Hourly + data processed | Hourly + data processed (highest) |
defaultOutboundAccess=false). AKS's own traffic uses explicit outbound paths and is not affected, but unsupported practices such as "quickly putting a VM in the same subnet to reach the internet" will fail. BYO VNet is not affected. (2) From API 2026-06-01, managedNATGateway defaults to StandardV2 (available within zones). The managedNATGatewayV2 type from the preview period is replaced by natGatewayProfile.sku.Architecture diagram: three outbound paths side by side
Flowchart: outbound type migration matrix (BYO VNet)
Core animation: packet paths for a Pod's outbound and inbound traffic
Choose a direction and an outbound type, then step through the animation. Each step shows which component handled the packet, how the header (source/destination IP:port) changed, what connection tracking state that component stored, and a real command you can use to observe that step.
Core commands and parameters
| Command / flag | Purpose | Notes |
|---|---|---|
--outbound-type | Select outbound type | Supported for both create and update; update requires CLI ≥ 2.56 |
--load-balancer-managed-outbound-ip-count | Number of managed outbound public IPs | Maximum 100; choose one of this or bring-your-own IPs/prefix |
--load-balancer-outbound-ports | SNAT ports per node | Multiple of 8; default 0 (auto) |
--load-balancer-idle-timeout | Outbound idle timeout (minutes) | AKS default 30 |
--load-balancer-outbound-ips / -ip-prefixes | Bring-your-own outbound IPs or prefix | The cluster identity needs public IP permissions |
--nat-gateway-managed-outbound-ip-count | Number of IPv4 addresses for the managed NAT Gateway | 1–16 |
az network lb outbound-rule list --lb-name kubernetes | View actual outbound rule values | Run in the node resource group |
View current outbound rules
NODE_RG=$(az aks show -g $RG -n $NETCLUSTER --query nodeResourceGroup -o tsv) az network lb outbound-rule list -g $NODE_RG --lb-name kubernetes -o table
AllocatedOutboundPorts EnableTcpReset IdleTimeoutInMinutes Name Protocol ProvisioningState ------------------------ ---------------- ---------------------- --------------- ---------- ------------------- 0 True 30 aksOutboundRule All Succeeded
How to verify: 0 means automatic allocation. In production, switch to explicit values. Common mistake: editing this rule directly in the portal; it gets overwritten on the cluster's next reconciliation. Production use: include it in baseline checks.
Set ports and IPs explicitly (load balancer outbound)
# Up to 30 nodes + 3 surge: 64000/4000*2 = 32 nodes → use 3 IPs for headroom (48 nodes) az aks update -g $RG -n $NETCLUSTER \ --load-balancer-managed-outbound-ip-count 3 --load-balancer-outbound-ports 4000 \ --load-balancer-idle-timeout 4
BYO VNet: migrate to userAssignedNATGateway (StandardV2)
az network public-ip create -g $RG -n pip-natgw-aks-lab -l $LOC \ --sku StandardV2 --allocation-method Static --version IPv4 --zone 1 2 3 az network nat gateway create -g $RG -n natgw-aks-lab -l $LOC \ --sku StandardV2 --public-ip-addresses pip-natgw-aks-lab --idle-timeout 4 az network vnet subnet update -g $RG --vnet-name $VNET -n snet-nodes --nat-gateway natgw-aks-lab az aks update -g $RG -n $NETCLUSTER --outbound-type userAssignedNATGateway
A StandardV2 NAT Gateway must use StandardV2 public IPs. Some regions do not yet support StandardV2; if creation fails, use --sku Standard instead (with Standard public IPs). For the SKU parameter syntax, follow az network nat gateway create --help.
Managed VNet: use managedNATGateway directly
az aks create -g $RG -n aks-lab-nat -l $LOC --outbound-type managedNATGateway \ --nat-gateway-managed-outbound-ip-count 1 --generate-ssh-keys # For an existing managed VNet cluster: az aks update -g $RG -n $CLUSTER --outbound-type managedNATGateway --nat-gateway-managed-outbound-ip-count 2
UDR + Azure Firewall (reference only, not run in this lesson's lab: the firewall is expensive)
az network route-table create -g $RG -n rt-aks-egress az network route-table route create -g $RG --route-table-name rt-aks-egress -n default-to-fw \ --address-prefix 0.0.0.0/0 --next-hop-type VirtualAppliance --next-hop-ip-address 10.10.6.4 az network vnet subnet update -g $RG --vnet-name $VNET -n snet-nodes --route-table rt-aks-egress az aks update -g $RG -n $NETCLUSTER --outbound-type userDefinedRouting
Before switching, confirm the firewall allows the required AKS outbound traffic (the FQDN tag AzureKubernetesService and the endpoints listed in the "Limit egress traffic" document). Otherwise, nodes immediately lose connectivity to the control plane and MCR.
Lab 3: Migrate from the load balancer to NAT Gateway and verify the egress IP (about 10 minutes)
rg-aks-lab.kubectl run nettest -n myapp --image=mcr.microsoft.com/azurelinux/base/core:3.0 --restart=Never --command -- sleep 3600 kubectl -n myapp wait --for=condition=Ready pod/nettest kubectl -n myapp exec nettest -- sh -c "tdnf install -y curl bind-utils >/dev/null 2>&1; curl -s https://ifconfig.me; echo" | tee before.txt
20.48.1.10
kubectl -n myapp exec nettest -- sh -c 'for i in $(seq 1 300); do curl -s -o /dev/null https://ifconfig.me & done; wait' NODE_RG=$(az aks show -g $RG -n $NETCLUSTER --query nodeResourceGroup -o tsv) LB_ID=$(az network lb show -g $NODE_RG -n kubernetes --query id -o tsv) az monitor metrics list --resource $LB_ID --metric SnatConnectionCount --interval PT1M --aggregation Total -o table | tail -5
Use the metric names from the output of az monitor metrics list-definitions --resource $LB_ID. If the SNAT failed connections count (ConnectionState=Failed dimension) is not 0, the ports are insufficient.
az aks update -g $RG -n $NETCLUSTER --outbound-type userAssignedNATGateway az aks show -g $RG -n $NETCLUSTER --query networkProfile.outboundType -o tsv
userAssignedNATGateway
kubectl -n myapp exec nettest -- curl -s https://ifconfig.me; echo az network public-ip show -g $RG -n pip-natgw-aks-lab --query ipAddress -o tsv az network lb outbound-rule list -g $NODE_RG --lb-name kubernetes -o table
The first two IPs are the same. The outbound rules on the load balancer and the outbound public IPs have been removed by AKS (the load balancer remains for inbound type: LoadBalancer Services). If external systems allowlist the old egress IP, update them now.
az aks update -g $RG -n $NETCLUSTER --outbound-type loadBalancer, then detach the subnet association: az network vnet subnet update -g $RG --vnet-name $VNET -n snet-nodes --nat-gateway "". Later modules in this lesson keep the NAT Gateway by default.kubectl -n myapp delete pod nettest --now. At the end of the course, the NAT Gateway and public IP are deleted along with the resource group.Case 1: Outbound connections fail widely after scaling to 51 nodes
Problem: With the default allocatedOutboundPorts=0, the cluster scaled from 48 to 52 nodes, and ports per node dropped from 1024 to 512. A service that calls a third-party API heavily started seeing SNAT failures and timeouts. Approach: Short term: --load-balancer-outbound-ports 4000 --load-balancer-managed-outbound-ip-count 4 (64000/4000×4 = 64 nodes, including surge headroom). Long term: migrate to NAT Gateway. On the app side, enable HTTP connection pooling and keep-alive to reduce new connections. Limitation: Changing ports or IPs also reallocates ports, so do it during low-traffic periods.
Case 2: A partner allowlist requires a fixed egress IP
Problem: The payment gateway only allows registered IPs, and the team is worried the egress IP will change when the cluster is rebuilt. Approach: BYO VNet + a pre-created StandardV2 public IP prefix attached to a user-assigned NAT Gateway. When the cluster is rebuilt, you only need to place the new cluster in the same subnet. Configuration: userAssignedNATGateway. Limitation: A NAT Gateway is subnet-scoped, so all resources in the subnet share the same egress. If only one application needs a fixed IP, use a dedicated node pool subnet with its own NAT Gateway.
Case 3: Unified outbound auditing for hub-spoke
Problem: The security team requires all outbound traffic to go through Azure Firewall in the hub. Approach: Node subnet route table in the spoke: 0.0.0.0/0 → firewall private IP, with --outbound-type userDefinedRouting. Firewall application rules use the AzureKubernetesService FQDN tag to allow required endpoints, and business FQDNs are allowed as needed. Attach a NAT Gateway to the firewall subnet to extend SNAT ports. Inbound traffic goes through AGC private/public frontends; do not create a public LoadBalancer Service on the UDR cluster. Limitation: The firewall becomes a single point of failure and a cost center. You need to monitor firewall SNAT and throughput.
Common errors and fixes
Intermittent connect timeout / SNAT port exhaustion (SNAT connection failures in load balancer metrics)
Cause: Preallocated ports per node have run out. This is common with many short-lived connections to a small number of destinations and no connection reuse.
az network lb outbound-rule list -g $NODE_RG --lb-name kubernetes -o table az monitor metrics list --resource $LB_ID --metric SnatConnectionCount --filter "ConnectionState eq 'Failed'" --interval PT5M -o table
Fix: Reuse connections in the application; explicitly increase ports per node and outbound IPs; migrate to NAT Gateway. For detailed troubleshooting, see hour 7.
(OutboundTypeUserAssignedNATGatewayRequiresBYOVnet) / managedNATGateway is not compatible with custom virtual networks
Cause: managedNATGateway can only be used with a managed VNet; userAssignedNATGateway can only be used with a BYO VNet (check the actual error message text).
Fix: For a BYO VNet, first create a NAT Gateway and attach it to the node subnet, then use userAssignedNATGateway.
After switching to userDefinedRouting, nodes are NotReady and image pulls fail
Cause: The firewall does not allow required AKS outbound traffic (control plane, MCR, Entra, package repositories, etc.).
kubectl get nodes kubectl describe node <node> | grep -A5 Conditions az network firewall show -g <hub-rg> -n <fw> --query "ipConfigurations[0].privateIPAddress"
Fix: In firewall application rules, use the AzureKubernetesService FQDN tag, and add the network rules from the "Limit egress traffic" document. Confirm the next-hop IP in the route table is correct.
External access to a public LoadBalancer Service on a UDR cluster fails
Cause: Inbound traffic enters the node through the load balancer, but return traffic is sent to the firewall by the 0.0.0.0/0 route. The asymmetric routing causes it to be dropped.
Fix: Route inbound traffic through firewall DNAT, AGC, or an internal load balancer + front-end gateway instead, or add routes for the relevant addresses following the official egress-udr guide.
After migrating the outbound type, external systems refuse connections (403 / connection reset)
Cause: The egress IP has changed, but the external allowlist or the API Server authorized IP ranges still contain the old IP.
Fix: Before migrating, add the new IP (NAT Gateway public IP/prefix) to the allowlist and to --api-server-authorized-ip-ranges. Do not reuse IPs that were used in the previous outbound configuration.
1. Set SNAT ports per node to 8000 and managed outbound IPs to 4, and calculate the maximum number of nodes supported.
az aks update -g $RG -n $NETCLUSTER --load-balancer-outbound-ports 8000 --load-balancer-managed-outbound-ip-count 4 # 64000 / 8000 * 4 = 32 nodes (including surge)
2. Find the cluster's current outbound type and the actual egress IP of a Pod.
az aks show -g $RG -n $NETCLUSTER --query networkProfile.outboundType -o tsv kubectl -n myapp exec nettest -- curl -s https://ifconfig.me
A BYO VNet cluster (loadBalancer outbound, 80 nodes, default ports) has third-party API timeouts during peak hours every day. The security team also requires connecting to the hub firewall next year. Provide a phased plan.
Phase 1 (this week): Confirm the cause is SNAT failures (LB metrics). With 80 nodes on default settings, each node only gets 512 ports, so set ports and IPs explicitly right away (for example, 2000 ports × 3 IPs = 96-node limit, leaving room for surge). Push the application to reuse connections. Phase 2: Migrate to userAssignedNATGateway (StandardV2). Outbound ports are then allocated on demand. Notify the third party of the new egress IP in advance. Phase 3 (connect to the hub): Point the route table 0.0.0.0/0 to the firewall and use userDefinedRouting. Attach a NAT Gateway to the firewall subnet to address the firewall limit of 2,496 ports per IP. Move inbound traffic to AGC to avoid asymmetric routing. Each switch changes the egress IP, so it needs a maintenance window and coordinated allowlist updates.
Verified teaching videos
Official documentation
- Customize cluster egress with outbound types
- Configure a public standard load balancer (port formula, idle timeout)
- Managed or user-assigned NAT gateway
- Cluster egress with user-defined routing
- Limit egress traffic (required endpoints)
Video storyboard script (about 100 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
Visual: An envelope (the packet) leaves a Pod. Its postmark "192.168.0.37" is stamped over with "10.10.0.4".
Narration: The first translation happens on the node: the Pod address becomes the node address.
Visual: Three forks: load balancer, NAT gateway, and firewall. At each fork, another public IP postmark is stamped.
Narration: The second translation is determined by the outbound type. The load balancer preallocates ports per node, the NAT gateway allocates them on demand, and the firewall checks rules before translating.
Visual: The node count jumps from 50 to 51. Each node's port bar shrinks from 1024 to 512, and several connections turn red.
Narration: Default automatic allocation halves the ports when you cross that boundary. In production, set ports explicitly, or use a NAT gateway.
Visual: When the outbound type is switched, the old IP on the external allowlist is crossed out and the new IP is added.
Narration: Changing the outbound type always changes the egress IP. Update the allowlist first, then make the change.
Module 4 · Private clusters and API Server VNet integration
- Compare three ways to access the control plane: a public endpoint (with optional authorized IP ranges), a private cluster (Private Link + private endpoint), and API Server VNet integration (internal load balancer in a delegated subnet).
- Know the three values for
--private-dns-zone(system/none/ custom zone resource ID), the zone naming format, and the required roles. - Know that VNet integration conversion is one-way, requires a manual stop/start, and configures NSG ports (443, 4443, 10250, 9988).
- Know how to use
az aks command invoke, a jump box, Bastion, or VPN/ExpressRoute to access a private API Server.
What: Three ways to expose the API Server
| Public endpoint (default) | Private cluster (Private Link) | API server VNet integration | |
|---|---|---|---|
| API Server address | Public IP, FQDN *.hcp.<region>.azmk8s.io | A private endpoint IP in your subnet | Internal load balancer VIP in the delegated subnet |
| Node → API Server | Through the cluster's outbound type (public path); the konnectivity tunnel is used for API Server → kubelet | Through a private endpoint (Private Link) | Connects directly to the ILB private IP, no DNS lookup and no tunnel |
| Can you switch public/private? | Can add --api-server-authorized-ip-ranges | Decided at creation (public FQDN can be disabled) | Public/private mode can be toggled after creation, no rebuild needed |
| Extra subnet | None | None (the endpoint is placed in the first node pool's subnet) | A subnet delegated to Microsoft.ContainerService/managedClusters, minimum /28 |
| AKS Automatic | — | — | Preconfigured |
Why
The control plane is the most sensitive entry point of a cluster. A public endpoint, even with Entra authentication, is exposed to the internet. In a non-private cluster, node-to-API Server traffic also goes through the cluster's outbound type (the official note says to avoid treating API Server traffic as public traffic by using a private cluster or VNet integration). A private cluster uses Private Link to project the API Server as a private IP inside your VNet. VNet integration goes further: it places the API Server's ILB in your delegated subnet, so nodes connect directly by IP with no tunnel component, and you can toggle private mode after creation.
How: How DNS works for private clusters
- When you create a private cluster, AKS creates a private endpoint and a private DNS zone in the node resource group. An A record resolves the API Server's private FQDN to the endpoint IP. By default, the zone is linked only to the cluster's VNet.
- By default, a publicly resolvable FQDN is also created (it resolves to a private IP, not a public endpoint).
--disable-public-fqdnremoves it. --private-dns-zone:system(default, AKS creates the zone),none(no private zone; public DNS resolves to the private IP), or a custom zone resource ID. Custom zone formats:privatelink.<region>.azmk8s.ioor<subzone>.privatelink.<region>.azmk8s.io; VNet integration clusters useprivate.<region>.azmk8s.ioor<subzone>.private.<region>.azmk8s.io. A custom zone requires a user-assigned identity with Private DNS Zone Contributor on the region's zone and Network Contributor on the VNet. These resources cannot be changed or deleted after creation.- You cannot use
--private-dns-zone nonetogether with--disable-public-fqdn. That would leave no DNS that can resolve the API Server. - You can only update from
byo/systemtonone, not the reverse (this triggers a node image upgrade to switch to the public FQDN).
How: hub-spoke with custom DNS
Enterprise VNets often point DNS to a DNS forwarder in the hub. In that case: (1) the custom DNS server must be able to resolve the cluster's private zone: a conditional forwarder to 168.63.129.16 (from a VNet linked to the private zone) or Azure DNS Private Resolver; (2) nodes must reach the custom DNS on UDP and TCP 53 (since 1.37, LocalDNS defaults to PreferUDP and falls back to TCP on truncation; see Module 7); (3) by default, AKS tries to link the zone to the spoke VNet, which fails if the cluster identity lacks Network Contributor on the spoke VNet. Either provide a custom zone + authorization + --disable-public-fqdn, or use none and keep the public FQDN. Conditional forwarders do not support subdomains.
When
- New clusters should use a private control plane. Prefer API Server VNet integration + private mode (reversible public/private switching, no tunnel), unless the region is unavailable (qatarcentral) or you use a v4+ node SKU that supports VNet encryption (incompatible with VNet integration).
- Existing private clusters (Private Link) that run stably do not need to be converted for its own sake. The conversion is one-way and requires a cluster restart.
- CI/CD: Private clusters do not support the Azure DevOps Microsoft-hosted agent. Use a self-hosted agent inside the VNet, or
az aks command invoke(see the Azure DevOps course).
Comparison with similar technologies
| AKS VNet integration | EKS private endpoint | GKE private endpoint | |
|---|---|---|---|
| Mechanism | ILB in delegated subnet | Control plane ENI placed in your subnet | Peering/PSC private IP |
| Public/private switch | Switchable after creation | Public and private can be enabled together | Configurable |
Architecture diagram: private cluster vs VNet integration
Flowchart: how the private FQDN resolves in hub-spoke
Step-by-step animation: how kubectl and nodes each reach the API Server
Select a control plane mode and play through the full path for kubectl get pods: DNS resolution → TCP connection → TLS/Entra authentication → API Server → kubelet (for exec/logs).
Core commands and parameters
| Command / flag | Purpose | Notes |
|---|---|---|
--enable-private-cluster | Private cluster | CLI ≥ 2.28; API version ≥ 2021-05-01 |
--private-dns-zone system|none|<id> | Private DNS zone policy | Custom zone requires a user-assigned identity + two roles |
--disable-public-fqdn | Remove the publicly resolvable FQDN | Cannot be used with none |
--fqdn-subdomain | Subdomains in a custom zone | Only with a custom zone of the form privatelink.<region>.azmk8s.io |
--enable-apiserver-vnet-integration --apiserver-subnet-id | VNet integration | CLI ≥ 2.73; BYO requires a delegated subnet |
az aks update --enable-private-cluster / --disable-private-cluster | Switch public/private on a VNet integration cluster | --disable-private-cluster preview |
az aks command invoke | Run a command in the cluster through the Azure API | No network connectivity needed; good for emergencies |
--api-server-authorized-ip-ranges | Source IP allowlist for the public endpoint | Applies only to the public endpoint |
View current control plane access configuration
az aks show -g $RG -n $NETCLUSTER --query "{fqdn:fqdn, privateFqdn:privateFqdn, apiServerAccess:apiServerAccessProfile}" -o json
{
"apiServerAccess": {
"enablePrivateCluster": true,
"enableVnetIntegration": true,
"privateDnsZone": "system",
"subnetId": "/subscriptions/…/virtualNetworks/vnet-aks-lab/subnets/snet-apiserver",
"authorizedIpRanges": null
},
"fqdn": "aks-lab-ne-rg-aks-lab-1a2b3c-xxxx.hcp.canadacentral.azmk8s.io",
"privateFqdn": "aks-lab-ne-rg-aks-lab-1a2b3c-xxxx.private.canadacentral.azmk8s.io"
}
Create a new private cluster with a custom private DNS zone (reference)
ZONE_ID=$(az network private-dns zone create -g $RG -n privatelink.canadacentral.azmk8s.io --query id -o tsv) az role assignment create --assignee-object-id $ID_PRINCIPAL --assignee-principal-type ServicePrincipal \ --role "Private DNS Zone Contributor" --scope $ZONE_ID az aks create -g $RG -n aks-lab-private -l $LOC --load-balancer-sku standard \ --enable-private-cluster --private-dns-zone $ZONE_ID --disable-public-fqdn \ --network-plugin azure --network-plugin-mode overlay --pod-cidr 192.168.0.0/16 \ --vnet-subnet-id $SUBNET_ID --assign-identity $ID_RES --generate-ssh-keys
Without network connectivity: command invoke
az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl get pods -n myapp -o wide" # With attached file: az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl apply -f myapp.yaml -n myapp" --file myapp.yaml
command started at 2026-11-15 10:21:05+00:00, finished at 2026-11-15 10:21:09+00:00 with exitcode=0 NAME READY STATUS RESTARTS AGE IP NODE myapp-7c9d6b8f5c-2kq8x 1/1 Running 0 2h 192.168.0.37 aks-nodepool1-…000000
How to verify: exitcode=0. Common errors: The caller lacks the Microsoft.ContainerService/managedClusters/runcommand/action permission; command invoke temporarily runs a Pod in the cluster, and nodes must be able to pull its image. Production use: an emergency channel; it should not replace a self-hosted CI agent.
Lab 4: Convert aks-lab-net to API Server VNet integration, then enable private mode (about 15 minutes, includes a restart)
az aks stop + az aks start (the cluster is unavailable during this time, about 10 minutes). All node pools go through a node image upgrade, and workloads restart in a rolling fashion. The API Server IP will change. Run this only on the lab cluster for this course. Required role: Cluster Contributor, plus the permissions on snet-apiserver already granted to the cluster identity in Module 0.az network vnet subnet show -g $RG --vnet-name $VNET -n snet-apiserver --query "{prefix:addressPrefix, delegation:delegations[0].serviceName}" -o table
Prefix Delegation ------------- ------------------------------------------- 10.10.4.0/28 Microsoft.ContainerService/managedClusters
az aks update -g $RG -n $NETCLUSTER --enable-apiserver-vnet-integration --apiserver-subnet-id $APISERVER_SUBNET_ID az aks stop -g $RG -n $NETCLUSTER az aks start -g $RG -n $NETCLUSTER
Official warning: delaying the restart increases the risk of capacity unavailability (capacity is only validated, not reserved).
az network vnet subnet show -g $RG --vnet-name $VNET -n snet-apiserver --query "ipConfigurations[].id" -o tsv | head kubectl get endpoints kubernetes -n default
NAME ENDPOINTS AGE kubernetes 10.10.4.4:443 3d
The endpoints of the kubernetes Service become the ILB private IP in the delegated subnet.
az aks update -g $RG -n $NETCLUSTER --enable-private-cluster \ --enable-apiserver-vnet-integration --apiserver-subnet-id $APISERVER_SUBNET_ID kubectl get nodes # Run from outside the VNet: expected to fail
Unable to connect to the server: dial tcp 10.10.4.4:443: i/o timeout
The public FQDN is kept by default, so the name resolves, but it resolves to a private IP, and you cannot connect from outside the VNet. If the public FQDN is also disabled, you will see no such host.
az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl get nodes -o wide"
In later modules, you can wrap kubectl commands with command invoke, or set up a small jump box in vnet-aks-lab / use Azure Bastion. For convenience in later labs, you can also turn private mode off now (preview command): az aks update -g $RG -n $NETCLUSTER --disable-private-cluster.
az aks delete -g $RG -n $NETCLUSTER --yes --no-wait (the delegated subnet can be reused for the next cluster).Case 1: Private cluster + Azure DevOps release failure
Problem: After the cluster became private, a release pipeline using a Microsoft-hosted agent failed with no such host. Approach: Deploy a VMSS self-hosted agent in the spoke VNet (or Managed DevOps Pools injected into the VNet), and link the private DNS zone to the VNet where the agent runs. For urgent changes, use az aks command invoke. Limitation: Private clusters do not support Microsoft-hosted agents. This is an official limitation.
Case 2: Second cluster creation fails in hub-spoke
Problem: The spoke VNet uses the hub's custom DNS. When the second private cluster was created, it failed because the cluster identity could not link the private zone to the spoke VNet. Approach: Use the "custom private DNS zone" pattern: the central team pre-creates privatelink.canadacentral.azmk8s.io and links it to the hub. Grant each cluster's user-assigned identity Private DNS Zone Contributor on that zone and Network Contributor on the spoke VNet. At creation, use --private-dns-zone <id> --disable-public-fqdn. Limitation: The zone cannot be replaced or deleted after creation.
Case 3: Migrating from a Private Link private cluster to VNet integration
Problem: The team wants to remove the occasional kubectl logs timeouts caused by the konnectivity tunnel, and to toggle public access on demand. Approach: Create a new /28 delegated subnet. In a maintenance window, run az aks update --enable-apiserver-vnet-integration, then stop/start immediately. Update any hard-coded API Server IPs in the firewall, and verify the NSG rules for 443/4443/10250/9988. Limitation: The conversion is one-way. On v4+ node SKUs that support VNet encryption, the conversion is blocked.
Common errors and fixes
Unable to connect to the server: dial tcp: lookup <name>.privatelink.canadacentral.azmk8s.io: no such host
Cause: The client's network cannot resolve the private zone (the zone is not linked to the VNet where the client or DNS forwarder lives, or the enterprise DNS has no conditional forwarder).
az network private-dns link vnet list -g $NODE_RG -z $(az aks show -g $RG -n $NETCLUSTER --query privateFqdn -o tsv | cut -d. -f2-) -o table nslookup <privateFqdn>
Fix: Link the zone to the hub/client VNet, or configure a conditional forwarder to 168.63.129.16 / DNS Private Resolver. Confirm that both UDP and TCP 53 are allowed.
dial tcp 10.10.0.10:443: i/o timeout (the name resolves but the connection fails)
Cause: There is no network path between the client and the private endpoint (missing peering, VPN routes, or an NSG block).
Fix: Check whether peering has forwarding enabled, whether on-premises routes include the cluster VNet, and whether the NSG allows 443. As a temporary workaround, use az aks command invoke.
VNet integration creation fails: subnet is not delegated / The cluster identity does not have permission on the API server subnet
Cause: The API Server subnet is not delegated to Microsoft.ContainerService/managedClusters, or the cluster identity does not have permission on that subnet.
az network vnet subnet update -g $RG --vnet-name $VNET -n snet-apiserver --delegations Microsoft.ContainerService/managedClusters az role assignment create --assignee-object-id $ID_PRINCIPAL --assignee-principal-type ServicePrincipal --role "Network Contributor" --scope $APISERVER_SUBNET_ID
kubectl logs / exec reports error dialing backend or times out (VNet integration + custom NSG)
Cause: The NSG blocks TCP 10250 from the API Server subnet to the node subnet.
Fix: Add the rule. Also verify node → API Server subnet 443/4443 and AzureLoadBalancer → 9988.
(BadRequest) privateDNSZone none is not supported when publicDNS is false
Cause: --private-dns-zone none and --disable-public-fqdn were both set, so no DNS can resolve the API Server (check the actual error message text).
Fix: Choose one: system/custom zone + disable the public FQDN, or none + keep the public FQDN.
1. Without network connectivity, list the Services in the myapp namespace of the private cluster.
az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl get svc -n myapp"
2. For an existing public cluster (without VNet integration), allow only the office network 203.0.113.0/24 to access the API Server.
az aks update -g $RG -n $CLUSTER --api-server-authorized-ip-ranges 203.0.113.0/24
Security requires that "the API Server must not be exposed to the public internet." However, the development team works from home without a VPN and only has Entra ID accounts, and operations still needs occasional troubleshooting. Propose a solution and explain the trade-offs.
Preferred: API Server VNet integration + private mode. Developer access path: Azure Bastion + a jump box inside the VNet (Entra sign-in, Conditional Access), or a Cloud Shell injected into the VNet. CI/CD uses a self-hosted agent inside the VNet. For emergencies: az aks command invoke (relies on Azure RBAC; audit in the Activity Log). Trade-offs: everyone has one extra hop, and command invoke is not suitable for long interactive sessions. If the business allows, you can use "public endpoint + authorized IP ranges + Entra + disabled local accounts" as a transition, but it does not literally satisfy "must not be exposed to the public internet."
Verified teaching videos
Official documentation
- Create a private AKS cluster (DNS options, hub-spoke)
- API Server VNet Integration (conversion, NSG ports)
- Access a private cluster with command invoke
- API server authorized IP ranges
Video storyboard script (about 80 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
Visual: The API Server sits in a cloud labeled "AKS-managed subscription," and kubectl connects directly from the internet.
Narration: By default, the API Server has a public endpoint. Anyone can try to connect; they just need to authenticate.
Visual: A Private Link pipe projects the API Server as a private IP in your subnet, and a private DNS zone appears beside it.
Narration: A private cluster brings the API Server into your network through a private endpoint, and name resolution relies on a private DNS zone.
Visual: The API Server's load balancer drops directly into a subnet labeled "delegated /28." Nodes connect by IP directly, and the tunnel icon disappears.
Narration: VNet integration is more direct: the API Server's internal load balancer sits in your delegated subnet, and you can switch between public and private at any time.
Visual: A red warning reads "One-way conversion, restart immediately."
Narration: Converting an existing cluster is one-way. Once it's done, stop and start the cluster right away.
Module 5 · Ingress: App Routing add-on and Application Gateway for Containers
- Explain the specific impact of Ingress-NGINX retirement on AKS: upstream stopped maintenance in March 2026; Microsoft provides critical security patches for the App Routing add-on's NGINX through November 2026, after which you must migrate.
- Enable the Gateway API implementation of App Routing (GatewayClass
approuting-istio), expose myapp with Gateway + HTTPRoute, and understand how it differs from the Istio service mesh add-on. - Understand the components of Application Gateway for Containers (ALB Controller, frontend, association, security policy), its two deployment strategies, and the /24 delegated subnet requirement.
- Choose an ingress option based on WAF, multi-tenant isolation, L7 capabilities, and cost, and plan a migration from Ingress to Gateway API.
What: Ingress options on AKS (2026-11)
| Option | API | Data plane location | Status and key points |
|---|---|---|---|
| App Routing add-on · NGINX | Ingress (class webapprouting.kubernetes.azure.com) | NGINX Pods inside the cluster (app-routing-system namespace) | Based on the retired ingress-nginx; Microsoft supports its critical security patches through November 2026; integrates Azure DNS (up to 5 zones) and Key Vault certificates |
| App Routing add-on · Gateway API | Gateway API (GatewayClass approuting-istio) | Envoy inside the cluster (managed by the Istio control plane in aks-istio-system) | The official successor to NGINX; does not support sidecars or Istio CRDs; in-place upgrades (no revisions); each Gateway automatically gets an HPA (2–5) and a PDB; enabled by default on new AKS Automatic 1.36+ clusters |
| Gateway API ingress for the Istio service mesh add-on | Gateway API (GatewayClass istio) | Envoy inside the cluster | Choose this when you need advanced features such as EnvoyFilter (rate limiting, body size limits, Lua). You must perform revision canary upgrades yourself. It cannot be enabled together with the App Routing Gateway API. |
| Application Gateway for Containers (AGC) | Gateway API (GatewayClass azure-alb-external) and Ingress | Outside the cluster, an Azure-managed L7 data plane | WAF, mTLS, JWT validation, traffic splitting, private frontend; the ALB Controller implements Gateway API v1.6; the AKS add-on is in preview, and Helm deployment is the production-ready path |
| Application Gateway Ingress Controller (AGIC) | Ingress | Outside the cluster: App Gateway v2 | The previous generation; choose AGC for new projects |
Why: why you must act now
The Kubernetes SIG Network and the Security Response Committee announced in 2025-11 that ingress-nginx is being retired. Maintenance ends in March 2026, and the repository is archived; no security patches will follow. AKS's App Routing NGINX is built on it, and Microsoft only commits to critical security patches through November 2026. Note: the retirement applies to the ingress-nginx controller, not the Ingress API. The networking.k8s.io/v1 Ingress is still usable, and AGC continues to support Ingress. However, AKS has explicitly designated Gateway API as the long-term standard for ingress and L7 traffic management.
How: Two data path types
- Inside the cluster (App Routing Gateway API / NGINX): Client → Azure load balancer (L4,
type: LoadBalancerService; public, or internal with an annotation) → node → Envoy/NGINX Pod (TLS termination, L7 routing) → backend Pod. Gateway Pods consume cluster resources and are upgraded along with the cluster. - Outside the cluster (AGC): Client → AGC frontend (
*.fzXX.alb.azure.com, listens on 80/443 only) → Azure-managed proxy (in the association subnet) → sent directly to the backend Pod IP. AGC insertsx-forwarded-for,x-forwarded-proto, andx-request-id. Default request timeout is 60 seconds, HTTP idle timeout 5 minutes, and upstream connection timeout 5 seconds. Inside the cluster, the ALB Controller only translates Gateway/HTTPRoute into AGC configuration (through ARM and the AGC configuration API, using Workload Identity).
AGC components
- AGC resource (parent resource, deploys the control plane) → frontend (entry point that generates an FQDN; public or private; a private frontend can connect to up to 200 private endpoints) → association (1:1 mapping to one subnet delegated to
Microsoft.ServiceNetworking/trafficControllers, at least /24; currently limited to 1 association per AGC) → security policy (currently only thewaftype). - Deployment strategies: BYO (you manage the AGC, frontend, and association with the CLI or Terraform, and the Gateway references the frontend) or managed by the ALB Controller (you create an
ApplicationLoadBalancercustom resource, and the Controller manages its lifecycle). - AKS add-on (preview): automatically creates the identity
applicationloadbalancer-<cluster name>(roles: Network Contributor on the MC resource group, AppGw for Containers Configuration Manager, Reader) and the delegated subnetaks-appgatewayin the managed VNet. Requires Azure CNI or Overlay, Workload Identity enabled, and managed Gateway API CRDs (--enable-gateway-api).
When: How to choose
| Requirement | Recommended |
|---|---|
| General HTTP/HTTPS ingress, managed and low cost | App Routing Gateway API (approuting-istio) |
| Needs WAF, mTLS to front and back ends, JWT validation, private endpoint access, and ingress that doesn't consume cluster resources | AGC |
| Needs rate limiting, body size limits, Lua scripting, or equivalents of NGINX annotations | Istio add-on Gateway API + gateway-level EnvoyFilter (EnvoyFilter issues are outside Azure support scope) |
| Multi-tenant, mutually untrusted tenants | Do not rely on a shared NGINX controller for isolation (official note: it is not a security boundary, and it can read Secrets in all namespaces). Use allowedRoutes and ReferenceGrant in Gateway API, or use a cluster per tenant. |
Comparison with similar technologies
| App Routing NGINX | App Routing Gateway API | AGC | |
|---|---|---|---|
| API | Ingress + annotations | Gateway / HTTPRoute | Gateway / HTTPRoute / GRPCRoute + Ingress |
| DNS / TLS automation | Azure DNS + Key Vault (mature) | Requires configuring the DNS/TLS workflow for the App Routing operator (see the official DNS & TLS docs) | Certificates stored in a Secret, or Key Vault integration (follow the docs) |
| WAF | None | None | Yes (security policy) |
| Support period | Critical patch deadline 2026-11 | Long-term | Long-term |
app-routing-system are kept, so you must delete the namespace manually. (4) "The AGC add-on is GA": as of the verification date it is still in preview. For production, deploy the ALB Controller with Helm.Architecture diagram: in-cluster gateway vs out-of-cluster AGC
Flowchart: migrating from Ingress-NGINX
Step-by-step animation: how an HTTPS request reaches myapp
Choose an ingress option, then step through where TLS terminates, how the client IP is preserved, and how many hops the request takes.
Core commands and parameters
| Command | Purpose | Notes |
|---|---|---|
az aks update --enable-gateway-api --enable-app-routing-istio | Enable managed Gateway API CRDs + App Routing Gateway API | CLI ≥ 2.86.0; self-managed Gateway API CRDs are not supported; mutually exclusive with the Istio mesh add-on |
az aks update --disable-app-routing-istio | Disable App Routing Gateway API | Delete Gateways/HTTPRoutes first |
az aks approuting enable|disable / --enable-app-routing | App Routing NGINX (Ingress) | Only for existing workloads; do not choose it for new projects |
az aks update --enable-gateway-api --enable-application-load-balancer | AGC ALB Controller add-on | Preview; requires registering ManagedGatewayAPIPreview, ApplicationLoadBalancerPreview, and the alb and aks-preview extensions; requires Workload Identity |
kubectl get gatewayclass | View available gateway implementations | approuting-istio / azure-alb-external / istio |
kubectl wait --for=condition=programmed gateway/<name> | Wait for the gateway to be ready | Then read .status.addresses[0].value |
Inventory existing Ingress (migration step 1)
kubectl get ingress -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,CLASS:.spec.ingressClassName,HOSTS:.spec.rules[*].host
kubectl get ingress -A -o json | jq -r '.items[] | .metadata.annotations // {} | keys[]' | sort | uniq -c | sort -rn | head -20
NS NAME CLASS HOSTS
myapp myapp webapprouting.kubernetes.azure.com myapp.example.com
12 nginx.ingress.kubernetes.io/rewrite-target
7 nginx.ingress.kubernetes.io/proxy-body-size
3 nginx.ingress.kubernetes.io/configuration-snippet
proxy-body-size and configuration-snippet have no direct equivalent in App Routing Gateway API, so they are migration risk points.
Generate a Gateway API draft with ingress2gateway
ingress2gateway print --providers=ingress-nginx -A > gwapi-draft.yaml grep -n "gatewayClassName" gwapi-draft.yaml # change to approuting-istio or azure-alb-external
ingress2gateway 1.0 (2026-03) supports more than 30 ingress-nginx annotations. The output is a draft and must be reviewed manually. For flags, follow ingress2gateway print --help.
App Routing Gateway API: expose myapp
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: myapp-gw
namespace: myapp
spec:
gatewayClassName: approuting-istio
listeners:
- name: http
port: 80
protocol: HTTP
allowedRoutes:
namespaces:
from: Same
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: myapp
namespace: myapp
spec:
parentRefs:
- name: myapp-gw
hostnames: ["myapp.example.com"]
rules:
- matches:
- path: { type: PathPrefix, value: / }
backendRefs:
- name: myapp
port: 80
To create an internal load balancer, you can add annotations to the Gateway as described in the Istio Gateway API docs (for example, how the service.beta.kubernetes.io/azure-load-balancer-internal: "true" annotation is passed through follows the official "annotation customizations" guide).
AGC example (managed by ALB Controller)
apiVersion: alb.networking.azure.io/v1
kind: ApplicationLoadBalancer
metadata:
name: alb-myapp
namespace: myapp
spec:
associations:
- /subscriptions/<sub>/resourceGroups/rg-aks-lab/providers/Microsoft.Network/virtualNetworks/vnet-aks-lab/subnets/snet-agc
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: myapp-agc
namespace: myapp
annotations:
alb.networking.azure.io/alb-namespace: myapp
alb.networking.azure.io/alb-name: alb-myapp
spec:
gatewayClassName: azure-alb-external
listeners:
- name: http
port: 80
protocol: HTTP
allowedRoutes: { namespaces: { from: Same } }
The field and annotation names follow the "managed by ALB Controller" pattern from the AGC quickstart. Follow the current AGC docs. The HTTPRoute is the same as the previous example; just change parentRefs to myapp-agc.
Lab 5: Expose myapp with App Routing Gateway API (about 10 minutes)
az aks command invoke, or turn off private mode first.az version --query '"azure-cli"' -o tsv # requires ≥ 2.86.0 az aks update -g $RG -n $NETCLUSTER --enable-gateway-api --enable-app-routing-istio kubectl get pods -n aks-istio-system kubectl get gatewayclass
NAME READY STATUS RESTARTS AGE istiod-6d8c7f9b5d-4xk2p 1/1 Running 0 3m istiod-6d8c7f9b5d-qp9wn 1/1 Running 0 3m NAME CONTROLLER ACCEPTED AGE approuting-istio istio.io/gateway-controller True 3m
myapp-gateway.yaml from the “Commands” tab and apply it:
kubectl apply -f myapp-gateway.yaml kubectl -n myapp wait --for=condition=programmed gateways.gateway.networking.k8s.io myapp-gw --timeout=5m kubectl -n myapp get deploy,svc,hpa,pdb | grep approuting-istio
deployment.apps/myapp-gw-approuting-istio 2/2 2 2 2m service/myapp-gw-approuting-istio LoadBalancer 10.0.54.96 20.48.33.120 15021:30580/TCP,80:32693/TCP 2m horizontalpodautoscaler.autoscaling/myapp-gw-approuting-istio Deployment/myapp-gw-approuting-istio cpu: 3%/80% 2 5 2 2m poddisruptionbudget.policy/myapp-gw-approuting-istio 1 N/A 1 2m
GW=$(kubectl -n myapp get gateways.gateway.networking.k8s.io myapp-gw -o jsonpath='{.status.addresses[0].value}')
curl -s -H "Host: myapp.example.com" http://$GW/ ; echo
curl -s -o /dev/null -w "%{http_code}\n" -H "Host: other.example.com" http://$GW/
kubectl -n myapp logs deploy/myapp-gw-approuting-istio --tail=3
Hello from myapp! This page has been viewed 7 times. 404 [2026-11-15T10:42:01.120Z] "GET / HTTP/1.1" 200 - via_upstream - "-" 0 52 6 5 "-" "curl/8.11.1" "…" "myapp.example.com" "192.168.1.12:5000" outbound|80||myapp.myapp.svc.cluster.local …
A hostname mismatch returns 404. The upstream address in the access log is a Pod IP, because Envoy sends requests directly to the endpoints.
snet-agc (/24, delegated to Microsoft.ServiceNetworking/trafficControllers). For the commands, see the “Commands” tab. AGC is billed by the hour and by capacity units, so try it only if you have budget for it.kubectl delete -f myapp-gateway.yaml # If you no longer need it: az aks update -g $RG -n $NETCLUSTER --disable-app-routing-istio
Case 1: NGINX annotation migration for 40 teams
Problem: The platform has 300 Ingresses using application routing NGINX, and support ends in 2026-11. Approach: Use the inventory command to count annotation usage. 90% of the Ingresses use only rewrite, timeout, or redirect, so they map directly to HTTPRoute filters. Seven services that depend on proxy-body-size and rate limiting move to the Istio add-on Gateway plus a gateway-level EnvoyFilter. Run the old and new entry points in parallel for two weeks, lower the DNS TTL to 60 seconds in advance, then switch. Limitation: DNS and TLS automation for application routing Gateway API must be configured again following the official docs. You can't reuse the Key Vault workflow assumptions from the NGINX add-on.
Case 2: The external API needs WAF and mTLS
Problem: A financial customer requires the external API to have WAF and client certificate validation, and the entry proxy must not compete with business Pods for node resources. Approach: AGC (deploy the ALB Controller with Helm using the BYO deployment strategy, with AGC, frontend, and association managed by Terraform). The security policy is associated with a WAF policy. Frontend mTLS. Configure an NSG on snet-agc. Associations created after 2026-04-23 fully support inbound and outbound rules, so allow 80/443, the AzureLoadBalancer tag, and outbound traffic to the Pod CIDR. Limitations: It only listens on 80/443. The default request timeout is 60 seconds; for large file downloads, adjust the timeout in the HTTPRoute.
Case 3: A shared NGINX controller allows cross-namespace hijacking
Problem: Tenant B created an Ingress with the same host as tenant A and added a new path, which took over part of the traffic. Cause: The official documentation states that the NGINX controller does not isolate tenants at the namespace level. When hosts match, the earliest Ingress controls TLS and server-level annotations. Approach: Move to Gateway API. The platform team owns the Gateway, allowedRoutes.namespaces uses labels to select the allowed tenant namespaces, and a Policy (Azure Policy/Gatekeeper) validates hostname ownership. Limitation: Tenants that don't trust each other should still run in separate clusters.
Common errors and fixes
The Gateway stays at Programmed=False, and istiod logs report CRD conflicts / the control plane fails to start
Cause: The Istio service mesh add-on was enabled before. After it was disabled, leftover *.istio.io CRDs and the istio GatewayClass prevent the application routing Istio control plane from starting.
kubectl get crd | grep istio.io kubectl get gatewayclass
Fix (this deletes Istio custom resources, so first confirm you no longer need them): kubectl delete crd $(kubectl get crd -o name | grep -E 'istio\.io'); kubectl delete gatewayclass istio.
az aks update --enable-app-routing-istio: unrecognized arguments
Cause: The Azure CLI version is lower than 2.86.0.
Fix: Run az upgrade, and confirm that managed Gateway API is enabled (--enable-gateway-api). Self-managed Gateway API CRDs are not supported.
HTTPRoute status Accepted=False, reason NotAllowedByListeners
Cause: The HTTPRoute and the Gateway are in different namespaces, but the listener sets allowedRoutes.namespaces.from: Same; or the sectionName or port doesn't match.
kubectl -n myapp describe httproute myapp | sed -n '/Status/,$p'
Fix: Adjust allowedRoutes (Selector plus namespace labels). When referencing a Service in another namespace, add a ReferenceGrant.
The Ingress has no effect, and the NGINX log in app-routing-system shows snippet annotation ... is not allowed
Cause: The snippet contains blocked values (such as proxy_pass, location, _by_lua, {, and so on), so the entire Ingress is not configured.
Fix: Remove the snippet. During migration, this is exactly the part you need to find a replacement for in Gateway API.
AGC: The Gateway status shows the frontend is not ready, and alb-controller logs show AuthorizationFailed
Cause: The ALB Controller identity is missing the AppGw for Containers Configuration Manager or Network Contributor role, or the federated credential doesn't match. This is common with Helm deployments.
kubectl -n kube-system logs deploy/alb-controller --tail=50 az role assignment list --assignee <alb-identity-client-id> --all -o table
Fix: Add the missing roles. Note that this role includes data-plane permissions that Owner and Contributor don't have. Check the association subnet delegation and the /24 size.
1. List all Ingresses in the cluster that still use the application routing NGINX class.
kubectl get ingress -A -o jsonpath='{range .items[?(@.spec.ingressClassName=="webapprouting.kubernetes.azure.com")]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}'2. Get the external address of the Gateway myapp-gw and test hostname routing.
GW=$(kubectl -n myapp get gateways.gateway.networking.k8s.io myapp-gw -o jsonpath='{.status.addresses[0].value}')
curl -s -H "Host: myapp.example.com" http://$GW/A cluster uses application routing NGINX with 20 Ingresses. Two of them use nginx.ingress.kubernetes.io/limit-rps for rate limiting, and the security team also wants WAF next year. It is mid-November 2026. What do you do?
Time is tight: support for critical NGINX patches has ended. Short term: enable application routing Gateway API now and move the 18 regular Ingresses over (ingress2gateway generates a draft, then manual review, parallel validation, and a DNS cutover). For the two rate-limited services: application routing Gateway API does not support rate limiting. The options are the Istio add-on Gateway with EnvoyFilter (the two can't be enabled on the same cluster at the same time, so evaluate this), or moving rate limiting to AGC or the API management layer. Medium term: when WAF arrives next year, move the external entry point as a whole to AGC, which supports Gateway API and keeps migration cost low, and handle rate limiting with API Management or AGC capabilities (check the documentation at that time). After migration is complete, run az aks approuting disable and delete the app-routing-system namespace.
Verified teaching videos
Official documentation
- Application routing NGINX (includes retirement notes and the multi-tenancy warning)
- Application routing Gateway API implementation
- What is Application Gateway for Containers?
- AGC components (subnets, timeouts, headers)
- Ingress NGINX retirement announcement
Video storyboard (about 90 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
On screen: the ingress-nginx icon gets an “Archived” sign, and the calendar stops at November 2026.
Narration: Upstream ingress-nginx has been retired. AKS application routing for NGINX only receives critical security patches until November 2026.
On screen: Gateway and HTTPRoute cards come together, and the approuting-istio and Envoy Pods appear below.
Narration: The successor is Gateway API. Application routing runs the Envoy gateway in the cluster on a managed Istio control plane. No sidecar is needed.
On screen: requests are checked by the AGC shield (WAF) outside the cluster, then go directly to the Pods.
Narration: If you need WAF, mutual TLS, or don't want the entry point using cluster resources, choose Application Gateway for Containers, which runs outside the cluster.
On screen: the five-step migration progress bar lights up in order.
Narration: Inventory the annotations, choose the target, convert automatically, run in parallel, then decommission. The risk is in the annotations, not the YAML.
Module 6 · Network policies: Azure, Cilium, and Calico
- Compare the three policy engines (Cilium, Azure NPM, Calico) by platform support, capabilities, and retirement dates, and choose Cilium as the Linux default.
- Write a namespace-level “default deny Ingress and Egress” policy, and correctly allow DNS (both the kube-dns and LocalDNS paths).
- Understand Cilium's
ipBlocklimits,toEntitiesandfromEntitiesinCiliumNetworkPolicy, and that FQDN and L7 policies require ACNS. - Understand how LoadBalancer Services interact with policies. To restrict public sources, use
loadBalancerSourceRanges, which takes effect before address rewriting.
What: The three policy engines in AKS
| Engine | Platform | Network options | Extra capabilities | Support status |
|---|---|---|---|---|
| Cilium | Linux | Azure CNI (any IPAM) plus Cilium data plane | L3/L4, CiliumNetworkPolicy, cluster-wide policies; FQDN and L7 require ACNS | Recommended |
| Azure NPM | Linux (Windows support ended 2026-09-30) | Azure CNI | None; iptables implementation; limit of 250 nodes / 20,000 Pods; IPv6 not supported | Linux support ends 2028-09-30; migrate to Cilium |
| Calico (AKS-managed) | Linux, Windows Server 2019/2022 | Azure CNI; kubenet (Linux) | AKS only tests and supports networking.k8s.io policies; projectcalico.org/v3 requires self-managed Calico | Supported; choice for Windows nodes |
Why
By default, all Pods in a cluster can reach each other freely. A compromised frontend Pod can connect directly to the database, the metadata endpoint, and other tenants. Network policies tighten east-west traffic on a least-privilege basis, which is a basic requirement for zero trust and compliance (PCI, China's MLPS). Cilium enforces policy based on identity, so rules don't need to be rewritten when Pods scale, and its scale and performance are clearly better than the iptables approach.
How: Four rules for writing policies
- Policies are additive: Once any policy selects a Pod in a given direction, that direction becomes “default deny plus the union of all policies' allows.”
- Allow DNS before default-deny Egress: Allow UDP and TCP 53 to
k8s-app=kube-dnsinkube-system. If the node pool has LocalDNS enabled, Pod DNS requests go first to169.254.10.10/11(node-local). With Cilium, you need aCiliumNetworkPolicythat allowstoCIDR 169.254.10.0/24and port 53 totoEntities: host(example from the official FAQ). - Cilium's ipBlock can't select Pod or node IPs: For allows within the cluster, use
podSelector/namespaceSelector. To reach nodes, usetoEntities: [host]orremote-node. For inbound traffic from the internet, usefromEntities: [world]. - LoadBalancer traffic gets its addresses rewritten: With
externalTrafficPolicy: Cluster, the source a Pod sees may be the node IP. To restrict public sources, useloadBalancerSourceRangeson the Service, which takes effect at the NSG/host layer before rewriting. Or use theazure-allowed-ip-ranges/azure-allowed-service-tagsannotations (preview).
When
- Every business namespace: default deny, plus DNS, plus required dependencies.
- Egress to external SaaS: FQDN policies (ACNS), or FQDN rules through Azure Firewall.
- Need HTTP method or path-level control: Cilium L7 policies (ACNS, Kubernetes ≥ 1.29).
- Windows node pools: Calico.
Comparison with similar technologies
| NetworkPolicy | CiliumNetworkPolicy | NSG | Azure Firewall | |
|---|---|---|---|---|
| Granularity | Pod labels, namespaces, IP ranges, ports | Plus entities (host/world), FQDN, L7 (ACNS) | Subnets/NICs, IPs, service tags | FQDN, IP, threat intelligence |
| Location | Node eBPF | Node eBPF | Azure networking stack | Outside the cluster |
| East-west (Pod↔Pod) | Yes | Yes | With overlay, Pod CIDR traffic is also affected by subnet NSGs, but they can't tell individual Pods apart | No |
Preferred mode on Cilium or Calico clusters will not automatically enable LocalDNS if network policies are detected (apart from the default konnectivity-agent policy).Architecture diagram: target policies for the myapp namespace
Flowchart: How Cilium decides on a packet
Policy simulator: select policies to see which connections are allowed
This simulates how Cilium enforces policy in the myapp namespace. After you check or uncheck policies, click “Test all connections.” The log below simulates Hubble-style flow records. Hubble flow logs require ACNS; here they only explain why each decision was made.
Core commands and parameters
| Command | Purpose | Notes |
|---|---|---|
--network-policy cilium|azure|calico|none | Select the policy engine | Automatically set to cilium when using the Cilium data plane |
az aks update --network-policy none | Uninstall NPM/Calico | Policy objects are kept but no longer enforced; the whole pool is reimaged |
az aks update --network-dataplane cilium | NPM/Calico → Cilium | The existing engine is replaced; behavior differences must be covered by regression tests |
kubectl get netpol,cnp,ccnp -A | List K8s and Cilium policies | cnp = CiliumNetworkPolicy, ccnp = cluster-wide |
cilium-dbg endpoint list | View the policy enforcement status of each endpoint | POLICY column shows Enabled/Disabled |
cilium-dbg monitor --type drop | Watch dropped packets in real time | Reason Policy denied |
Default deny plus DNS allow
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny-all, namespace: myapp }
spec:
podSelector: {}
policyTypes: [Ingress, Egress]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: allow-dns-coredns, namespace: myapp }
spec:
podSelector: {}
policyTypes: [Egress]
egress:
- to:
- namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: kube-system } }
podSelector: { matchLabels: { k8s-app: kube-dns } }
ports: [{ port: 53, protocol: UDP }, { port: 53, protocol: TCP }]
---
# LocalDNS (169.254.10.10/11 on the node) requires a Cilium policy allow, taken from the official FAQ
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata: { name: allow-localdns, namespace: myapp }
spec:
endpointSelector: { matchLabels: {} }
egress:
- toCIDR: ["169.254.10.0/24"]
toPorts: [{ ports: [{ port: "53", protocol: UDP }, { port: "53", protocol: TCP }] }]
- toEntities: [host]
toPorts: [{ ports: [{ port: "53", protocol: UDP }, { port: "53", protocol: TCP }] }]
Business allows
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: redis-from-myapp, namespace: myapp }
spec:
podSelector: { matchLabels: { app: redis } }
policyTypes: [Ingress]
ingress:
- from: [{ podSelector: { matchLabels: { app: myapp } } }]
ports: [{ port: 6379, protocol: TCP }]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: myapp-egress-redis, namespace: myapp }
spec:
podSelector: { matchLabels: { app: myapp } }
policyTypes: [Egress]
egress:
- to: [{ podSelector: { matchLabels: { app: redis } } }]
ports: [{ port: 6379, protocol: TCP }]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: myapp-from-gateway, namespace: myapp }
spec:
podSelector: { matchLabels: { app: myapp } }
policyTypes: [Ingress]
ingress:
- from: [{ podSelector: { matchLabels: { gateway.networking.k8s.io/gateway-name: myapp-gw } } }]
ports: [{ port: 5000, protocol: TCP }]
---
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata: { name: gateway-pods, namespace: myapp }
spec:
endpointSelector: { matchLabels: { gateway.networking.k8s.io/gateway-name: myapp-gw } }
ingress:
- fromEntities: [world, host, remote-node]
toPorts: [{ ports: [{ port: "80", protocol: TCP }, { port: "15021", protocol: TCP }] }]
egress:
- toEndpoints: [{ matchLabels: { app: myapp } }]
toPorts: [{ ports: [{ port: "5000", protocol: TCP }] }]
- toEndpoints: [{ matchLabels: { "k8s:io.kubernetes.pod.namespace": aks-istio-system } }]
toPorts: [{ ports: [{ port: "15012", protocol: TCP }] }]
The label gateway.networking.k8s.io/gateway-name on the gateway Pod is added by Istio's automatic deployment. Confirm it with kubectl -n myapp get pod --show-labels. Port 15012 is Istio's default xDS port for istiod. fromEntities: host, remote-node covers load balancer health probes and traffic forwarded through other nodes when externalTrafficPolicy: Cluster is set. Verify each rule before going live.
Observe drops
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg monitor --type drop
xx drop (Policy denied) flow 0x0 to endpoint 1203, ifindex 14, file bpf_lxc.c:2071, identity 52114->40211: 192.168.0.52:41236 -> 192.168.1.25:6379 tcp SYN
cilium-dbg monitor only shows events for this node. Run it in the cilium Pod on the node where the source or destination Pod runs (find the node with kubectl -n kube-system get pod -l k8s-app=cilium -o wide).
Lab 6: Zero trust in the myapp namespace (about 8 minutes)
kubectl run nettest -n myapp --image=mcr.microsoft.com/azurelinux/base/core:3.0 --restart=Never --command -- sleep 3600 kubectl -n myapp wait --for=condition=Ready pod/nettest kubectl -n myapp exec nettest -- sh -c "tdnf install -y nmap-ncat bind-utils curl >/dev/null 2>&1; nc -zv -w 3 redis 6379"
Ncat: Connected to 10.0.143.20:6379.
kubectl -n myapp apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny-all }
spec: { podSelector: {}, policyTypes: [Ingress, Egress] }
EOF
kubectl -n myapp exec nettest -- nc -zv -w 3 redis 6379
Ncat: Could not resolve hostname "redis": Temporary failure in name resolution. QUITTING.
The first failure is DNS, not redis. That's why you allow DNS first.
kubectl apply -f np-baseline.yaml -f np-app.yaml kubectl -n myapp get netpol,cnp
kubectl -n myapp exec nettest -- nc -zv -w 3 redis 6379 # expected: timeout (nettest has no app=myapp label)
kubectl -n myapp exec deploy/myapp -- python -c "import socket;s=socket.create_connection(('redis',6379),3);print('redis ok')"
kubectl -n myapp exec nettest -- dig +short myapp.myapp.svc.cluster.local # expected: returns the ClusterIP (DNS is allowed)
GW=$(kubectl -n myapp get gateways.gateway.networking.k8s.io myapp-gw -o jsonpath='{.status.addresses[0].value}' 2>/dev/null)
[ -n "$GW" ] && curl -s -o /dev/null -w "%{http_code}\n" -H "Host: myapp.example.com" http://$GW/
Ncat: TIMEOUT. redis ok 10.0.91.7 200
If the Gateway from Module 5 has been deleted, the last item is skipped. The myapp image is Python, so the connection test uses Python.
cilium-dbg monitor --type drop. Then start a connection from nettest and watch for Policy denied.kubectl -n myapp delete pod nettest --now. To revoke everything, run kubectl -n myapp delete netpol,cnp --all.Case 1: Migrating from Azure NPM to Cilium
Problem: A 120-node Linux cluster uses NPM, which stops being supported on 2028-09-30. Large policy edits also cause occasional brief failures for new connections (a known NPM race condition). Approach: Use Azure Resource Graph to find all Linux clusters with networkPolicy == azure. Run --network-dataplane cilium on a staging cluster, and test all policies with a connection matrix. Pay special attention to ipBlock, since Cilium can't select Pod or node IPs. Run production in a maintenance window. During the migration, until all nodes finish reimaging, Cilium hasn't started enforcing policies yet. Limitation: Clusters with Windows node pools can't be migrated.
Case 2: After default-deny went live, all Pods failed DNS resolution overnight
Problem: The platform enabled LocalDNS after upgrading to 1.37. The existing policies only allowed traffic to the kube-dns Pods, so all DNS queries timed out. Approach: Following the official FAQ, add a CiliumNetworkPolicy that allows 169.254.10.0/24 and port 53 to the host entity. Add it to the policy template library as part of the baseline. Limitation: In 1.37, the Preferred mode doesn't automatically enable LocalDNS when network policies are detected. But an explicit Required does enable it, so policies must work on both paths.
Case 3: Only the payment service may reach the external payment gateway
Problem: PCI requires that only the payment namespace can make outbound connections to api.payments.example.com. Approach: Enable ACNS. A CiliumNetworkPolicy uses toFQDNs plus a DNS proxy to allow the traffic. Other namespaces deny egress to world by default. Egress is audited through Azure Firewall. Limitation: FQDN filtering depends on DNS passing through the Cilium proxy. When used with LocalDNS, the labels in the Local Redirect Policy must match the policy (per the official notes).
Common errors and fixes
Temporary failure in name resolution (after the application's default deny)
Cause: Default-deny Egress blocks DNS, or only kube-dns was allowed while the node has LocalDNS enabled.
kubectl -n myapp exec POD -- cat /etc/resolv.conf kubectl -n myapp get netpol,cnp
Fix: Allow UDP and TCP 53 to kube-dns, and add the LocalDNS CiliumNetworkPolicy.
drop (Policy denied) ... identity X->Y (but I wrote ipBlock 0.0.0.0/0)
Cause: Cilium's ipBlock can't select Pod or node IPs.
Fix: In the same to, add namespaceSelector: {} and podSelector: {}. To reach nodes, use toEntities: [host, remote-node] in a CiliumNetworkPolicy.
LoadBalancer Service health probes fail, and external access returns 503 or times out (after default-deny on the app Ingress)
Cause: Load balancer health probes, and traffic forwarded under externalTrafficPolicy: Cluster, come from nodes or remote nodes, which default-deny blocks.
Fix: On the ingress Pod, allow fromEntities: [world, host, remote-node]. To restrict public sources, use loadBalancerSourceRanges instead.
az aks update --network-policy calico fails: must set network policy to none first
Cause: Changing the policy engine requires setting it to none first, then setting the new value. Go by the actual error text.
az aks update -g $RG -n <cluster> --network-policy none az aks update -g $RG -n <cluster> --network-policy calico
Note: Policies are not enforced during the intermediate stage, and each change reimages the node pool.
After an NPM cluster scaled to 260 nodes, the azure-npm Pod was OOMKilled
Cause: Azure NPM doesn't support more than 250 nodes or 20,000 Pods.
Fix: Migrate to the Cilium data plane.
1. List the Kubernetes and Cilium network policies in every namespace of the cluster.
kubectl get networkpolicy,ciliumnetworkpolicy,ciliumclusterwidenetworkpolicy -A
2. Find the clusters in the subscription that still use Azure NPM (Resource Graph).
az graph query -q "Resources | where type =~ 'microsoft.containerservice/managedclusters' | where tolower(tostring(properties.networkProfile.networkPolicy)) == 'azure' | project name, resourceGroup" -o table
A mixed cluster (Linux and Windows node pools) requires default deny in all namespaces. It currently uses Azure NPM. How would you plan for 2027?
NPM support on Windows nodes ended 2026-09-30, and Linux support ends 2028-09-30. Cilium only supports Linux, and clusters with Windows node pools can't upgrade to the Cilium data plane. There are two options: ① Split. Move the Linux workloads to a new overlay plus Cilium cluster (recommended), and keep the Windows workloads in a cluster with overlay, the Azure data plane, and Calico. ② Don't split. Switch the whole cluster to Calico (--network-policy none → calico). Calico supports Windows Server 2019/2022, but AKS only supports the standard networking.k8s.io policies. Both options require building a policy test matrix first, and assessing the risk of the intermediate stage during the switch, when the policy engine is set to none.
Verified teaching videos
Official documentation
- Secure pod traffic with network policies (engine comparison, retirement)
- Migrate from NPM to Cilium Network Policy
- Cilium FAQ (ipBlock, LocalDNS allow rules)
- FQDN filtering (ACNS)
Video storyboard script (about 80 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
On screen: lines connect every Pod in the namespace.
Narration: By default, any two Pods in the cluster can reach each other.
On screen: a “default deny” wall drops down, all the lines are cut, and DNS is cut too.
Narration: If you write default deny first, you'll find DNS is the first thing to break.
On screen: green lines come back one at a time: DNS, the gateway to myapp, and myapp to redis. nettest's line stays red.
Narration: Then allow only the connections that are really needed. Cilium uses identity rather than IP to make decisions, so rules don't change when Pods are rebuilt.
On screen: the calendar shows September 30, 2028, and the NPM icon turns gray.
Narration: Azure NPM on Linux stops being supported on September 30, 2028. Please migrate to Cilium.
Module 7 · DNS, CoreDNS, and private DNS zones
- Read a Pod's
/etc/resolv.conf(nameserver, search,ndots:5), and explain why one external domain name can produce 4–5 queries. - Use the
coredns-customConfigMap (keys must end in.serveror.override) for forwarding, stub domains, and hosts mappings, and roll out a CoreDNS restart safely. - Understand LocalDNS: the DNS proxy on each node (169.254.10.10/11), its three modes,
vnetDNSOverridesandkubeDNSOverrides, and the upgrade impact of AKS Standard defaulting to Preferred starting in 1.37. - Design DNS for private endpoints: private DNS zone links, conditional forwarding from custom DNS servers to 168.63.129.16, and allowing both UDP and TCP 53.
svc.namespace.svc.cluster.local). Importance: ★★★★★ (half of network problems are DNS problems)What: DNS components in an AKS cluster
| Component | Location | Purpose |
|---|---|---|
Pod /etc/resolv.conf | Each Pod | With dnsPolicy: ClusterFirst (the default), nameserver is the kube-dns Service IP (10.0.0.10 in this hour). The search list includes <ns>.svc.cluster.local svc.cluster.local cluster.local and the node's VNet search suffix. options ndots:5 |
| LocalDNS | Each node (DNS proxy) | Intercepts DNS queries from Pods and nodes, caches them locally (up to 3600 seconds by default, can serve stale), and forwards by zone: cluster.local goes to CoreDNS (ForceTCP by default), and everything else goes to VNet DNS (PreferUDP by default). Addresses are 169.254.10.10 and 169.254.10.11. |
| CoreDNS | kube-system Deployment (Service name kube-dns) | Resolves in-cluster Service and Pod names. Other names use forward . /etc/resolv.conf (the node's DNS, which is VNet DNS). The main Corefile can't be modified; extend it through coredns-custom. |
| VNet DNS | VNet settings | Default Azure DNS (168.63.129.16), which automatically resolves private DNS zones linked to the VNet, or an enterprise custom DNS server |
| Azure private DNS zone | Global resource, linked to a VNet | Private endpoints (privatelink.blob.core.windows.net, and so on), private cluster API server, internal domain names |
Why: DNS is the top source of failures
- ndots:5: If a name has fewer than 5 dots, the resolver first appends each search suffix in turn.
api.github.com(2 dots) is first queried asapi.github.com.myapp.svc.cluster.local, then…svc.cluster.local, then…cluster.local, then…<vnet suffix>. The real name is queried only after all of them return NXDOMAIN, which multiplies the query volume by 4–5×. For external domains, add a trailing dot (api.github.com.), or setdnsConfig.options ndots: 2on the Pod to mitigate. - UDP packet loss and conntrack races: Under high QPS, UDP DNS occasionally times out for 5 seconds. LocalDNS keeps queries on the local node and uses TCP to CoreDNS, which significantly reduces this kind of problem.
- Private zone link mismatch: The zone isn't linked to the VNet of the DNS server that actually does the resolving.
How: LocalDNS modes and the 1.37 changes (verified 2026-11)
| Kubernetes | Preferred | Required | Disabled |
|---|---|---|---|
| 1.31–1.36 | Validate configuration only, don't enable (but it still triggers a reimage) | Install and force-enable | Don't install |
| 1.37+ | Install and enable if the compatibility check passes | Install and force-enable | Don't install |
Starting 1.37, in AKS Standard, eligible node pools with no explicit LocalDNS configuration are set to Preferred when they're created or updated (including version upgrades), and LocalDNS is enabled if the checks pass. The checks include: Azure Linux or Ubuntu 22.04+, sufficient VM SKU resources (the official prerequisite is at least 4 vCPUs), a managed CNI (not BYOCNI), no network policies on Cilium or Calico clusters (except the default kube-system/konnectivity-agent policy), and no upstream NodeLocal DNSCache installed. Once enabled, it changes the DNS forwarding path, and LocalDNS uses long-lived TCP connections to upstream (it also falls back to TCP when PreferUDP truncates). If a custom DNS server doesn't accept TCP 53, or limits concurrent TCP connections, name resolution fails across the entire cluster. To prevent enablement, explicitly set mode: Disabled (this triggers a reimage).
How: coredns-custom
- ConfigMap
kube-system/coredns-custom. A key indataending in.serveradds a new server block (for example,corp.contoso.com:53 { forward . 10.50.0.4 }). A key ending in.overrideinserts into the default server block (for example,hosts { … fallthrough }orlog). - Supports all built-in plugins, but not third-party plugins. After making changes, run
kubectl -n kube-system rollout restart deployment coredns. - Note: When LocalDNS is enabled, names outside
cluster.localare forwarded by default directly from LocalDNS to VNet DNS, without going through CoreDNS. Forwarding rules you wrote for enterprise domains in coredns-custom won't apply to those queries. Instead, add a server block for that domain in the LocalDNS configuration withforwardDestination: ClusterCoreDNS(the official example uses microsoft.com to demonstrate a custom server block).
When
- To access PaaS private endpoints, link the private zone to the cluster VNet (Azure DNS) or to the VNet where the DNS server lives (custom DNS).
- Internal enterprise domains: configure them on the enterprise DNS first, so they're consistent for all workloads. Use coredns-custom or LocalDNS server blocks only for mappings specific to the cluster.
- High QPS or occasional DNS timeouts: enable LocalDNS (Required, or Preferred on 1.37), and validate TCP 53 in advance.
Comparison with similar technologies
| AKS LocalDNS | Upstream NodeLocal DNSCache | CoreDNS only | |
|---|---|---|---|
| Managed by | AKS (node pool configuration) | Self-deployed DaemonSet | AKS |
| Configuration surface | localdnsconfig.json (per node pool) | ConfigMap | coredns-custom |
| Can be enabled together | Not recommended to enable both. 1.37 Preferred won't auto-enable when NodeLocal DNSCache is detected. | — | |
az aks nodepool upgrade --node-image-only). ② “For custom DNS, opening UDP 53 is enough.” You must open both UDP and TCP 53, which is especially critical starting with 1.37. ③ “Editing the coredns ConfigMap changes the Corefile.” AKS restores the main configuration. Use only coredns-custom. ④ “Linking the private zone to the spoke is enough.” When custom DNS lives in the hub, the zone must be linked to the hub (or use DNS Private Resolver).Architecture diagram: resolution path with LocalDNS enabled
Flowchart: resolving api.github.com with ndots:5
Step-by-step animation: the full path of one DNS query
Select the name and environment, then step through: search expansion, the LocalDNS cache, CoreDNS, VNet DNS, and private zones. The log shows the real query and response at each hop (sample values).
Core commands and parameters
| Command | Purpose | Notes |
|---|---|---|
kubectl exec POD -- cat /etc/resolv.conf | Pod DNS configuration | Check nameserver, search, and ndots |
kubectl -n kube-system get cm coredns coredns-custom -o yaml | CoreDNS configuration | Change only coredns-custom |
kubectl -n kube-system rollout restart deploy coredns | Reload custom configuration | Rolling restart with no downtime |
az aks nodepool update --localdns-config ./localdnsconfig.json | Enable, modify, or disable LocalDNS | CLI ≥ 2.80; triggers a node reimage |
az aks nodepool upgrade --node-image-only | Gives nodes the new VNet DNS settings | Required after changing VNet DNS |
dig +udp / +tcp @<dns> <fqdn> | Verify both transports on the DNS server | Must do before enabling LocalDNS |
az network private-dns link vnet create | Link the private zone to the VNet | Only the VNet that does the resolving needs the link |
kubectl -n myapp exec deploy/myapp -- cat /etc/resolv.conf
search myapp.svc.cluster.local svc.cluster.local cluster.local abcd1234efgh.yx.internal.cloudapp.net nameserver 10.0.0.10 options ndots:5
Even with LocalDNS enabled, the nameserver seen inside a Pod may still be 10.0.0.10, because traffic is redirected on the node. So check the Server: field in the nslookup output instead. The official verification method is to see 169.254.10.10 or 169.254.10.11.
coredns-custom: enterprise domain forwarding, hosts mapping, and query logging
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-custom
namespace: kube-system
data:
corp.server: |
corp.contoso.com:53 {
errors
cache 30
forward . 10.50.0.4
}
legacy.override: |
hosts {
10.10.0.100 legacy.lab.internal
fallthrough
}
log.override: |
log
kubectl apply -f coredns-custom.yaml kubectl -n kube-system rollout restart deployment coredns kubectl -n kube-system rollout status deployment coredns kubectl -n kube-system logs -l k8s-app=kube-dns --tail=5
Common errors: A key that doesn't end in .server or .override is ignored, and forgetting the rollout restart. log.override logs every query, so delete it after troubleshooting to avoid excessive log volume.
LocalDNS: viewing and explicit configuration
az aks nodepool show -g $RG --cluster-name $NETCLUSTER -n nodepool1 -o json | jq '.localDnsProfile'
# Explicitly disable (before upgrading to 1.37, if the DNS path isn't ready yet):
echo '{"mode":"Disabled"}' > localdns-disabled.json
az aks nodepool update -g $RG --cluster-name $NETCLUSTER -n nodepool1 --localdns-config ./localdns-disabled.json
Property names follow the actual output of az aks nodepool show -o json. The configuration file structure follows the default template in the official “Configure LocalDNS” docs. Check the CLI validation result to confirm whether setting only mode is accepted. Any profile change reimages the node pool.
Private DNS zones: give the cluster an internal domain name
az network private-dns zone create -g $RG -n lab.aks.internal az network private-dns link vnet create -g $RG -z lab.aks.internal -n link-aks-lab -v $VNET -e false az network private-dns record-set a add-record -g $RG -z lab.aks.internal -n legacy -a 10.10.0.100
Lab 7: Observe ndots, configure coredns-custom, resolve a private zone, and check LocalDNS (about 10 minutes)
dnslab, so those policies don't affect it. A private DNS zone costs about $0.5 per month (prorated by day; check the pricing page for current rates).kubectl create ns dnslab kubectl -n dnslab run dig --image=mcr.microsoft.com/azurelinux/base/core:3.0 --restart=Never --command -- sleep 3600 kubectl -n dnslab wait --for=condition=Ready pod/dig kubectl -n dnslab exec dig -- sh -c "tdnf install -y bind-utils >/dev/null 2>&1; cat /etc/resolv.conf"
log.override from the previous section), then:
kubectl -n dnslab exec dig -- sh -c "getent hosts api.github.com >/dev/null; getent hosts api.github.com. >/dev/null"
kubectl -n kube-system logs -l k8s-app=kube-dns --since=1m | grep github | awk '{print $7, $8, $9}'
"A IN api.github.com.dnslab.svc.cluster.local. NXDOMAIN "A IN api.github.com.svc.cluster.local. NXDOMAIN "A IN api.github.com.cluster.local. NXDOMAIN "A IN api.github.com.abcd1234efgh.yx.internal.cloudapp.net. ...
A second query with a trailing dot is not expanded. If LocalDNS is enabled, external domain queries don't go through CoreDNS, so the log shows only the few entries with the cluster.local suffix. That alone is a clue that LocalDNS is in effect.
kubectl -n dnslab exec dig -- dig +short legacy.lab.internal
10.10.0.100
legacy.override from coredns-custom, restart CoreDNS, and query again:
kubectl -n dnslab exec dig -- dig legacy.lab.internal | grep -A1 "ANSWER SECTION"
This time the answer comes from the Azure private zone (through CoreDNS or LocalDNS to 168.63.129.16). If the VNet uses custom DNS, this step will fail, and you need to configure conditional forwarding on the custom DNS server.
az aks nodepool show -g $RG --cluster-name $NETCLUSTER -n nodepool1 -o json | jq '.localDnsProfile' kubectl -n dnslab exec dig -- nslookup kubernetes.default | head -2
Server: 169.254.10.10 Address: 169.254.10.10#53
If it shows 10.0.0.10, LocalDNS isn't enabled (for example, the compatibility check failed at creation time). Note: The Module 6 network policies make 1.37's Preferred mode skip initial enablement. A LocalDNS that is already enabled is not turned off by this.
kubectl delete ns dnslab. Delete log.override from coredns-custom and run a rollout restart. The private zone can stay until the course ends, since it's deleted with the resource group.Case 1: Cluster-wide DNS failure after upgrading to 1.37
Problem: The enterprise VNet uses a Windows DNS server in the hub, and the firewall only allows UDP 53. After the node pool was upgraded to 1.37, LocalDNS was enabled in Preferred mode. It uses TCP to reach upstream, so all resolution timed out. Approach: The rollback is to explicitly set mode: Disabled on the node pool (this triggers a reimage). The real fix is to allow TCP 53, confirm the DNS server has no concurrent TCP connection limit, and then enable LocalDNS again. Prevention: Before upgrading, verify from a node with dig +udp and dig +tcp, and check whether each node pool has an explicit LocalDNS profile (from the official pre-upgrade checklist).
Case 2: A Pod reaches the Storage private endpoint but resolves to a public IP
Problem: mystorage.blob.core.windows.net returns a public IP, and the storage firewall denies access. Cause: The private zone privatelink.blob.core.windows.net is linked only to the spoke. The spoke's DNS points to the hub's custom DNS, but the hub hasn't linked the zone or set up conditional forwarding. Approach: Link the centralized private DNS zone to the hub, and provide resolution through a DNS Private Resolver inbound endpoint. An Azure Policy automatically creates records for new private endpoints. Limitation: Conditional forwarding doesn't support subdomains.
Case 3: A high-concurrency service has occasional 5-second delays
Problem: The Node.js service's P99 latency shows many spikes of exactly 5 seconds. Packet capture showed DNS UDP requests being lost and retried. Approach: Enable LocalDNS (on 1.36 clusters, use Required). On the application side, add a trailing dot to external domains and set ndots: 2. Use the LocalDNS metrics on port 9253 to feed managed Prometheus (see the Prometheus course). Limitation: The LocalDNS cache is best-effort (256 shards, 10,000 entries by default, random eviction), so it doesn't guarantee that a stale record will be available.
Common errors and fixes
;; connection timed out; no servers could be reached (all Pods in the cluster)
Cause: CoreDNS is unhealthy, a network policy blocks DNS, or LocalDNS can't reach upstream (TCP 53 is blocked).
kubectl -n kube-system get pod -l k8s-app=kube-dns kubectl -n kube-system logs -l k8s-app=kube-dns --tail=50 | grep -iE "timeout|error" kubectl debug node/<node> -it --image=mcr.microsoft.com/azurelinux/base/core:3.0 -- sh -c "tdnf install -y bind-utils; dig +tcp @<vnet-dns> microsoft.com"
Fix: Restore CoreDNS, allow DNS in the policy, and for custom DNS, allow UDP+TCP 53. In an emergency, you can set LocalDNS to Disabled (this reimages the nodes).
Private endpoint domain resolves to a public IP
Cause: The VNet where the DNS server doing the resolution lives isn't linked to the matching privatelink.* zone, or conditional forwarding is missing.
kubectl -n dnslab exec dig -- dig +short mystorage.blob.core.windows.net az network private-dns link vnet list -g <dns-rg> -z privatelink.blob.core.windows.net -o table
Fix: Link the zone to the correct VNet. On the enterprise DNS, conditionally forward blob.core.windows.net to 168.63.129.16 (or the Private Resolver).
No effect after changing coredns-custom
Cause: The key doesn't end in .server or .override, CoreDNS wasn't restarted, or LocalDNS is already forwarding that domain directly to VNet DNS.
Fix: Correct the key and run rollout restart. In LocalDNS scenarios, add a server block in localdnsconfig.json that forwards that domain to ClusterCoreDNS.
Changed the VNet custom DNS server, but nodes still use the old server
Cause: A change at the VNet layer only notifies the network resource provider. The AKS resource provider doesn't know about it.
az aks nodepool upgrade -g $RG --cluster-name $NETCLUSTER -n nodepool1 --node-image-only
LocalDNS config rejected: forwardDestination for root zone can't be ClusterCoreDNS
Cause: A validation rule was violated: in vnetDNSOverrides, . can't forward to ClusterCoreDNS; cluster.local can't forward to VnetDNS; and with ForceTCP, serveStale can't be Verify.
Fix: Modify the official default template.
1. Add a stub domain to the cluster: forward corp.contoso.com to 10.50.0.4, and make the configuration take effect.
kubectl -n kube-system apply -f - <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata: { name: coredns-custom, namespace: kube-system }
data:
corp.server: |
corp.contoso.com:53 {
errors
cache 30
forward . 10.50.0.4
}
EOF
kubectl -n kube-system rollout restart deployment coredns2. From one node, verify that the custom DNS server 10.0.1.4 supports both UDP and TCP.
kubectl debug node/<node> -it --image=mcr.microsoft.com/azurelinux/base/core:3.0 -- \ sh -c "tdnf install -y bind-utils >/dev/null; dig +udp @10.0.1.4 microsoft.com +short; dig +tcp @10.0.1.4 microsoft.com +short"
You're responsible for upgrading 30 AKS Standard clusters from 1.36 to 1.37. All spokes use the hub's custom DNS. Which DNS-related checks do you run before the upgrade?
① Inventory whether each node pool has an explicit LocalDNS profile. Pools without one are set to Preferred after the upgrade and may be enabled. ② From each spoke's nodes, run dig +udp and dig +tcp against the hub DNS. Confirm that NSGs, firewalls, NVAs, and routes all allow TCP 53, and that the DNS server doesn't have an overly low TCP concurrent connection limit. ③ Check whether the network policies on Cilium or Calico clusters allow 169.254.10.0/24 and host port 53. Preferred won't enable for the first time when policies exist, but an explicit Required will. ④ Check whether an upstream NodeLocal DNSCache is deployed. It blocks automatic enablement, and running it alongside LocalDNS isn't recommended. ⑤ Validate first in a non-production node pool. For node pools whose DNS path isn't ready, explicitly set Disabled before the upgrade. ⑥ Enterprise domain forwarding in coredns-custom may be bypassed under LocalDNS, so move it to LocalDNS server blocks or to the enterprise DNS.
Verified teaching videos
Official documentation
- Customize CoreDNS
- Configure LocalDNS (1.37 default behavior, modes, validation rules)
- DNS resolution in AKS
- Private endpoint DNS configuration
- What is IP address 168.63.129.16?
Video storyboard (about 90 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
On screen: a Pod sends an “api.github.com” question bubble, which is copied five times. The first four bounce back with “NXDOMAIN.”
Narration: Because ndots is five, external domains get search suffixes appended first. You end up sending several extra queries for nothing.
On screen: a small cache box, 169.254.10.10, appears on the node. The query is split here: cluster.local goes to CoreDNS, and everything else goes to VNet DNS.
Narration: LocalDNS caches and splits queries on every node. Starting with version 1.37, it is enabled by default on AKS Standard when possible.
On screen: VNet DNS points to 168.63.129.16, then to the private zone, which returns a private 10.x address.
Narration: Private endpoints are resolved through private DNS zones. The zone must be linked to the network that actually does the resolving.
On screen: “TCP 53” lights up next to “UDP 53” on the firewall.
Narration: Custom DNS must allow both UDP and TCP port 53, or cluster-wide name resolution can fail after an upgrade.
Module 8 · Network readiness review and common errors
- Use a 20-item network readiness review checklist to assess the cluster design, and set remediation priorities.
- Recognize 6 high-frequency failure types: address overlap, subnet or Pod CIDR exhaustion, SNAT exhaustion, accidental blocks by NSG or UDR, DNS, and ingress or policy misconfiguration.
- Master the troubleshooting method of working from the outside in and verifying hop by hop, along with the commands for each hop.
What: Network Readiness Review
The goal of the review is to answer three questions before launch: Is there enough address space? Is the path correct? Can you see problems when they happen? The table below is the review checklist summarized in this hour. You can copy it directly into your architecture review template.
| # | Area | Check item | Basis |
|---|---|---|---|
| 1 | Model | Use Azure CNI Overlay (or Pod Subnet with a documented reason). No kubenet or Node Subnet. | M1 |
| 2 | Address | The VNet, Pod CIDR, and Service CIDR don't overlap with the hub, peerings, on-premises networks, or reserved ranges, and are registered in the enterprise IPAM | M0/M1 |
| 3 | Address | The number of /24s for the Pod CIDR is ≥ max node count + surge. The node subnet reserves ≥ 30% for scaling and upgrades. | M1/M2 |
| 4 | Data plane | Linux cluster uses Cilium, and the Cilium version meets the minimum requirement | M2 |
| 5 | NSG | Custom NSG allows node↔node, node→Pod, and Pod↔Pod traffic, plus the ports for the API server subnet | M2/M4 |
| 6 | Outbound | Production uses a NAT Gateway (StandardV2 preferred) or UDR to a firewall. LB outbound ports and IPs are explicitly calculated. | M3 |
| 7 | Outbound | Egress IPs are registered in external allow lists. Changes to the outbound type have a window and a rollback plan. | M3 |
| 8 | Outbound | With UDR, the firewall allows the endpoints AKS requires. No public LoadBalancer Service causes asymmetric routing. | M3 |
| 9 | Control plane | Private API server (VNet integration or private cluster), or a public endpoint plus authorized IP ranges | M4 |
| 10 | Control plane | Private DNS zone links and conditional forwarding are verified. CI/CD uses a proxy inside the VNet. | M4 |
| 11 | Ingress | No longer depends on application routing NGINX or self-managed ingress-nginx. Uses Gateway API (approuting-istio or AGC). | M5 |
| 12 | Ingress | The external entry point has WAF (AGC, or Front Door or App Gateway in front). TLS certificates come from Key Vault. | M5 |
| 13 | Ingress | The Gateway is owned by the platform team, with allowedRoutes restricting namespaces. Ingress Pods have a PDB. | M5 |
| 14 | Policy | Every business namespace default-denies Ingress and Egress, and DNS (including LocalDNS) is allowed | M6 |
| 15 | Policy | No Azure NPM (Linux retires 2028-09-30). ipBlock usage has been reviewed against Cilium's limits. | M6 |
| 16 | DNS | Custom DNS servers allow UDP and TCP 53 from nodes, with no TCP connection limit | M7 |
| 17 | DNS | The LocalDNS mode for each node pool is set explicitly, especially before upgrading to 1.37 | M7 |
| 18 | DNS | Private endpoint zones are linked to the VNet doing the resolution. Policies auto-register records. | M7 |
| 19 | Observability | LB and NAT GW SNAT metrics, CoreDNS and LocalDNS metrics, and ingress access logs are connected to monitoring and alerting | M3/M5/M7 |
| 20 | IaC | All of the network parameters above are written in IaC (explicit networkPluginMode, outboundType, and so on), not left to defaults | All |
Why
Network design decisions (IPAM mode, Pod CIDR, API server access) are mostly impossible to change after creation, or can only be changed in one direction. Reworking them after launch means rebuilding the cluster. The review moves troubleshooting from after launch to design time.
How: Outside in, verifying hop by hop
- Name: Does it resolve? Which IP does it return? (
dig. Check the Server field to tell whether LocalDNS or kube-dns answered.) - Entry point: Gateway or Ingress status, the load balancer frontend IP, and health probes (
kubectl describe gateway, LB metrics) - Service: Does the EndpointSlice have ready endpoints? (
kubectl get endpointslice,cilium-dbg service list) - Policy: Is traffic being dropped? (
cilium-dbg monitor --type drop) - Azure networking: NSG effective rules, effective routes (
az network nic show-effective-route-table), and NAT or SNAT metrics - Destination: Does the remote firewall or allow list recognize your egress IP?
When
Run the design review for new clusters, before Kubernetes minor version upgrades (especially the LocalDNS changes in 1.37), before changes to the egress or ingress approach, and run a compliance review once a quarter.
Comparison with similar practices
| This hour's review checklist | Azure Well-Architected AKS service guide | AKS baseline reference architecture | |
|---|---|---|---|
| Purpose | Check off each item before launch | Design recommendations across the five pillars | Deployable hub-spoke reference implementation |
| Recommendation | Combine all three: start from the reference architecture, use the WAF guide to make trade-offs, and use the checklist as the launch gate | ||
nc -zv, curl). ③ “The Service CIDR exists only inside the cluster and has nothing to do with the enterprise network.” If an address range in the enterprise network overlaps with the Service CIDR, Pods can't reach it.Overview: all of this hour's components on one diagram
Failure map: symptom → most likely layer
Interactive review scorer: run a network readiness review on your cluster
Check the boxes that match your situation. Each item has a weight, and design items that are hard to change after creation carry higher weights. The scorer shows the score, risk level, and a remediation list sorted by priority in real time, and generates a Markdown summary you can paste into a ticket. Check states are saved in this browser.
Hop-by-hop troubleshooting commands
| Layer | Command | What to look at |
|---|---|---|
| Cluster configuration | az aks show --query networkProfile | Mode, data plane, CIDRs, outbound type |
| Name | kubectl exec … -- nslookup / dig | Server field, NXDOMAIN, timeouts |
| Ingress | kubectl describe gateway/httproute | Accepted and Programmed conditions |
| Service | kubectl get endpointslice -l kubernetes.io/service-name=X | Ready endpoints |
| Policy | cilium-dbg monitor --type drop | Policy denied |
| Node network | kubectl debug node/N -it --image=… | Capture packets and run dig in the node's namespace |
| Azure routing | az network nic show-effective-route-table | 0.0.0.0/0 next hop |
| NSG | az network nic list-effective-nsg | Deny rule hit |
| Outbound capacity | az monitor metrics list --metric SnatConnectionCount | Failed dimension |
| Subnet capacity | az network vnet subnet show --query "length(ipConfigurations)" | Used IPs vs. prefix |
One-click network health check script (read-only)
#!/usr/bin/env bash
# Usage: RG=rg-aks-lab C=aks-lab-net ./aks-net-check.sh
set -u
echo "== networkProfile"
az aks show -g "$RG" -n "$C" --query "networkProfile.{plugin:networkPlugin,mode:networkPluginMode,dataplane:networkDataplane,policy:networkPolicy,pod:podCidr,svc:serviceCidr,outbound:outboundType}" -o table
echo "== apiServerAccessProfile"
az aks show -g "$RG" -n "$C" --query apiServerAccessProfile -o json
echo "== nodes / podCIDR"
kubectl get nodes -o custom-columns=NAME:.metadata.name,IP:.status.addresses[0].address,PODCIDR:.spec.podCIDR
echo "== system pods not Running"
kubectl -n kube-system get pod --field-selector=status.phase!=Running
echo "== gateways / ingresses"
kubectl get gateway,httproute -A 2>/dev/null; kubectl get ingress -A
echo "== policies"
kubectl get netpol,cnp,ccnp -A 2>/dev/null | head -30
echo "== DNS test"
kubectl run dnscheck --rm -i --restart=Never --image=busybox:1.36 -- nslookup kubernetes.default 2>/dev/null | head -4
== networkProfile Plugin Mode Dataplane Policy Pod Svc Outbound -------- ------- ----------- -------- -------------- ------------ ---------------------- azure overlay cilium cilium 192.168.0.0/16 10.0.0.0/16 userAssignedNATGateway ... == DNS test Server: 169.254.10.10 Address 1: 169.254.10.10
Note: The script is read-only and doesn't change any resources. busybox must be able to pull from Docker Hub; in restricted environments, replace it with a debug image from ACR.
View the effective routes and NSG for the node NIC
NODE_RG=$(az aks show -g $RG -n $NETCLUSTER --query nodeResourceGroup -o tsv) VMSS=$(az vmss list -g $NODE_RG --query "[0].name" -o tsv) az vmss nic list -g $NODE_RG --vmss-name $VMSS --query "[0].id" -o tsv # For VMSS instance NICs, view the effective routes and NSG in the portal under “Network interface → Effective routes / Effective security rules”; # or use Network Watcher: az network watcher show-next-hop -g $NODE_RG --vm <vmss-instance-id> --source-ip 10.10.0.4 --dest-ip 8.8.8.8
CLI support for effective routes on VMSS instance NICs varies by resource type, so check az network watcher show-next-hop --help and the portal for the current behavior.
Lab 8: Fault injection and repair (about 10 minutes)
aks-lab-net, and repair them in strict order. NSGs are free.az network nsg create -g $RG -n nsg-snet-nodes
az network nsg rule create -g $RG --nsg-name nsg-snet-nodes -n deny-pod-cidr --priority 200 \
--source-address-prefixes 192.168.0.0/16 --destination-address-prefixes 192.168.0.0/16 \
--access Deny --protocol '*' --destination-port-ranges '*'
az network vnet subnet update -g $RG --vnet-name $VNET -n snet-nodes --network-security-group nsg-snet-nodes
kubectl -n myapp exec deploy/myapp -- python -c "import socket;socket.create_connection(('redis',6379),3);print('ok')"
If myapp and redis are on different nodes, the connection times out. On the same node, it succeeds. This is the classic symptom of “can only reach Pods on the same node.”
az network nsg rule create -g $RG --nsg-name nsg-snet-nodes -n allow-pod-pod --priority 100 \ --source-address-prefixes 192.168.0.0/16 --destination-address-prefixes 192.168.0.0/16 \ --access Allow --protocol '*' --destination-port-ranges '*' az network nsg rule create -g $RG --nsg-name nsg-snet-nodes -n allow-node-pod --priority 110 \ --source-address-prefixes 10.10.0.0/22 --destination-address-prefixes 192.168.0.0/16 \ --access Allow --protocol '*' --destination-port-ranges '*'
kubectl -n myapp delete networkpolicy allow-dns-coredns
kubectl -n myapp delete cnp allow-localdns
kubectl -n myapp exec deploy/myapp -- python -c "import socket;print(socket.gethostbyname('redis'))"
socket.gaierror: [Errno -3] Temporary failure in name resolution
Fix: kubectl apply -f np-baseline.yaml (Module 6).
nc -zv 10.0.5.20 1433 from myapp? — 10.0.5.20 falls within the Service CIDR 10.0.0.0/16, so Cilium treats it as a cluster Service address (and drops it if no matching Service exists). It never reaches on-premises. This kind of problem can only be fixed by re-planning the CIDR (building a new cluster), so item 2 in the review carries the highest weight.aks-net-check.sh from the “Commands” tab, compare its output with the review scorer on the “Animation” tab, and record your score.az network vnet subnet update -g $RG --vnet-name $VNET -n snet-nodes --network-security-group "" az network nsg delete -g $RG -n nsg-snet-nodes
Case 1: The review stopped a launch that used default values
Problem: A team built a production cluster with portal defaults: Overlay (default Pod CIDR 10.244.0.0/16), LB outbound with automatic ports, a public API server, application routing NGINX, and no policies. Review findings: the enterprise network uses part of 10.244.0.0/16 (item 2), the ingress depends on a retired component (item 11), and there is no default deny (item 14). Action: Rebuild before launch: Pod CIDR 192.168.0.0/16, NAT Gateway, VNet-integrated API server in private mode, application routing Gateway API, and a default-deny policy template. Write all of it into Terraform (see the Terraform course). Limitation: Rebuilding is only acceptable before launch.
Case 2: Subnet IP exhaustion stalls an upgrade
Problem: A Node Subnet (legacy) cluster uses a /24 subnet. 30 nodes × (30+1) = 930 reserved addresses already exceed it. During the upgrade, the surge nodes couldn't get IPs, and the upgrade failed. Action: Short term, lower maxSurge to 1 and clean up idle nodes. Long term, migrate to Overlay (one-time); the node subnet then needs only node IPs. Limitation: The migration reimages all node pools and needs a maintenance window.
Case 3: The Monday morning peak incident, caused by DNS and SNAT together
Problem: At the Monday morning peak, many Pods rebuilt connections at the same time. DNS query amplification (ndots) plus insufficient SNAT on the LB outbound path caused widespread 5-second delays and connection failures. Action: Separate the two problems hop by hop. On the DNS side, enable LocalDNS and adjust ndots. On the outbound side, move to a NAT Gateway. In monitoring, add alerts for SNAT failures and DNS latency. Limitation: When several factors stack up, a single metric can lead to a wrong diagnosis, so watch DNS and SNAT metrics together.
Interactive troubleshooting tree: AKS networking faults
Start from the symptom and choose each next step. The tree ends with a diagnostic command and a fix.
Quick error reference
SubnetIsFull / Subnet ... does not have enough capacity for N IP addresses
Cause: Not enough addresses in the node subnet (in Node Subnet mode, Pods also use it). This is common during upgrade surge or scale-out.
az network vnet subnet show -g $RG --vnet-name $VNET -n snet-nodes --query "{prefix:addressPrefix, used:length(ipConfigurations)}"
Fix: Lower maxSurge, or add a node pool in a new subnet. Long term, migrate to Overlay.
dial tcp: lookup … on 10.0.0.10:53: read udp …: i/o timeout
Cause: CoreDNS is unreachable: policy, an NSG that blocks the Pod CIDR, or an unhealthy CoreDNS Pod.
Fix: See the “DNS” branch of the troubleshooting tree.
Service EXTERNAL-IP stays at <pending>
Cause: The cluster identity lacks permissions (BYO subnet or public IP), the public IP name or resource group in the annotation is wrong, or quota is insufficient.
kubectl describe svc <svc> | sed -n '/Events/,$p'
Fix: Based on the error in the events, grant the missing permission or correct the annotation.
1. Find the number of IP configurations currently in use in the node subnet, and its prefix.
az network vnet subnet show -g $RG --vnet-name $VNET -n snet-nodes --query "{prefix:addressPrefix, used:length(ipConfigurations)}" -o table2. On the node where redis runs, view packets dropped by policy in real time.
NODE=$(kubectl -n myapp get pod -l app=redis -o jsonpath='{.items[0].spec.nodeName}')
CP=$(kubectl -n kube-system get pod -l k8s-app=cilium --field-selector spec.nodeName=$NODE -o name)
kubectl -n kube-system exec $CP -c cilium-agent -- cilium-dbg monitor --type dropNew cluster review: Overlay + Cilium, Pod CIDR 10.244.0.0/16, Service CIDR 10.0.0.0/16, default LB outbound, public API server, application routing NGINX, no policies, hub custom DNS that allows only UDP 53, and a planned upgrade to 1.37. List the remediation items in priority order.
P0 (hard to change after creation): Confirm that 10.244/16 and 10.0/16 don't overlap the hub or on-premises networks. If they do, replace the CIDRs and rebuild now. Choose VNet-integrated private mode for the API server when you create the cluster. P1 (blocks launch): Allow TCP 53 on the hub DNS (in 1.37, LocalDNS defaults to Preferred), or set the LocalDNS mode on the node pool explicitly. Move ingress to application routing Gateway API or AGC (NGINX support runs until 2026-11). Use default deny in business namespaces, with DNS/LocalDNS allowed. P2: Move outbound to a NAT Gateway, or set the ports explicitly. Add SNAT and DNS monitoring alerts. Write all parameters into IaC.
Verified teaching videos
Official documentation
- CNI networking prerequisites (reserved ranges, permissions, NSGs)
- Well-Architected: AKS service guide
- AKS baseline reference architecture
- AKS troubleshooting documentation
Video storyboard (about 90 seconds)
This lesson can't generate a video or MP3 directly. A storyboard and narration script are provided for a video tool to produce them.
Visual: A review checklist. Twenty checkboxes are checked or marked red, one after another.
Narration: Most network design choices can't be changed after creation, so review them before launch.
Visual: A request travels from the user to the Pod. Six checkpoints light up in turn: name, ingress, Service, policy, Azure networking, and destination.
Narration: When you troubleshoot, work from the outside in and verify each hop. Every hop has a matching command.
Visual: Four symptom cards flip over. The backs show DNS, SNAT, NSG, and CIDR overlap.
Narration: These four symptoms cover most AKS network incidents.
Visual: All the settings flow into an IaC file icon.
Narration: Finally, write every network parameter into infrastructure code. Don't rely on defaults.
Command cheat sheet
Create: Overlay + Cilium + BYO VNet
az aks create -g $RG -n $C -l $LOC \ --network-plugin azure --network-plugin-mode overlay --network-dataplane cilium \ --pod-cidr 192.168.0.0/16 --service-cidr 10.0.0.0/16 --dns-service-ip 10.0.0.10 \ --vnet-subnet-id $SUBNET_ID --assign-identity $ID_RES \ --outbound-type userAssignedNATGateway \ --enable-apiserver-vnet-integration --apiserver-subnet-id $APISERVER_SUBNET_ID \ --enable-private-cluster --generate-ssh-keys
View and migrate the network model
az aks show -g $RG -n $C --query networkProfile -o json kubectl get nodes -o custom-columns=N:.metadata.name,CIDR:.spec.podCIDR # kubenet / Node Subnet → Overlay (irreversible) az aks update -g $RG -n $C --network-plugin azure --network-plugin-mode overlay --pod-cidr 192.168.0.0/16 # Data plane → Cilium (separate operation) az aks update -g $RG -n $C --network-dataplane cilium
Cilium troubleshooting
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status --brief kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg service list kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg endpoint list kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg monitor --type drop kubectl get netpol,cnp,ccnp -A
Outbound
az network lb outbound-rule list -g $NODE_RG --lb-name kubernetes -o table az aks update -g $RG -n $C --load-balancer-outbound-ports 4000 --load-balancer-managed-outbound-ip-count 3 az aks update -g $RG -n $C --load-balancer-idle-timeout 4 az aks update -g $RG -n $C --outbound-type userAssignedNATGateway # BYO VNet az aks update -g $RG -n $C --outbound-type managedNATGateway --nat-gateway-managed-outbound-ip-count 2 # managed VNet kubectl exec POD -- curl -s https://ifconfig.me # Capacity: 64000 / ports per node × IP count = max nodes (including surge)
Control plane access
az aks update -g $RG -n $C --enable-apiserver-vnet-integration --apiserver-subnet-id $APISERVER_SUBNET_ID az aks stop -g $RG -n $C && az aks start -g $RG -n $C # required after the conversion az aks update -g $RG -n $C --enable-private-cluster az aks update -g $RG -n $C --disable-private-cluster # preview az aks update -g $RG -n $C --api-server-authorized-ip-ranges 203.0.113.0/24 az aks command invoke -g $RG -n $C --command "kubectl get pods -A"
Ingress
az aks update -g $RG -n $C --enable-gateway-api --enable-app-routing-istio # CLI ≥ 2.86
kubectl get gatewayclass
kubectl wait --for=condition=programmed gateways.gateway.networking.k8s.io/G -n NS
kubectl get gateway G -n NS -o jsonpath='{.status.addresses[0].value}'
kubectl get ingress -A -o custom-columns=NS:.metadata.namespace,N:.metadata.name,CLASS:.spec.ingressClassName
ingress2gateway print --providers=ingress-nginx -A
az aks update -g $RG -n $C --enable-gateway-api --enable-application-load-balancer # AGC add-on (preview)DNS
kubectl exec POD -- cat /etc/resolv.conf kubectl -n kube-system get cm coredns-custom -o yaml kubectl -n kube-system rollout restart deployment coredns az aks nodepool update -g $RG --cluster-name $C -n NP --localdns-config ./localdnsconfig.json az aks nodepool upgrade -g $RG --cluster-name $C -n NP --node-image-only # after VNet DNS changes dig +udp @DNS fqdn; dig +tcp @DNS fqdn
Azure networking resources
az network vnet subnet show -g $RG --vnet-name $VNET -n snet-nodes --query "{p:addressPrefix,used:length(ipConfigurations)}"
az network vnet subnet create … --delegations Microsoft.ContainerService/managedClusters # API Server /28
az network vnet subnet create … --delegations Microsoft.ServiceNetworking/trafficControllers # AGC /24
az network private-dns link vnet create -g $RG -z ZONE -n LINK -v $VNET -e false
az graph query -q "Resources | where type =~ 'microsoft.containerservice/managedclusters' | project name, properties.networkProfile.networkPlugin, properties.networkProfile.networkPolicy"Quick troubleshooting table
| Symptom | Most likely cause | First command | Fix direction |
|---|---|---|---|
| Temporary failure in name resolution | Policy doesn't allow DNS / TCP 53 to the LocalDNS upstream is blocked | nslookup kubernetes.default | Allow kube-dns and 169.254.10.0/24; open TCP 53 on the DNS server |
| Can only reach Pods on the same node | NSG blocks the Pod CIDR (Overlay doesn't encapsulate) | az network nsg rule list | Allow node↔node, node→Pod, and Pod↔Pod |
| Intermittent external call timeouts during peak hours | LB SNAT port exhaustion | LB metric SnatConnectionCount (Failed) | Explicit ports/IPs, NAT Gateway, connection reuse |
| An enterprise network segment is unreachable | Overlaps with the Pod or Service CIDR | az aks show --query networkProfile | Re-plan the CIDR (build a new cluster) |
| kubectl no such host / i/o timeout | Private zone not linked / no network path | nslookup <privateFqdn> | Link the zone, conditional forwarding, command invoke |
| logs/exec reports error dialing backend | VNet integration NSG doesn't allow 10250 | NSG effective rules | API server subnet → node subnet TCP 10250 |
| Gateway Programmed=False | Leftover Istio CRDs, CLI version, wrong class name | kubectl describe gateway | Clean up CRDs, upgrade the CLI, verify gatewayClassName |
| Nodes NotReady after switching the UDR | Firewall doesn't allow required outbound traffic | kubectl describe node | FQDN tag AzureKubernetesService |
| Private endpoint resolves to a public IP | Zone not linked to the VNet doing the resolution | dig +short <fqdn> | Link the hub / DNS Private Resolver |
Recommended configuration snippets
Namespace network baseline (Cilium)
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny-all }
spec: { podSelector: {}, policyTypes: [Ingress, Egress] }
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: allow-dns-coredns }
spec:
podSelector: {}
policyTypes: [Egress]
egress:
- to:
- namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: kube-system } }
podSelector: { matchLabels: { k8s-app: kube-dns } }
ports: [{ port: 53, protocol: UDP }, { port: 53, protocol: TCP }]
---
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata: { name: allow-localdns }
spec:
endpointSelector: { matchLabels: {} }
egress:
- toCIDR: ["169.254.10.0/24"]
toPorts: [{ ports: [{ port: "53", protocol: UDP }, { port: "53", protocol: TCP }] }]
- toEntities: [host]
toPorts: [{ ports: [{ port: "53", protocol: UDP }, { port: "53", protocol: TCP }] }]Gateway API ingress (application routing)
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata: { name: myapp-gw, namespace: myapp }
spec:
gatewayClassName: approuting-istio
listeners:
- name: http
port: 80
protocol: HTTP
allowedRoutes: { namespaces: { from: Same } }
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: myapp, namespace: myapp }
spec:
parentRefs: [{ name: myapp-gw }]
hostnames: ["myapp.example.com"]
rules:
- matches: [{ path: { type: PathPrefix, value: / } }]
backendRefs: [{ name: myapp, port: 80 }]
Pod-level DNS optimization
spec:
dnsConfig:
options:
- name: ndots
value: "2"Capstone lab + final quiz
rg-aks-lab / aks-lab-net (if already deleted, rebuild it following Module 0).az network vnet show -g $RG -n $VNET --query addressSpace.addressPrefixes -o tsv az aks show -g $RG -n $NETCLUSTER --query "networkProfile.[podCidr,serviceCidr,dnsServiceIp,networkPluginMode,networkDataplane]" -o tsv
Compare the results with the enterprise IPAM. Confirm that 10.10.0.0/16, 192.168.0.0/16, and 10.0.0.0/16 are not used in the hub or on-premises networks, and record the result in the review log.
az aks show -g $RG -n $NETCLUSTER --query networkProfile.outboundType -o tsv # expected userAssignedNATGateway
az network nat gateway show -g $RG -n natgw-aks-lab --query "{sku:sku.name, ips:publicIpAddresses[].id}" -o json
kubectl -n myapp run egress --image=mcr.microsoft.com/azurelinux/base/core:3.0 --restart=Never --command -- sleep 600
kubectl -n myapp exec egress -- sh -c "tdnf install -y curl >/dev/null 2>&1; curl -s https://ifconfig.me"
The egress IP must equal the NAT Gateway public IP. Note: the default-deny policy from Module 6 blocks outbound traffic from the egress Pod. This is expected! Add a CiliumNetworkPolicy that allows only TCP 443 to world (toEntities: [world]), then test. Delete the Pod and the policy after testing.
az aks show -g $RG -n $NETCLUSTER --query "apiServerAccessProfile.{vnet:enableVnetIntegration, private:enablePrivateCluster, zone:privateDnsZone}" -o table
az aks update -g $RG -n $NETCLUSTER --enable-private-cluster --enable-apiserver-vnet-integration --apiserver-subnet-id $APISERVER_SUBNET_ID
az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl get nodes"
Run the later kubectl commands with command invoke, or from inside the VNet through Bastion or a jump box.
approuting-istio is enabled. Deploy myapp-gateway.yaml, switch the Gateway to an internal load balancer (using the official annotation approach), and access it from inside the VNet:
az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl -n myapp get gateway,httproute"
np-baseline.yaml and np-app.yaml. Test matrix: gateway→myapp allowed, myapp→redis allowed, other Pods→redis denied, and DNS working for all Pods.
az aks command invoke -g $RG -n $NETCLUSTER --command "kubectl get netpol,cnp -n myapp"
dig +udp and +tcp. In myapp, verify the Server field of nslookup redis. Record your conclusion (enabled or disabled, and why) in the review log.aks-net-check.sh (through command invoke or a jump box) and attach the output to the review log.az aks delete -g $RG -n $NETCLUSTER --yes --no-wait az network nat gateway delete -g $RG -n natgw-aks-lab # detach the subnet association first, or run this after the cluster is deleted az network public-ip delete -g $RG -n pip-natgw-aks-lab # hour 3 still needs rg-aks-lab and the aks-lab from hour 1; if everything is finished: # az group delete -n $RG --yes --no-wait
Open-ended self-check (answer on your own first, then expand the reference answer)
1. When a Pod reaches the internet, how many times does the packet's source address change? Who makes each change?
Twice. (1) When leaving the Pod CIDR, the Azure CNI or Cilium on the node SNATs the Pod IP to the node's primary IP. (2) When leaving the VNet, the outbound type does the translation: the load balancer outbound rule, NAT Gateway, or firewall converts the node IP to a public IP. Return traffic is reverse-translated twice by connection tracking.
2. Why does the subnet NSG affect Pod-to-Pod communication in Overlay mode?
Azure CNI Overlay doesn't encapsulate Pod traffic. Cross-node packets are forwarded with Pod IPs inside the Azure network routing domain, and subnet NSG rules apply to them. So when an NSG has deny rules, allow node↔node, node→Pod CIDR, and Pod CIDR↔Pod CIDR.
3. What is the core difference between a private cluster and API server VNet integration?
A private cluster places a private endpoint in your subnet through Private Link, and the API server stays in the managed VNet. VNet integration places the API server's internal load balancer directly in your delegated subnet (starting at /28). Nodes connect to it directly by IP, with no tunnel, and you can turn public access on or off after creation. Converting to VNet integration is one-way and needs a manual restart.
4. What does the retirement of Ingress-NGINX mean for a team that uses the application routing add-on?
Application routing NGINX is based on the retired ingress-nginx, and Microsoft provides only critical security patches through November 2026. The team needs to migrate to application routing Gateway API (approuting-istio) or AGC. If advanced capabilities are required, use Gateway API with the Istio add-on. The Ingress API itself isn't deprecated, and AGC also supports Ingress, but AKS uses Gateway API as the long-term standard.
5. After you enable Cilium, which network policy patterns need to change?
ipBlock can't select Pod or node IPs, so pair it with podSelector or namespaceSelector, or use Cilium entities (host, remote-node, world). hostNetwork Pods are not subject to policy. LocalDNS requires allowing 169.254.10.0/24 and port 53 on the host. FQDN and L7 policies require ACNS.
6. Before you upgrade the cluster to 1.37, what should you check for DNS?
LocalDNS is enabled in Preferred mode on eligible node pools that have no explicit profile. Check each node pool's profile. Verify that the custom DNS allows UDP and TCP 53 to the nodes, with no TCP connection limit. Check that network policies allow LocalDNS. Don't run it alongside NodeLocal DNSCache. Set node pools that aren't ready to Disabled explicitly first.
Final quiz (12 questions, covering all modules)
Sources and versions
| Topic | Verified conclusion | Source |
|---|---|---|
| Network model | Two model types, Overlay and Flat. IPAM and the data plane are independent. kubenet retires on 2028-03-31. Reserved ranges: 169.254.0.0/16, 192.0.2.0/24, 172.30.0.0/16, 172.31.0.0/16. A BYO VNet cluster identity needs Network Contributor. The node subnet can't be a delegated subnet. CNS sends telemetry to Microsoft Application Insights by default. | CNI networking in AKS (page updated 2026-07-31) |
| Azure CNI Overlay | A fixed /24 per node. maxPods default and maximum 250, minimum 10 (Windows recommended ≤110). Overlay supports 5000 nodes, kubenet 400 nodes. No encapsulation and no UDR. Source NAT to the node's primary IP when leaving the Pod CIDR. Three allow rules for the NSG. Service CIDR must be smaller than /12. Only Linux clusters can extend the Pod CIDR to a superset. Default Pod CIDR 10.244.0.0/16. If you don't specify --network-plugin, Overlay is the default. Specifying only azure without a mode gives Node Subnet. Azure NPM stops support on Windows on 2026-09-30 and on Linux on 2028-09-30. | Overview of Azure CNI Overlay · Configure Azure CNI Overlay |
| Cilium | Can be configured as Overlay, Pod Subnet, or Node Subnet. Minimum version table (1.34/1.35 → 1.18.12, 1.36 → 1.19.6, 1.37 not listed). Linux only. ipBlock can't select Pod or node IPs. hostNetwork Pods are not subject to policy. Identity limit 65535. cilium-config supports only label exclusion. kube-proxy is not run. NAP clusters must first disable NAP. FQDN, L7, flow logs, and WireGuard require ACNS. LocalDNS allow-policy example (169.254.10.0/24 + host). | Configure Azure CNI Powered by Cilium (updated 2026-08-24) |
| Migration | IPAM can only be migrated one way, to Overlay (from kubenet or Node Subnet). The cluster must be ≥ 1.27 with no network policies, and kubenet needs a user-assigned identity. The Cilium data plane can be upgraded from any Azure CNI IPAM, but not in the same operation as the IPAM migration. All pools are reimaged at the same time. | Update Azure CNI IPAM mode and data plane |
| Outbound type | loadBalancer / managedNATGateway / userAssignedNATGateway / userDefinedRouting / none. block (preview). From 2026-03-31, VMs no longer get default outbound access (subnets in the managed VNet are private by default; BYO is not affected). From API 2026-06-01, managedNATGateway defaults to StandardV2, which can be upgraded but not downgraded. Migration matrix. Updates need CLI ≥ 2.56. For non-private clusters, API server traffic goes through the outbound type. | Customize cluster egress with outbound types (updated 2026-10-08) |
| NAT Gateway | 64,512 flows per IP, up to 16 IPs. --nat-gateway-managed-outbound-ip-count 1–16. StandardV2 requires StandardV2 public IPs. Managed NAT Gateway is incompatible with a custom VNet. Windows OutboundNAT port notes (LB 64, firewall 2,496/IP, NAT GW 64,512/IP). | Managed or user-assigned NAT gateway |
| Load balancer outbound | AllocatedOutboundPorts defaults to 0 (≤50 nodes: 1024 per node). Ports are multiples of 8. Formula: 64,000 / ports × IPs. AKS outbound idle timeout is 30 minutes, and TCP Reset is on by default. Inbound annotation idle timeout: default and minimum 4, maximum 100. Up to 100 managed outbound IPs. Basic SKU retired on 2025-09-30. | Configure a public standard load balancer · Use a public standard load balancer |
| API server VNet integration | Delegates Microsoft.ContainerService/managedClusters, minimum /28, and keeps at least 9 IPs. CLI ≥ 2.73. Conversion is one-way and needs a manual stop and start. Capacity is only validated, not reserved. The API server IP changes. --disable-private-cluster is in preview. NSG ports 443/4443, 10250, and 9988. VNet encryption is not supported (v4+ node SKUs are blocked). Not available in qatarcentral. Preconfigured for AKS Automatic. | API Server VNet Integration (updated 2026-11-06) |
| Private cluster | --private-dns-zone: system, none, or custom. Regional format privatelink.<region>.azmk8s.io (private.<region>.azmk8s.io with VNet integration). A custom zone needs Private DNS Zone Contributor and Network Contributor. none and disable-public-fqdn can't be used together. Microsoft-hosted Azure DevOps agents are not supported. Authorized IP ranges apply only to the public endpoint. UDP/TCP note for LocalDNS in 1.37. | Create a private AKS cluster (updated 2026-10-20) |
| Application routing | ingress-nginx maintenance ended in March 2026. Application routing NGINX gets critical security patches through November 2026. Ingress class webapprouting.kubernetes.azure.com. Up to 5 DNS zones. Snippet blocklist. Multi-tenant warning. Gateway API implementation: GatewayClass approuting-istio, CLI ≥ 2.86, --enable-gateway-api --enable-app-routing-istio. Mutually exclusive with the Istio add-on. HPA 2–5 and PDB. Default for AKS Automatic 1.36+. | App routing NGINX (updated 2026-10-27) · App routing Gateway API (updated 2026-11-06) · AKS blog 2025-11-13 |
| Application Gateway for Containers | The ALB Controller implements Gateway API v1.6. Components: frontend, association, security policy. The association subnet is at least /24, delegated to Microsoft.ServiceNetworking/trafficControllers, and currently limited to 1. Associations created after 2026-04-23 fully support NSGs. The frontend listens only on 80/443. Default timeouts. Inserts x-forwarded-for, x-forwarded-proto, and x-request-id. Available in Canada Central. AKS add-on in preview (--enable-application-load-balancer). | AGC overview · AGC components · ALB Controller add-on quickstart |
| Network policy | Comparison of the three engines. Azure NPM limits: 250 nodes / 20,000 Pods, no IPv6. Calico supports only networking.k8s.io policies. To switch engines, set none first. For LoadBalancer scenarios, use loadBalancerSourceRanges. | Secure pod traffic with network policies (updated 2026-10-20) |
| DNS | coredns-custom key names: .server or .override. Built-in plugins only. rollout restart. LocalDNS 169.254.10.10/11. Mode table. From 1.37, AKS Standard defaults to Preferred with compatibility checks. Validation rules. Metrics port 9253. ≥4 vCPU. CLI ≥ 2.80. VNet DNS changes need a node image upgrade. Cache: 256 shards / 10,000 entries. | Customize CoreDNS · Configure LocalDNS (updated 2026-10-07) |
| Upstream Ingress-NGINX | Retirement announced 2025-11, archived 2026-03, final release v1.15.1. ingress2gateway 1.0 supports 30+ annotations. The Ingress API is still GA. | kubernetes.dev announcement (consistent with the verified conclusions in the Kubernetes lesson) |
Video verification notes
The following videos were checked through the YouTube oEmbed API (2026-11-15) for matching titles and channels: John Savill's Technical Training, “Azure Kubernetes Service (AKS) Networking Deep Dive” (6TZsd4toIbg), “AKS Networking Update - Control plane, nodes and pod networking options!” (54y986U1uYM), “NAT and NAT Gateway in Azure” (c685a1CiaIs), and “NAT Gateway v2 Overview” (I9HPGJUjq2Q); eBPF & Cilium Community, “eCHO Episode #70: Azure CNI Powered by Cilium” (8it8Hm2F_GM) and “eCHO Episode 137: A Review of Cilium Network Policy” (2XisJm0e8fc); Houssem Dellai, “AKS Egress Traffic and Outbound Types” (V2E1WNR-4KM), “Access to AKS control plane (public, private, vnet integration)” (8e8vBLZiIhQ), “App Routing, the best AKS feature ?” (TOBGA-ztINM), “Better DNS for your AKS clusters” (VtffOXINAdE), and “Top AKS mistake ! CIDR IP overlapping!” (3WD5DeCXjws); Azure Power Lunch, “Azure Kubernetes Service cluster with API Server VNet Integration (Preview)” (WO6LvQFvBUI) and “Ingress with the Kubernetes Gateway API via the application routing add-on (preview)” (TjPaohbTKAM); Programming with Wolfgang, “AKS Application Gateway for Containers Addon - Part 18” (5arGrivpen8); That DevOps Guy, “How I would migrate from Ingress NGINX to Gateway API” (7CaDvoKO9wo); DevOps & AI Toolkit, “Kubernetes Network Policies Explained” (18FEA5xXBGY). The oEmbed endpoint doesn't return durations or publish dates, so the cards don't list specific durations. Videos labeled “Preview” were recorded during the preview period. All videos are in English and were recorded before this lesson's verification date. For the current status, follow this lesson and the official documentation.
Voice narration notes
The Voice tab uses the browser's Web Speech API (speechSynthesis, en-US) to read the narration script aloud in real time. English terms are pronounced with en-US. Results depend on the voices installed on the operating system (for example, an English voice on Windows or macOS). This course build environment can't call a TTS service, so no MP3 is embedded. If you need offline audio, give the narration script to a TTS service such as Azure AI Speech.
Known limitations
- Lab commands were not run in a real subscription: All “expected output” examples were built from the official documentation. Node names, IPs, public IPs, image tags, timestamps, and counts depend on your environment.
- The minimum Cilium version for Kubernetes 1.37 on AKS was not yet listed in the official table as of the verification date. The Cilium image path and version in the sample output are illustrative only.
- The CLI
--skusyntax for StandardV2 NAT Gateway and public IPs is inconsistent in the official examples (StandardV2/standard-v2). Follow--help. Some regions don't support StandardV2 yet. - Whether the LocalDNS node pool property name (such as
localDnsProfile) and a minimal config file containing onlymodeare accepted has not been verified line by line. Follow the CLI output and validation results. - For the internal load balancer annotation syntax in application routing Gateway API, the
ApplicationLoadBalancerfields for AGC, and the Gateway annotation names, follow the current official documentation. The AGC AKS add-on is still in preview. - The gateway Pod label
gateway.networking.k8s.io/gateway-nameand istiod port 15012 come from Istio's default behavior. They were not verified word for word in the AKS docs, so verify them before rolling out the policy. - For load balancer SNAT metric names and dimensions, use
az monitor metrics list-definitions. Error text (such as the exact wording of InvalidParameter) is illustrative. - The cost figures are rough example estimates. Live prices were not queried, so use the Azure pricing calculator.
- Port numbers, identities, latencies, and times in the animations are illustrative values used to explain the mechanism.