AKS Hour 2: Networking

From “the cluster can be created” to “the network design holds up in review”: IP planning, CNI selection, outbound traffic, the private control plane, ingress, network policy, and DNS
AKS · Kubernetes 1.37Azure CNI OverlayCilium data planeNAT Gateway StandardV2Verified against learn.microsoft.com · 2026-11-15
Overall learning goals
  • 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 CIDR 192.168.0.0/16, Service CIDR 10.0.0.0/16, DNS 10.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-zone and 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 (default Preferred on AKS Standard from 1.37), private DNS zones, and the UDP/TCP 53 requirements for custom DNS servers.

1-hour timetable

#TimeModuleCore contentAnimation / interactionLab (rg-aks-lab · canadacentral)
0Before classWarm-upReuse 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-checkBYO VNet + Overlay + Cilium cluster
100–06Network model selectionOverlay vs Flat, IPAM and data plane separation, kubenet retirement on 2028-03-31, reserved ranges, CIDR planningIP capacity calculator + selection wizardRead the networkProfile of both clusters; kubenet migration drill commands
206–13Azure CNI Overlay and Cilium/24 per node, 250-Pod limit, unencapsulated routing domain, SNAT to node IP, Cilium eBPF (no kube-proxy), ACNSCross-node Pod traffic and SNAT animationObserve Pod IPs, node podCIDRs, and Cilium status
313–21Outbound: LB / NAT Gateway / UDRFive outboundType values, migration matrix, SNAT port formula, NAT Gateway StandardV2 default, UDR + firewall, outbound IP changesCore animation: Pod outbound and inbound packet pathsMigrate LB → userAssignedNATGateway and verify the egress IP
421–28Private clusters and API Server VNet integrationPrivate Link vs delegated-subnet ILB, --private-dns-zone, --disable-public-fqdn, command invoke, NSG portskubectl → API Server path comparisonConvert the lab cluster to VNet integration and enable private mode (optional)
528–35Ingress: application routing and AGCIngress-NGINX retirement impact, application routing NGINX and Gateway API (approuting-istio), AGC (ALB Controller, frontend, association)Inbound request path comparisonExpose myapp with Gateway + HTTPRoute
635–42Network policyCilium / Azure NPM / Calico comparison and retirement, default deny, DNS allow rules, FQDN/L7 (ACNS)Policy simulator: which connections are allowedZero-trust policy for the myapp namespace
742–50DNS and private DNS zonesCoreDNS, coredns-custom, LocalDNS (169.254.10.10/11), ndots, 168.63.129.16, private zones and conditional forwardingFull path of one DNS queryForward custom domains, verify LocalDNS
850–60Network readiness review and common errorsReview checklist, address overlap, SNAT exhaustion, subnet IP exhaustion, NSG false blocks, DNS failuresReview scorer + interactive troubleshooting treeFault injection and fixes
—After classCheat sheet · Capstone labDeliver a “production network baseline” for myappFinal quiz (12 questions)Capstone lab

Knowledge coverage matrix

Target skillsM1M2M3M4M5M6M7M8Key commandsLab
Choose a network model and plan CIDRs✓✓·✓···✓az aks show --query networkProfileModule 0 / 1
Migrate kubenet / upgrade the Cilium data plane✓✓···✓··az aks update --network-plugin-mode overlay, --network-dataplane ciliumM1 drill
Explain Pod outbound SNAT and the inbound path·✓✓·✓··✓curl ifconfig.me, az network lb outbound-rule listM3 egress IP verification
Choose and migrate the outbound type··✓····✓az aks update --outbound-typeLB → NAT GW
Private control plane and API access··✓✓··✓✓--enable-apiserver-vnet-integration, az aks command invokeM4 conversion
Ingress controller selection and Ingress-NGINX migration····✓··✓--enable-gateway-api --enable-app-routing-istioGateway + HTTPRoute
Zero-trust network policy·✓···✓✓✓kubectl get netpol,cnp -ADefault deny + allow rules
DNS customization and private zone resolution···✓·✓✓✓coredns-custom, --localdns-config, digM7 forwarding and LocalDNS
Network troubleshooting··✓✓✓✓✓✓kubectl debug, cilium-dbg, eventsM8 fault injection

What this hour leaves out (and where to learn it)

TopicWhy it is not in this hourWhere to learn it
Kubernetes-generic semantics of Service / Ingress / Gateway API / NetworkPolicyThis hour covers only the AKS implementation and selectionKubernetes 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 topicHour 3
Istio service mesh (sidecars, mTLS, traffic management)This hour uses only its “sidecar-free Gateway API ingress” partAKS Istio add-on documentation
In-depth troubleshooting of SNAT port exhaustion and subnet IP exhaustionM8 in this hour only covers introductory diagnosisHour 7 (troubleshooting and optimization)
Deploy ingress and applications with Helm / GitHub Actions / Azure DevOpsBelongs to the delivery toolchainHelm course Hour 3 · GitHub course · Azure DevOps course
Network observability metrics (Hubble flow logs, container network metrics) into PrometheusBelongs to the monitoring topicPrometheus & Grafana course Hour 3

How to use this course material

10 pages per module
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.
Learning progress
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).
English voice
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.
Version note This hour uses Kubernetes 1.37 on AKS as its baseline. All feature statuses were verified against learn.microsoft.com on 2026-11-15: kubenet retires on 2028-03-31; new clusters default to Azure CNI Overlay when --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.
Prerequisite courses: please complete Hour 1 (cluster design and creation) first. For Kubernetes networking basics, see the Kubernetes 8 + 1 hour course.

Module 0 · Warm-up (planning the VNet and address space)

Reuse the variables from hour 1, write down the address plan first, then use BYO VNet to build a cluster dedicated to networking experiments, aks-lab-net
Before class ≈ 15 min (cluster creation about 8–10 min)az CLI ≥ 2.86 (required for the Gateway API lab)
Prerequisites
  • Completed Hour 1: the resource group rg-aks-lab (canadacentral) exists in your subscription. The hour 1 cluster aks-lab can 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 $ACR in 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)

PurposeNameAddressNotes
VNetvnet-aks-lab10.10.0.0/16Must not overlap the hub, local networks, or peered VNets
Node subnetsnet-nodes10.10.0.0/221024 addresses; Azure reserves 5 per subnet. With Overlay, only nodes and the internal load balancer use addresses.
API Server subnet (module 4)snet-apiserver10.10.4.0/28Delegated to Microsoft.ContainerService/managedClusters; official minimum /28
AGC subnet (module 5, optional)snet-agc10.10.8.0/24Delegated to Microsoft.ServiceNetworking/trafficControllers; each association needs at least 256 addresses
Pod CIDR (Overlay)—192.168.0.0/16Fixed /24 per node → up to 256 nodes; not within the VNet address space
Service CIDR—10.0.0.0/16Only valid inside the cluster; must not overlap the VNet, the Pod CIDR, or peered networks
Cluster DNSkube-dns Service10.0.0.10Within the Service CIDR; cannot use the first address (10.0.0.1 is assigned to the kubernetes Service)
Reserved ranges AKS rejects Pod, Service, and VNet addresses that overlap these ranges: 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
Why it is built this way ① Explicitly specify --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.
Costs, permissions, and risks Estimated costs (check the Azure pricing page for current rates): 2 × D4ds_v5 about 0.4–0.5 USD/hour, plus the Standard load balancer and public IP at about 0.03 USD/hour. The control plane is free on the Free tier. The NAT Gateway in module 3 is billed separately (hourly plus per GB processed). Risk: the cluster API server in this hour is publicly reachable until module 4 (you still need Entra/certificate authentication), so do not deploy sensitive data during the lab. Cleanup: 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.

Environment self-check list

Module 1 · AKS network model selection: Overlay, VNet, and kubenet retirement

00:00 – 06:00 · First decide where Pod IPs come from and whether they can be reached directly from outside. Every other design decision follows from that.
6 minAzure CNI Overlay GA · defaultkubenet retires 2028-03-31★★★★★
Learning objectives
  • 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.
Prerequisite knowledge: the Kubernetes Pod network model (each Pod has one IP, and Pods can reach each other without NAT). Importance: ★★★★★ (most choices cannot be reverted after creation)

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 optionsModelPod IP sourceCan external traffic connect directly to Pods?Status
Azure CNI OverlayOverlayPrivate Pod CIDR, fixed /24 per nodeNo (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 SubnetFlatA dedicated Pod subnet in the VNet (dynamic or static block allocation)Yes; Pod IPs are preserved across peered and on-premises networksRecommended option for the flat model
Azure CNI Node SubnetFlatSame subnet as the nodes, reserved per maxPodsPod IPs are visible inside the VNet; outside the VNet, the node IP is seenLegacy; consider only when you need a managed VNet
kubenetOverlayPrivate CIDR + route table (UDR)NoLegacy, 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

QuestionLeans toward OverlayLeans toward Pod Subnet (Flat)
Is VNet address space tight?Tight → OverlayLarge contiguous ranges available
Do external systems need to connect directly to Pod IPs?No; use Services or ingressYes (on-premises systems calling back, or firewall rules by Pod IP)
Is most traffic inside the cluster or outside it?Inside the clusterExternal resources
Do you need advanced features such as virtual nodes (ACI)?NoYes
ScaleUp to 5000 nodesDepends on subnet size

Comparison with similar technologies

AKS Azure CNI OverlayEKS (VPC CNI default)GKE (VPC-native)
Default Pod IP sourcePrivate Pod CIDR, isolated from the VNetVPC subnet IPs (ENI secondary IPs, Flat)Secondary address range of the subnet (alias IPs)
Ways to save addressesOverlay is the defaultCustom networking / prefix delegationNon-contiguous multiple Pod CIDRs
Cross-node forwardingAzure routing domain, no encapsulationVPC-native routingVPC-native routing
Common misconceptions ① “Overlay is a VXLAN tunnel, so performance is poor.” Azure CNI Overlay does not encapsulate; cross-node traffic is routed directly by Azure's separate routing domain. ② “If you choose Cilium, you must use Overlay.” Cilium is a data plane and can be configured with Overlay, Pod Subnet, or Node Subnet. ③ “The Pod CIDR is used only inside the cluster, so any range will do.” The Pod CIDR must not overlap peered VNets, on-premises networks, or ExpressRoute ranges. Otherwise, packets from Pods to those addresses are treated as Overlay-internal traffic, and the destination is unreachable. ④ “kubenet works until 2028, so there's no rush.” Migration rebuilds (reimages) all node pools, requires a user-assigned identity, and requires uninstalling the network policy engine first. Schedule it early.

Architecture diagram: Overlay and flat within the same VNet

Azure CNI Overlay (vnet-aks-lab 10.10.0.0/16) snet-nodes 10.10.0.0/22 (only nodes use addresses) Node 10.10.0.4podCIDR 192.168.0.0/24Pod .37 .38 .39 … Node 10.10.0.5podCIDR 192.168.1.0/24Pod .12 .25 … Pod CIDR routing domain 192.168.0.0/16 in Azure networkingCross-node Pod→Pod: no encapsulation, no UDR Leaving the cluster (peered VNet / on-premises / internet)Source 192.168.0.37 → SNAT to node 10.10.0.4 Azure CNI Pod Subnet (Flat) snet-nodes 10.20.0.0/24Nodes 10.20.0.4 · 10.20.0.5 snet-pods 10.20.16.0/20 (each Pod uses one VNet address)Pod 10.20.16.7 · 10.20.16.8 · 10.20.17.3 …Dynamic allocation: take addresses from the Pod subnet on demandStatic block allocation: one /28 per node (for large scale; preview and new features, see the documentation for current status) Peered VNet / on-premises see the real Pod IPTwo-way connections; internet egress is still determined by outboundType Both models can layer the Cilium data plane. kubenet (legacy) is similar to Overlay but relies on route tables, and it retires on 2028-03-31
Figure 1-1: Overlay gives VNet addresses only to nodes; Flat makes every Pod a first-class citizen in the VNet

Flowchart: model selection decisions

Do external systems need direct access to Pod IPs?Or do you need virtual nodes? Azure CNI Pod SubnetDo you need large contiguous address blocks? Yes No Existing kubenet / Node Subnet?Existing cluster Migrate to OverlayOne-time, irreversible, reimages all pools Yes No (new cluster) Azure CNI Overlay + CiliumDefault network for AKS Automatic Then: the Pod CIDR must not overlap any connected networkPlan as /24 × maximum number of nodes (including surge) Windows nodes: Overlay is supported (Windows Server 2022/2025), but the Cilium data plane is Linux only
Figure 1-2: first ask whether external systems need direct access to Pods, then handle existing-cluster migration, and only then the CIDR details

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.

Maximum nodes (including the autoscaler limit)
60
maxPods per node
110
Upgrade surge nodes
3

Core commands and parameters

Command / flagPurposeNotes
--network-plugin azure|noneChoose Azure CNI or bring your own CNI (BYOCNI)Defaults to Azure CNI Overlay when omitted; kubenet is already legacy
--network-plugin-mode overlayEnable Overlay IPAMSpecifying only --network-plugin azure and omitting this parameter = Node Subnet
--pod-cidr / --pod-subnet-idPrivate Pod CIDR for Overlay / Pod subnet for Pod Subnet modeOverlay default 10.244.0.0/16
--service-cidr, --dns-service-ipService address range and kube-dns IPThe Service CIDR must be smaller than /12; the DNS IP cannot be the first address
--network-dataplane ciliumUse the Cilium eBPF data planeIndependent of IPAM; replaces the old --enable-ebpf-dataplane
--vnet-subnet-idNode subnet for BYO VNetThe cluster identity needs Network Contributor on the subnet; the subnet cannot be a delegated subnet
az aks update --network-plugin azure --network-plugin-mode overlaykubenet / Node Subnet → OverlayIrreversible; 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)

Read the network configuration: run the 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.
See which Pod segment each node gets:
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).

Confirm the VNet is used only by 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.

Check for reserved-range conflicts: creating a cluster on purpose with a reserved range will be rejected. You only need to see the error; there is no cost.
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.

Use the animated calculator page: enter your production environment's “maximum nodes + surge”, and record the minimum Pod CIDR prefix length that Overlay needs (for example, 300 nodes need /15, or you split the workload across multiple clusters).
Cleanup: this lab creates no persistent resources. Confirm that 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.

Command-line tasks
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 -l
Scenario analysis
A 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

▶
Azure Kubernetes Service (AKS) Networking Deep Dive — John Savill's Technical Training
English · a systematic explanation of kubenet, Azure CNI, and VNet design (recorded before Overlay became the default and before the kubenet retirement announcement; the latest status is in this hour)
▶
AKS Networking Update - Control plane, nodes and pod networking options! — John Savill's Technical Training
English · a summary of updates to control plane, node, and Pod networking options, useful for reviewing modules 1–4

Official 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.

Shot 1 · 0–20s
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.
Shot 2 · 20–45s
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.
Shot 3 · 45–70s
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.
Shot 4 · 70–90s
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.
Or score ≥ 70% on the “Quiz”

Module 2 · Azure CNI Overlay and Azure CNI powered by Cilium

06:00 – 13:00 · Overlay decides the addressing, and Cilium decides the forwarding: a /24 per node, an unencapsulated routing domain, and eBPF in place of kube-proxy
7 minOverlay GA · Cilium GAACNS is a paid add-on★★★★★
Learning objectives
  • 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; ipBlock cannot 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.
Prerequisites: module 1; the role of Kubernetes Services and kube-proxy. Importance: ★★★★★

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 uses 192.168.0.0/16). Each node is assigned a fixed /24 whose 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), and CiliumClusterwideNetworkPolicy, 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)

KubernetesMinimum Cilium version
1.34 / 1.351.18.12
1.361.19.6
1.37The 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.
  • ipBlock in a NetworkPolicy cannot select Pod or node IPs. Even 0.0.0.0/0 blocks Pods and nodes, so you must also add namespaceSelector: {} / podSelector: {}. ipBlock cannot be used to allow node IPs.
  • Pods with hostNetwork: true use 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 CiliumBYOCNI (--network-plugin none)
Service implementationkube-proxyeBPF, no kube-proxyDetermined by the CNI you install
Network policyAzure NPM / CalicoBuilt into CiliumYour responsibility
WindowsSupportedNot supportedDepends on the CNI
Microsoft support scopeFullFull (Cilium components are managed and upgraded by AKS)CNI-related issues are outside the support scope
Common misconceptions ① “In a Cilium cluster, 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

Node aks-nodepool1-…000000 (10.10.0.4, podCIDR 192.168.0.0/24) myapp Podeth0 192.168.0.37identity 18342 redis Podeth0 192.168.0.41identity 40211 eBPF on veth (lxc*): policy decision + Service DNATClusterIP 10.0.x.x → backend Pod IP (lookup in the eBPF LB map) Node NIC eth0 (10.10.0.4) tc eBPFDestination not in 192.168.0.0/16 → source IP masqueraded as 10.10.0.4 kube-system cilium (DaemonSet)cilium-operatorazure-cns (IPAM)coredns / LocalDNSkonnectivity-agentNo kube-proxyACNS: hubble-relay, etc.(present only after enabling) Azure networking stackPod CIDR routing domain: 192.168.1.0/24 → node 10.10.0.5No VXLAN encapsulation, no UDRSubnet NSG applies to Pod traffic Traffic leaving the VNetSource is already the node IP 10.10.0.4Internet: then through LB / NAT GW / UDR Traffic to destinations inside the Pod CIDR keeps the Pod source IP. Only traffic leaving the Pod CIDR is masqueraded.
Figure 2-1: Cilium eBPF handles Service load balancing, policy, and masquerading. Azure networking handles cross-node routing of the Pod CIDR.

Data flow: the source address seen by three destinations

myapp Pod192.168.0.37 redis Pod on another nodeSees source 192.168.0.37 (not translated) VM 10.30.1.4 in a peered VNetSees source 10.10.0.4 (node IP) Internet (ifconfig.me)Sees the outbound public IP (module 3) RuleDestination ∈ Pod CIDR → no SNATDestination ∉ Pod CIDR → SNAT to node IPInternet → then SNAT to the outbound public IP
Figure 2-2: the same packet sent from a Pod has a different source address depending on the destination

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).

myapp Pod192.168.0.37 veth eBPFPolicy + LB Node eth0 eBPF10.10.0.4 Azure networking stackRouting domain / VNet redis Pod192.168.1.25 src 192.168.0.37:43122 → dst 10.0.143.20:6379

Core commands and parameters

CommandPurposeNotes
az aks create … --network-plugin-mode overlay --network-dataplane ciliumCreate a new Overlay + Cilium clusterCLI ≥ 2.48.1; Cilium automatically becomes the policy engine
az aks update --network-dataplane ciliumSwitch an existing Azure CNI cluster to the Cilium data planeIPAM is unchanged; all node pools are reimaged together; not supported for Windows node pools
az aks nodepool add --vnet-subnet-idPut a node pool in a separate subnet in an Overlay clusterUsed to distinguish outbound source IPs by subnet
kubectl -n kube-system exec ds/cilium -- cilium-dbg statusCilium agent health statusFrom Cilium 1.15, the command name inside the container is cilium-dbg
cilium-dbg service list / bpf lb listView the Service → backend mapping in eBPFReplaces iptables -t nat -L from the kube-proxy era
cilium-dbg endpoint list / identity listPod endpoints, identities, and policy enforcement statusAlways 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)

Pod IPs match the node /24:
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.

Access redis across nodes and confirm the source IP is unchanged:
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.

Find the redis Service in eBPF: run 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.
SNAT when leaving the VNet: run 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.
(Optional) Inspect the Azure CNI IPAM components:
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).

Cleanup: 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.

Command-line tasks
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
Scenario analysis
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

▶
eCHO Episode #70: Azure CNI Powered by Cilium — eBPF & Cilium Community
English · Live demo of creating and working with Azure CNI powered by Cilium (recorded early in the feature's life; for versions and limits, follow this hour and the official docs)
▶
AKS Networking Update - Control plane, nodes and pod networking options! — John Savill's Technical Training
English · Overview of Pod networking options (including Overlay and Cilium)

Official 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.

Shot 1 · 0–20s
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.
Shot 2 · 20–45s
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.
Shot 3 · 45–70s
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.
Shot 4 · 70–90s
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.
Or score ≥ 70% on the “Quiz”

Module 3 · Outbound: load balancers, NAT Gateway, and UDR

13:00 – 21:00 · A Pod's packet goes through two address translations before it reaches the internet. The outbound type determines who performs the second one and how many connections it can handle.
8 minloadBalancer / NAT Gateway / UDR GAblock outbound type preview · StandardV2 default (API 2026-06-01)★★★★★
Learning objectives
  • List the 5 outboundType values: loadBalancer, managedNATGateway, userAssignedNATGateway, userDefinedRouting, and none (plus block in preview). Explain the prerequisites and migration path for each.
  • Use the formula 64,000 ports per IP ÷ ports per node × outbound IPs = maximum nodes to 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.
Prerequisite: Module 2's "SNAT to the node IP first." Importance: ★★★★★ (SNAT exhaustion is one of the most common AKS networking incidents)

What: The five outbound types

outboundTypeWho performs the second SNATVNetKey points
loadBalancer (default)The aksOutboundRule outbound rule on the AKS-managed standard load balancer kubernetesManaged or BYODefaults to 1 managed public IP (can be 1–100, or bring your own IPs/prefix); allocatedOutboundPorts=0 means automatic allocation; idle timeout 30 minutes
managedNATGatewayNAT Gateway created and managed by AKSManaged VNet onlyFrom API 2026-06-01, defaults to StandardV2 (zone-redundant, supports IPv6). You can upgrade from Standard to StandardV2, but not downgrade.
userAssignedNATGatewayA NAT Gateway you attach to the node subnet in advanceBYO VNet onlyBoth Standard and StandardV2 are supported. StandardV2 requires StandardV2 public IPs.
userDefinedRoutingYour NVA / Azure FirewallBYO VNetThe subnet route table must have 0.0.0.0/0 pointing to the gateway/NVA. AKS does not create outbound public IPs.
noneNone (you provide the path yourself)BYO or managedOnly for network-isolated clusters; the default route is not validated
block (preview)None; the NSG blocks public outboundManaged VNet onlyNetwork-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 kubernetes load balancer directly in the portal. Cluster reconciliation (stop/start/upgrade/scale) overwrites them. Always use az 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

ScenarioRecommended
Development/testing, low outbound volumeloadBalancer (default), with --load-balancer-outbound-ports set explicitly
Production, heavy outbound connections, fixed egress IP requiredNAT Gateway (managed VNet → managedNATGateway; BYO → userAssignedNATGateway), StandardV2 preferred
Enterprise hub-spoke, all outbound traffic must be audited/filtereduserDefinedRouting → 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 outboundNetwork-isolated cluster + none (BYO) or block (managed, preview)

Comparison with similar technologies

Load balancer outbound rulesNAT GatewayAzure Firewall (UDR)
Port allocationPreallocated per nodeOn demand, 64,512 per IP2,496 per public IP (extensible with NAT GW)
Maximum IPsManaged IPs up to 10016Depends on SKU
Filtering / loggingNoneNone (NAT only)FQDN/network rules, threat intelligence, logs
CostIncluded in the LBHourly + data processedHourly + data processed (highest)
Two changes in 2026(1) Starting 2026-03-31, Azure no longer provides default outbound access to new VMs. New subnets in AKS managed VNets default to private subnets (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.
Common misconceptions(1) "More outbound IPs means more connections per Pod": with the load balancer model, ports per node are fixed. Adding IPs only raises the node limit. (2) "Switching the outbound type is seamless": it changes the egress IP and breaks existing connections. If API Server authorized IP ranges are enabled, you must also add the new egress IP. (3) "A private cluster does not need outbound": nodes still need to reach required endpoints such as MCR, Entra, and package repositories, unless you use a network-isolated cluster. (4) "API Server traffic in a non-private cluster goes over the private network": the official note says that in a non-private cluster, node-to-API Server traffic is handled by the cluster's outbound type. To avoid that, use a private cluster or API Server VNet integration (Module 4).

Architecture diagram: three outbound paths side by side

Pod 192.168.0.37:43122① Leaving Pod CIDR → SNAT to node 10.10.0.4 A. loadBalancerLB outbound rules: preallocated ports per node② SNAT 20.48.1.10:1024–2047 B. NAT GatewaySubnet-level, allocated on demand, 64,512 per IP② SNAT 20.48.9.77: any free port C. userDefinedRoutingRoute table 0.0.0.0/0 → firewall 10.10.6.4② Firewall applies SNAT after checking rules Internet: the destination sees the source as the outbound public IP (A/B) or the firewall public IP (C)Return traffic follows connection tracking back along the same path: public IP → node IP → Pod IP (two reverse translations) When both a NAT Gateway and an LB exist, the NAT Gateway on the subnet takes precedence for outbound traffic (the LB only handles inbound Services) UDR + public LoadBalancer Service = asymmetric routing risk
Figure 3-1: The first SNAT is always "Pod → node IP"; the second SNAT is determined by outboundType

Flowchart: outbound type migration matrix (BYO VNet)

loadBalancer userAssignedNATGateway userDefinedRouting none (isolated cluster) In a BYO VNet, the paths above can all migrate to each other (including none → others); block does not support BYO. Managed VNet: managedNATGateway → loadBalancer is not supported
Figure 3-2: Migration changes the egress IP and breaks existing connections; requires CLI ≥ 2.56

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.

myapp Pod192.168.0.37 Cilium eBPFNode 10.10.0.4 VNet / subnetRouting and NSG Outbound deviceLB outbound rule InternetBackbone network api.github.com140.82.112.6:443 src 192.168.0.37:43122 → dst 140.82.112.6:443 Outbound · loadBalancer conntrack: —
SNAT port capacity calculator (loadBalancer outbound)
Ports per node (multiple of 8, 0 = auto)
Outbound public IPs (1–100)
Node count (including surge)

Core commands and parameters

Command / flagPurposeNotes
--outbound-typeSelect outbound typeSupported for both create and update; update requires CLI ≥ 2.56
--load-balancer-managed-outbound-ip-countNumber of managed outbound public IPsMaximum 100; choose one of this or bring-your-own IPs/prefix
--load-balancer-outbound-portsSNAT ports per nodeMultiple of 8; default 0 (auto)
--load-balancer-idle-timeoutOutbound idle timeout (minutes)AKS default 30
--load-balancer-outbound-ips / -ip-prefixesBring-your-own outbound IPs or prefixThe cluster identity needs public IP permissions
--nat-gateway-managed-outbound-ip-countNumber of IPv4 addresses for the managed NAT Gateway1–16
az network lb outbound-rule list --lb-name kubernetesView actual outbound rule valuesRun 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)

Cost and risk StandardV2 NAT Gateway and public IPs are billed hourly and for data processed (example: a few cents per hour; check the pricing page). Migration changes the egress IP and breaks existing outbound connections. Required role: Contributor on rg-aks-lab.
Record the egress IP before migration:
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
Stress-test outbound connections (observe SNAT): From a Pod, open 300 concurrent connections to the same destination, then check the load balancer's SNAT metrics:
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.

Create a NAT Gateway and attach it to the node subnet: Run the first three commands from the BYO VNet section on the "Commands" tab. The subnet then has a NAT Gateway, so outbound traffic will use it first (even though outboundType is still loadBalancer).
Update outboundType:
az aks update -g $RG -n $NETCLUSTER --outbound-type userAssignedNATGateway
az aks show -g $RG -n $NETCLUSTER --query networkProfile.outboundType -o tsv
userAssignedNATGateway
Verify the egress IP has changed:
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.

(Optional) Rollback: 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.
Cleanup: 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.

Command-line tasks
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
Scenario analysis
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

▶
AKS Egress Traffic and Outbound Types — Houssem Dellai
English · Demo of each AKS outbound type and its egress IP (recorded before StandardV2 became the default; for SKU details, follow this lesson)
▶
NAT and NAT Gateway in Azure — John Savill's Technical Training
English · SNAT principles and port allocation in NAT Gateway
▶
NAT Gateway v2 Overview — John Savill's Technical Training
English · Changes in StandardV2 NAT Gateway (zone-redundant, IPv6)

Official documentation

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.

Shot 1 · 0–20s
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.
Shot 2 · 20–50s
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.
Shot 3 · 50–80s
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.
Shot 4 · 80–100s
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.
Or score ≥ 70% on the “Quiz”

Module 4 · Private clusters and API Server VNet integration

21:00 – 28:00 · The API Server runs in a Microsoft-managed subscription. The question is: what path and what name do nodes and your kubectl use to reach it?
7 minPrivate clusters GA · API Server VNet integration GA--disable-private-cluster preview★★★★☆
Learning objectives
  • 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.
Prerequisites: Azure Private Link, private DNS zones; the control plane architecture from hour 1. Importance: ★★★★☆

What: Three ways to expose the API Server

Public endpoint (default)Private cluster (Private Link)API server VNet integration
API Server addressPublic IP, FQDN *.hcp.<region>.azmk8s.ioA private endpoint IP in your subnetInternal load balancer VIP in the delegated subnet
Node → API ServerThrough the cluster's outbound type (public path); the konnectivity tunnel is used for API Server → kubeletThrough 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-rangesDecided at creation (public FQDN can be disabled)Public/private mode can be toggled after creation, no rebuild needed
Extra subnetNoneNone (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-fqdn removes 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.io or <subzone>.privatelink.<region>.azmk8s.io; VNet integration clusters use private.<region>.azmk8s.io or <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 none together with --disable-public-fqdn. That would leave no DNS that can resolve the API Server.
  • You can only update from byo/system to none, 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 integrationEKS private endpointGKE private endpoint
MechanismILB in delegated subnetControl plane ENI placed in your subnetPeering/PSC private IP
Public/private switchSwitchable after creationPublic and private can be enabled togetherConfigurable
Common misconceptions(1) "A private cluster's public FQDN means the API Server has a public entry point": it can only be resolved by public DNS, and it still points to a private IP, so access still requires network connectivity. (2) "Authorized IP ranges can protect a private endpoint": authorized IP ranges only apply to the public endpoint. (3) "Once VNet integration is on, you can turn it off": it cannot be disabled, and the API Server IP changes after conversion (the hostname stays the same). (4) "It's fine to delete a private endpoint that looks redundant": deleting or modifying a private endpoint in the customer subnet will stop the cluster from working.

Architecture diagram: private cluster vs VNet integration

Private cluster (Private Link) AKS-managed subscription: API ServerFronted by a Private Link Service (standard load balancer)konnectivity: reverse tunnel from API Server → kubelet Your VNet · snet-nodes Private endpoint10.10.0.10 Node / kubectl hostResolve FQDN → 10.10.0.10 Private DNS zone privatelink.canadacentral.azmk8s.ioA record → private endpoint; linked only to the cluster VNet by default API server VNet integration Your VNet snet-apiserver 10.10.4.0/28 (delegated)API Server instances + internal load balancer VIP 10.10.4.4Reserve at least 9 IPs; IP exhaustion prevents the API Server from scaling snet-nodes 10.10.0.0/22Nodes connect directly to 10.10.4.4:443 (no DNS, no tunnel)API Server → kubelet:10250 direct connection Public access: can be turned on or off (--enable/--disable-private-cluster)Private mode DNS zone: private.canadacentral.azmk8s.io
Figure 4-1: A private cluster "projects" the API Server as a private endpoint; VNet integration places the API Server's ILB directly in your subnet

Flowchart: how the private FQDN resolves in hub-spoke

Ops laptopVia VPN to hub Enterprise DNS forwarderhub VNet 10.0.x Conditional forwardingazmk8s.io → 168.63.129.16 Azure DNSLook up private zone (linked to hub) A record10.10.0.10 Prerequisite: the private zone is linked to the VNet where the DNS forwarder lives (or use DNS Private Resolver); the forwarder is open to nodes on UDP+TCP 53 Common failure: the zone is linked only to the spoke, so the hub's forwarder cannot resolve it → kubectl reports no such host
Figure 4-2: Most cases of a private cluster being "unreachable" are actually DNS problems

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 / flagPurposeNotes
--enable-private-clusterPrivate clusterCLI ≥ 2.28; API version ≥ 2021-05-01
--private-dns-zone system|none|<id>Private DNS zone policyCustom zone requires a user-assigned identity + two roles
--disable-public-fqdnRemove the publicly resolvable FQDNCannot be used with none
--fqdn-subdomainSubdomains in a custom zoneOnly with a custom zone of the form privatelink.<region>.azmk8s.io
--enable-apiserver-vnet-integration --apiserver-subnet-idVNet integrationCLI ≥ 2.73; BYO requires a delegated subnet
az aks update --enable-private-cluster / --disable-private-clusterSwitch public/private on a VNet integration cluster--disable-private-cluster preview
az aks command invokeRun a command in the cluster through the Azure APINo network connectivity needed; good for emergencies
--api-server-authorized-ip-rangesSource IP allowlist for the public endpointApplies 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)

Risk notice: The conversion is irreversible. After conversion, you must immediately run 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.
Confirm the delegated subnet and permissions:
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
Run the conversion and restart immediately:
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).

Verify the API Server is in the delegated subnet:
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.

Enable private mode:
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.

Continue managing the cluster with command invoke:
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.

(Optional) NSG port check: If you added custom NSGs to snet-nodes / snet-apiserver, confirm these are allowed: node subnet → API Server subnet TCP 443 and 4443; API Server subnet → node subnet TCP 10250; AzureLoadBalancer → API Server subnet TCP 9988.
Cleanup: This lab has no extra billable resources. If you decide to delete the 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.

Command-line tasks
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
Scenario analysis
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

▶
Access to AKS control plane (public, private, vnet integration) — Houssem Dellai
English · Side-by-side demo of the public, private, and VNet integration control plane access methods
▶
Azure Kubernetes Service cluster with API Server VNet Integration (Preview) — Azure Power Lunch
English · Recorded during the preview period; the feature is now GA, so follow this lesson for details such as the manual restart on conversion

Official documentation

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.

Shot 1 · 0–20s
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.
Shot 2 · 20–45s
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.
Shot 3 · 45–65s
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.
Shot 4 · 65–80s
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.
Or score ≥ 70% on the “Quiz”

Module 5 · Ingress: App Routing add-on and Application Gateway for Containers

28:00 – 35:00 · Ingress-NGINX is retired. On AKS, the long-term standard is Gateway API. Your choice is whether the data plane runs inside the cluster (Istio/Envoy) or outside it (AGC).
7 minApp Routing Gateway API GA · AGC GAApp Routing NGINX supported through 2026-11 · AGC add-on preview★★★★★
Learning objectives
  • 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.
Prerequisites: Kubernetes Ingress and the Gateway API resource model (K8s course, hour 3). Importance: ★★★★★ (one of the most urgent migrations of 2026)

What: Ingress options on AKS (2026-11)

OptionAPIData plane locationStatus and key points
App Routing add-on · NGINXIngress (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 APIGateway 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-onGateway API (GatewayClass istio)Envoy inside the clusterChoose 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 IngressOutside the cluster, an Azure-managed L7 data planeWAF, 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)IngressOutside the cluster: App Gateway v2The 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: LoadBalancer Service; 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 inserts x-forwarded-for, x-forwarded-proto, and x-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 the waf type).
  • 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 ApplicationLoadBalancer custom 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 subnet aks-appgateway in the managed VNet. Requires Azure CNI or Overlay, Workload Identity enabled, and managed Gateway API CRDs (--enable-gateway-api).

When: How to choose

RequirementRecommended
General HTTP/HTTPS ingress, managed and low costApp 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 resourcesAGC
Needs rate limiting, body size limits, Lua scripting, or equivalents of NGINX annotationsIstio add-on Gateway API + gateway-level EnvoyFilter (EnvoyFilter issues are outside Azure support scope)
Multi-tenant, mutually untrusted tenantsDo 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 NGINXApp Routing Gateway APIAGC
APIIngress + annotationsGateway / HTTPRouteGateway / HTTPRoute / GRPCRoute + Ingress
DNS / TLS automationAzure 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)
WAFNoneNoneYes (security policy)
Support periodCritical patch deadline 2026-11Long-termLong-term
Common misconceptions(1) "The Ingress API is also deprecated": no, the retired component is the ingress-nginx controller. (2) "App Routing Gateway API is the Istio service mesh": it only uses the Istio control plane to manage gateways, and it does not support sidecars or Istio CRDs. (3) "Disabling App Routing deletes all ingress resources": to avoid disruption, when you disable NGINX, the Deployment, ConfigMap, and Secret in 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

App Routing Gateway API (approuting-istio) Client Azure standard load balancer (L4)Service: myapp-gw-approuting-istio AKS cluster Envoy gateway Pods ×2HPA 2–5 · PDB min 1 istiod (aks-istio-system)watch Gateway/HTTPRoute myapp Pod 192.168.0.37:5000 / 192.168.1.12:5000HTTPRoute backendRef: Service myapp:80 Application Gateway for Containers Client AGC (Azure-managed L7): frontend *.fzXX.alb.azure.comWAF · TLS · routing · inserts x-forwarded-for / x-request-idassociation → snet-agc 10.10.8.0/24 (delegated) AKS cluster alb-controller ×2Workload Identity → ARM myapp PodReceives AGC traffic directly Gateway does not consume cluster CPU; configuration updates go through the ALB ControllerListens only on 80/443; default request timeout 60s
Figure 5-1: App Routing puts the L7 proxy inside the cluster; AGC puts the L7 proxy outside the cluster, and the Controller only translates configuration

Flowchart: migrating from Ingress-NGINX

① InventoryIngress + annotations + snippets ② Choose targetapprouting-istio / AGC / istio ③ Convertingress2gateway print ④ Run in parallelNew IP + low-TTL DNS cutover ⑤ Retire NGINXapprouting disable + delete namespace Annotations with no one-to-one mapping (rate limiting, body size, Lua) must each be matched with an alternative and tested
Figure 5-2: Migration risk lies mainly in annotations, not in the YAML structure

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

CommandPurposeNotes
az aks update --enable-gateway-api --enable-app-routing-istioEnable managed Gateway API CRDs + App Routing Gateway APICLI ≥ 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-istioDisable App Routing Gateway APIDelete Gateways/HTTPRoutes first
az aks approuting enable|disable / --enable-app-routingApp Routing NGINX (Ingress)Only for existing workloads; do not choose it for new projects
az aks update --enable-gateway-api --enable-application-load-balancerAGC ALB Controller add-onPreview; requires registering ManagedGatewayAPIPreview, ApplicationLoadBalancerPreview, and the alb and aks-preview extensions; requires Workload Identity
kubectl get gatewayclassView available gateway implementationsapprouting-istio / azure-alb-external / istio
kubectl wait --for=condition=programmed gateway/<name>Wait for the gateway to be readyThen 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)

Cost and risk This creates a public load balancer frontend IP (on the order of $0.005 per hour; see the pricing page) and 2 Envoy Pods. myapp becomes publicly reachable, so delete everything as soon as the lab ends. If Module 4's private mode is on, run kubectl via az aks command invoke, or turn off private mode first.
Confirm the CLI version and enable it:
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
Deploy the Gateway and HTTPRoute: save the 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
Access the app and check the access logs:
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.

(Optional) Compare with AGC: The AGC add-on is in preview. You need to register the feature and create 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.
Cleanup:
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.

Command-line tasks
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/
Scenario analysis
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

▶
Ingress with the Kubernetes Gateway API via the application routing add-on (preview) — Azure Power Lunch
English · Recorded during preview. The implementation is now GA, so the CLI parameters in this hour take precedence.
▶
AKS Application Gateway for Containers Addon - Part 18 — Programming with Wolfgang
English · Demonstrates enabling and routing with the AGC add-on (preview)
▶
How I would migrate from Ingress NGINX to Gateway API — That DevOps Guy
English · General Ingress to Gateway API migration approach (not AKS-specific)
▶
App Routing, the best AKS feature ? — Houssem Dellai
English · Application routing NGINX add-on (to understand existing setups; this implementation is being retired)

Official 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.

Shot 1 · 0–20s
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.
Shot 2 · 20–45s
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.
Shot 3 · 45–70s
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.
Shot 4 · 70–90s
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.
Or score ≥ 70% on the “Quiz”

Module 6 · Network policies: Azure, Cilium, and Calico

35:00 – 42:00 · By default, all Pods can reach each other. Use Cilium to switch the myapp namespace to “default deny plus explicit allow,” and avoid the pitfalls with DNS and LocalDNS.
7 minCilium recommendedAzure NPM: support ends on Windows 2026-09-30 / Linux 2028-09-30★★★★☆
Learning objectives
  • 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 ipBlock limits, toEntities and fromEntities in CiliumNetworkPolicy, 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.
Prerequisites: Kubernetes NetworkPolicy semantics (additive, applied by selector). Importance: ★★★★☆

What: The three policy engines in AKS

EnginePlatformNetwork optionsExtra capabilitiesSupport status
CiliumLinuxAzure CNI (any IPAM) plus Cilium data planeL3/L4, CiliumNetworkPolicy, cluster-wide policies; FQDN and L7 require ACNSRecommended
Azure NPMLinux (Windows support ended 2026-09-30)Azure CNINone; iptables implementation; limit of 250 nodes / 20,000 Pods; IPv6 not supportedLinux support ends 2028-09-30; migrate to Cilium
Calico (AKS-managed)Linux, Windows Server 2019/2022Azure CNI; kubenet (Linux)AKS only tests and supports networking.k8s.io policies; projectcalico.org/v3 requires self-managed CalicoSupported; 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

  1. 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.”
  2. Allow DNS before default-deny Egress: Allow UDP and TCP 53 to k8s-app=kube-dns in kube-system. If the node pool has LocalDNS enabled, Pod DNS requests go first to 169.254.10.10/11 (node-local). With Cilium, you need a CiliumNetworkPolicy that allows toCIDR 169.254.10.0/24 and port 53 to toEntities: host (example from the official FAQ).
  3. Cilium's ipBlock can't select Pod or node IPs: For allows within the cluster, use podSelector/namespaceSelector. To reach nodes, use toEntities: [host] or remote-node. For inbound traffic from the internet, use fromEntities: [world].
  4. LoadBalancer traffic gets its addresses rewritten: With externalTrafficPolicy: Cluster, the source a Pod sees may be the node IP. To restrict public sources, use loadBalancerSourceRanges on the Service, which takes effect at the NSG/host layer before rewriting. Or use the azure-allowed-ip-ranges/azure-allowed-service-tags annotations (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

NetworkPolicyCiliumNetworkPolicyNSGAzure Firewall
GranularityPod labels, namespaces, IP ranges, portsPlus entities (host/world), FQDN, L7 (ACNS)Subnets/NICs, IPs, service tagsFQDN, IP, threat intelligence
LocationNode eBPFNode eBPFAzure networking stackOutside the cluster
East-west (Pod↔Pod)YesYesWith overlay, Pod CIDR traffic is also affected by subnet NSGs, but they can't tell individual Pods apartNo
Common misconceptions ① “After you write default-deny Egress, DNS still works.” No. You must allow it explicitly, and with LocalDNS enabled you also need to allow 169.254.10.0/24 and host. ② “With Cilium, ipBlock 0.0.0.0/0 allows everything.” It doesn't include Pod or node IPs. ③ “hostNetwork Pods are protected by policies.” They aren't. ④ “Uninstalling the policy engine deletes the policy objects.” It doesn't delete them, but they are no longer enforced. Calico's CRDs also need to be cleaned up manually. ⑤ “Having network policies doesn't affect LocalDNS.” Starting with 1.37, the 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

namespace myapp · default-deny (Ingress + Egress) Gateway Podmyapp-gw-approuting-istio myapp:5000 redis:6379 nettest (no label)Compromised Pod 5000 6379 Denied Internet usersentity: world 80 kube-dns / LocalDNS10.0.0.10 · 169.254.10.10 53 istiodaks-istio-system:15012 All Pods need DNS. The gateway Pod also needs to connect to istiod to get its configuration (xDS). Green = explicitly allowed; everything else is denied
Figure 6-1: After default deny, every arrow needs a matching policy

Flowchart: How Cilium decides on a packet

Source Pod sends the packetLook up the source identity Egress policy map(destination identity, port)? Route to the destination nodeAzure routing domain Ingress policy map(source identity, port)? Deliveredor DROP (Policy denied) Both directions must be allowed: the egress policy is checked on the source node, and the ingress policy is checked on the destination node
Figure 6-2: Identity instead of IP. When a Pod is rebuilt and gets a new IP, the policy doesn't need to be recalculated

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

CommandPurposeNotes
--network-policy cilium|azure|calico|noneSelect the policy engineAutomatically set to cilium when using the Cilium data plane
az aks update --network-policy noneUninstall NPM/CalicoPolicy objects are kept but no longer enforced; the whole pool is reimaged
az aks update --network-dataplane ciliumNPM/Calico → CiliumThe existing engine is replaced; behavior differences must be covered by regression tests
kubectl get netpol,cnp,ccnp -AList K8s and Cilium policiescnp = CiliumNetworkPolicy, ccnp = cluster-wide
cilium-dbg endpoint listView the policy enforcement status of each endpointPOLICY column shows Enabled/Disabled
cilium-dbg monitor --type dropWatch dropped packets in real timeReason 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)

Establish a baseline: everything currently communicates:
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.
Apply only default-deny (DNS is intentionally not allowed):
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.

Apply the full baseline and business policies: after saving the two files from the “Commands” tab:
kubectl apply -f np-baseline.yaml -f np-app.yaml
kubectl -n myapp get netpol,cnp
Verification matrix:
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.

Check the drop reason on the node: Find the cilium Pod on the node where redis runs and run cilium-dbg monitor --type drop. Then start a connection from nettest and watch for Policy denied.
Cleanup: Keep the policies for the Capstone lab. Delete the test Pod with 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.

Command-line tasks
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
Scenario analysis
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

▶
eCHO Episode 137: A Review of Cilium Network Policy — eBPF & Cilium Community
English · Systematic explanation of the Cilium policy model, entities, and identity (upstream Cilium, not AKS-specific)
▶
Kubernetes Network Policies Explained — DevOps & AI Toolkit
English · NetworkPolicy semantics review

Official documentation

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.

Shot 1 · 0–20s
On screen: lines connect every Pod in the namespace.
Narration: By default, any two Pods in the cluster can reach each other.
Shot 2 · 20–40s
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.
Shot 3 · 40–65s
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.
Shot 4 · 65–80s
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.
Or score ≥ 70% on the “Quiz”

Module 7 · DNS, CoreDNS, and private DNS zones

42:00 – 50:00 · A single lookup may pass through the resolv.conf search list, LocalDNS, CoreDNS, VNet DNS, 168.63.129.16, and private zones. Any hop can be the point of failure.
8 minCoreDNS · LocalDNS (1.31+)Starting 1.37, AKS Standard defaults to LocalDNS Preferred★★★★★
Learning objectives
  • 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-custom ConfigMap (keys must end in .server or .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, vnetDNSOverrides and kubeDNSOverrides, 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.
Prerequisites: Kubernetes Service DNS naming (svc.namespace.svc.cluster.local). Importance: ★★★★★ (half of network problems are DNS problems)

What: DNS components in an AKS cluster

ComponentLocationPurpose
Pod /etc/resolv.confEach PodWith 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
LocalDNSEach 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.
CoreDNSkube-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 DNSVNet settingsDefault 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 zoneGlobal resource, linked to a VNetPrivate 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 as api.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 set dnsConfig.options ndots: 2 on 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)

KubernetesPreferredRequiredDisabled
1.31–1.36Validate configuration only, don't enable (but it still triggers a reimage)Install and force-enableDon't install
1.37+Install and enable if the compatibility check passesInstall and force-enableDon'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 in data ending in .server adds a new server block (for example, corp.contoso.com:53 { forward . 10.50.0.4 }). A key ending in .override inserts into the default server block (for example, hosts { … fallthrough } or log).
  • 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.local are 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 with forwardDestination: 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 LocalDNSUpstream NodeLocal DNSCacheCoreDNS only
Managed byAKS (node pool configuration)Self-deployed DaemonSetAKS
Configuration surfacelocaldnsconfig.json (per node pool)ConfigMapcoredns-custom
Can be enabled togetherNot recommended to enable both. 1.37 Preferred won't auto-enable when NodeLocal DNSCache is detected.—
Common misconceptions ① “I changed the VNet's DNS server, so the nodes take effect right away.” No. You need to run a node image upgrade on the AKS node pool (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

Node 10.10.0.4 myapp Podresolv.confndots:5 · search … LocalDNS169.254.10.10/11Cache · serve-stale CoreDNS (kube-dns 10.0.0.10)cluster.local → Service/EndpointSlicecoredns-custom: *.server / *.override cluster.local (TCP) VNet DNSAzure DNS 168.63.129.16or custom DNS (UDP+TCP 53) Other domains Private DNS zoneprivatelink.blob… (linked) Public DNSapi.github.com Custom DNS scenario (DNS server in the hub)Conditional forwarding of privatelink.* and azmk8s.io to 168.63.129.16 (the zone must be linked to the hub)or Azure DNS Private Resolver inbound endpoint Without LocalDNS: Pod → kube-dns 10.0.0.10 (CoreDNS) → forward . /etc/resolv.conf → VNet DNS dnsPolicy: ClusterFirst uses kubeDNSOverrides; dnsPolicy: Default uses vnetDNSOverrides LocalDNS metrics: node IP:9253/metrics
Figure 7-1: LocalDNS hands in-cluster names to CoreDNS and sends all other names directly to VNet DNS

Flowchart: resolving api.github.com with ndots:5

1 api.github.com.myapp.svc.cluster.local → NXDOMAIN 2 api.github.com.svc.cluster.local → NXDOMAIN 3 api.github.com.cluster.local → NXDOMAIN 4 api.github.com.<xxxx>.internal.cloudapp.net → NXDOMAIN 5 api.github.com → A 140.82.112.6 (A and AAAA once each → about 10 requests in total) MitigationIn the application, add a trailing dot to the FQDN: api.github.com.Pod dnsConfig: options: [{name: ndots, value: "2"}]LocalDNS caches negative answers, which reduces load on CoreDNS
Figure 7-2: The search list multiplies the query volume for external domain names several times over

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).

Query name
LocalDNS
VNet DNS

Core commands and parameters

CommandPurposeNotes
kubectl exec POD -- cat /etc/resolv.confPod DNS configurationCheck nameserver, search, and ndots
kubectl -n kube-system get cm coredns coredns-custom -o yamlCoreDNS configurationChange only coredns-custom
kubectl -n kube-system rollout restart deploy corednsReload custom configurationRolling restart with no downtime
az aks nodepool update --localdns-config ./localdnsconfig.jsonEnable, modify, or disable LocalDNSCLI ≥ 2.80; triggers a node reimage
az aks nodepool upgrade --node-image-onlyGives nodes the new VNet DNS settingsRequired after changing VNet DNS
dig +udp / +tcp @<dns> <fqdn>Verify both transports on the DNS serverMust do before enabling LocalDNS
az network private-dns link vnet createLink the private zone to the VNetOnly 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)

Prerequisite If the Module 6 default-deny policies are still in the myapp namespace, DNS is already allowed. This lab's debug Pod runs in a new namespace, 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).
Create a debug Pod and view resolv.conf:
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"
Observe search expansion: Open the CoreDNS query log (the 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.

Hosts mapping takes effect:
kubectl -n dnslab exec dig -- dig +short legacy.lab.internal
10.10.0.100
Private DNS zone: Run the three private zone commands from the “Commands” tab. Then delete 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.

Check LocalDNS status:
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.

Cleanup: 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.

Command-line tasks
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 coredns
2. 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"
Scenario analysis
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

▶
Better DNS for your AKS clusters — Houssem Dellai
English · AKS cluster DNS optimization (recorded before the 1.37 LocalDNS default behavior change; this hour takes precedence)
▶
Azure Kubernetes Service (AKS) Networking Deep Dive — John Savill's Technical Training
English · The DNS and private zone sections can serve as background review

Official 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.

Shot 1 · 0–20s
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.
Shot 2 · 20–45s
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.
Shot 3 · 45–70s
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.
Shot 4 · 70–90s
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.
Or score ≥ 70% on the “Quiz”

Module 8 · Network readiness review and common errors

50:00 – 60:00 · Turn the first 7 modules into a pre-launch review checklist, then use a troubleshooting tree to connect the 6 most common types of network failure
10 minIntegrated★★★★★
Learning objectives
  • 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.
Prerequisites: Modules 1–7. Importance: ★★★★★

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.

#AreaCheck itemBasis
1ModelUse Azure CNI Overlay (or Pod Subnet with a documented reason). No kubenet or Node Subnet.M1
2AddressThe 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 IPAMM0/M1
3AddressThe number of /24s for the Pod CIDR is ≥ max node count + surge. The node subnet reserves ≥ 30% for scaling and upgrades.M1/M2
4Data planeLinux cluster uses Cilium, and the Cilium version meets the minimum requirementM2
5NSGCustom NSG allows node↔node, node→Pod, and Pod↔Pod traffic, plus the ports for the API server subnetM2/M4
6OutboundProduction uses a NAT Gateway (StandardV2 preferred) or UDR to a firewall. LB outbound ports and IPs are explicitly calculated.M3
7OutboundEgress IPs are registered in external allow lists. Changes to the outbound type have a window and a rollback plan.M3
8OutboundWith UDR, the firewall allows the endpoints AKS requires. No public LoadBalancer Service causes asymmetric routing.M3
9Control planePrivate API server (VNet integration or private cluster), or a public endpoint plus authorized IP rangesM4
10Control planePrivate DNS zone links and conditional forwarding are verified. CI/CD uses a proxy inside the VNet.M4
11IngressNo longer depends on application routing NGINX or self-managed ingress-nginx. Uses Gateway API (approuting-istio or AGC).M5
12IngressThe external entry point has WAF (AGC, or Front Door or App Gateway in front). TLS certificates come from Key Vault.M5
13IngressThe Gateway is owned by the platform team, with allowedRoutes restricting namespaces. Ingress Pods have a PDB.M5
14PolicyEvery business namespace default-denies Ingress and Egress, and DNS (including LocalDNS) is allowedM6
15PolicyNo Azure NPM (Linux retires 2028-09-30). ipBlock usage has been reviewed against Cilium's limits.M6
16DNSCustom DNS servers allow UDP and TCP 53 from nodes, with no TCP connection limitM7
17DNSThe LocalDNS mode for each node pool is set explicitly, especially before upgrading to 1.37M7
18DNSPrivate endpoint zones are linked to the VNet doing the resolution. Policies auto-register records.M7
19ObservabilityLB and NAT GW SNAT metrics, CoreDNS and LocalDNS metrics, and ingress access logs are connected to monitoring and alertingM3/M5/M7
20IaCAll of the network parameters above are written in IaC (explicit networkPluginMode, outboundType, and so on), not left to defaultsAll

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

  1. Name: Does it resolve? Which IP does it return? (dig. Check the Server field to tell whether LocalDNS or kube-dns answered.)
  2. Entry point: Gateway or Ingress status, the load balancer frontend IP, and health probes (kubectl describe gateway, LB metrics)
  3. Service: Does the EndpointSlice have ready endpoints? (kubectl get endpointslice, cilium-dbg service list)
  4. Policy: Is traffic being dropped? (cilium-dbg monitor --type drop)
  5. Azure networking: NSG effective rules, effective routes (az network nic show-effective-route-table), and NAT or SNAT metrics
  6. 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 checklistAzure Well-Architected AKS service guideAKS baseline reference architecture
PurposeCheck off each item before launchDesign recommendations across the five pillarsDeployable hub-spoke reference implementation
RecommendationCombine all three: start from the reference architecture, use the WAF guide to make trade-offs, and use the checklist as the launch gate
Common misconceptions ① “For a network problem, restart the Pod first.” Restarting wipes out the evidence (conntrack state and logs). Locate the problem with the hop-by-hop method first. ② “If ping fails, the network is down.” Many Azure components don't respond to ICMP, so test with TCP connections (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

vnet-aks-lab 10.10.0.0/16 snet-nodes 10.10.0.0/22 · NAT Gateway · NSG Node A 10.10.0.4192.168.0.0/24 · CiliumLocalDNS 169.254.10.10 Node B 10.10.0.5192.168.1.0/24 · CiliumGateway Envoy Pod Service CIDR 10.0.0.0/16 (cluster-internal only)kube-dns 10.0.0.10 · myapp · redisNetworkPolicy: myapp default deny snet-apiserver /28 (delegated)API Server ILB 10.10.4.4Private mode · private.* zones snet-agc /24 (optional)AGC associationWAF · private and public frontend DNS: Azure DNS 168.63.129.16 · private zones (lab.aks.internal, privatelink.*)or hub custom DNS (UDP+TCP 53) plus conditional forwarding or DNS Private ResolverCoreDNS extension: coredns-custom (*.server / *.override) InternetOutbound: NAT GW public IPInbound: LB frontend or AGC frontend Hub or on-premisesSees the node IP (overlay SNAT)Must not overlap with the Pod or Service CIDR Ops and CIBastion · self-hosted proxyaz aks command invoke
Figure 8-1: What the network review covers. Four subnets or address ranges, three paths (outbound, inbound, control plane), and one DNS setup.

Failure map: symptom → most likely layer

Temporary failure in name resolution Intermittent timeouts, only to external targets, at peak times Can only reach Pods on the same node Only one specific enterprise network range is unreachable DNS: policy, LocalDNS TCP, CoreDNS SNAT port exhaustion (LB outbound) NSG blocks the Pod CIDR (Overlay doesn't encapsulate) Pod or Service CIDR overlaps with that range Allow 53; dig +tcp; check the Server field Explicit ports and IPs, or migrate to a NAT Gateway Complete the three NSG allow rules Long term: rebuild the cluster with new CIDRs
Figure 8-2: The four most common symptoms and their fix directions (for the full version, see the interactive troubleshooting tree on the “Troubleshooting” tab)

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

LayerCommandWhat to look at
Cluster configurationaz aks show --query networkProfileMode, data plane, CIDRs, outbound type
Namekubectl exec … -- nslookup / digServer field, NXDOMAIN, timeouts
Ingresskubectl describe gateway/httprouteAccepted and Programmed conditions
Servicekubectl get endpointslice -l kubernetes.io/service-name=XReady endpoints
Policycilium-dbg monitor --type dropPolicy denied
Node networkkubectl debug node/N -it --image=…Capture packets and run dig in the node's namespace
Azure routingaz network nic show-effective-route-table0.0.0.0/0 next hop
NSGaz network nic list-effective-nsgDeny rule hit
Outbound capacityaz monitor metrics list --metric SnatConnectionCountFailed dimension
Subnet capacityaz 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)

Risk The following steps deliberately cause faults. Run them only on aks-lab-net, and repair them in strict order. NSGs are free.
Fault 1: NSG blocks the Pod CIDR: attach an NSG to the node subnet that denies 192.168.0.0/16:
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.”

Fix 1: Allow the traffic as required in M2 (with a higher priority than the deny rule), or simply delete the deny rule:
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 '*'
Fault 2: DNS blocked by policy:
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).

Fault 3 (paper exercise): Service CIDR overlaps with the enterprise network: Suppose there is a database at 10.0.5.20 on-premises. What happens when you run 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.
Run the health-check script: Run aks-net-check.sh from the “Commands” tab, compare its output with the review scorer on the “Animation” tab, and record your score.
Cleanup:
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.

Command-line tasks
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 table
2. 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 drop
Scenario analysis
New 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

▶
Top AKS mistake ! CIDR IP overlapping! — Houssem Dellai
English · Short video demonstrating a typical fault caused by CIDR overlap
▶
Azure Kubernetes Service (AKS) Networking Deep Dive — John Savill's Technical Training
English · Full review of this hour

Official 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.

Shot 1 · 0–20s
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.
Shot 2 · 20–50s
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.
Shot 3 · 50–75s
Visual: Four symptom cards flip over. The backs show DNS, SNAT, NSG, and CIDR overlap.
Narration: These four symptoms cover most AKS network incidents.
Shot 4 · 75–90s
Visual: All the settings flow into an IaC file icon.
Narration: Finally, write every network parameter into infrastructure code. Don't rely on defaults.
Or score ≥ 70% on the “Quiz”

Command cheat sheet

AKS networking · Every code block has one-click copy (verified on 2026-11-15)
Post-class reference

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

SymptomMost likely causeFirst commandFix direction
Temporary failure in name resolutionPolicy doesn't allow DNS / TCP 53 to the LocalDNS upstream is blockednslookup kubernetes.defaultAllow kube-dns and 169.254.10.0/24; open TCP 53 on the DNS server
Can only reach Pods on the same nodeNSG blocks the Pod CIDR (Overlay doesn't encapsulate)az network nsg rule listAllow node↔node, node→Pod, and Pod↔Pod
Intermittent external call timeouts during peak hoursLB SNAT port exhaustionLB metric SnatConnectionCount (Failed)Explicit ports/IPs, NAT Gateway, connection reuse
An enterprise network segment is unreachableOverlaps with the Pod or Service CIDRaz aks show --query networkProfileRe-plan the CIDR (build a new cluster)
kubectl no such host / i/o timeoutPrivate zone not linked / no network pathnslookup <privateFqdn>Link the zone, conditional forwarding, command invoke
logs/exec reports error dialing backendVNet integration NSG doesn't allow 10250NSG effective rulesAPI server subnet → node subnet TCP 10250
Gateway Programmed=FalseLeftover Istio CRDs, CLI version, wrong class namekubectl describe gatewayClean up CRDs, upgrade the CLI, verify gatewayClassName
Nodes NotReady after switching the UDRFirewall doesn't allow required outbound traffickubectl describe nodeFQDN tag AzureKubernetesService
Private endpoint resolves to a public IPZone not linked to the VNet doing the resolutiondig +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

Deliver a “production network baseline” for myapp: a private control plane, NAT Gateway outbound, Gateway API ingress, default-deny policies, and DNS verification, and pass the network readiness review.
Post-class ≈ 45 minutesCovers all modules
Scenariomyapp is about to be published externally. The architecture review board requires: ① the cluster address plan doesn't overlap the enterprise network and is registered; ② the API server isn't exposed on the public internet; ③ outbound uses fixed IPs (for partner allowlists) and capacity can scale; ④ external ingress uses a supported Gateway API implementation; ⑤ the myapp namespace is zero trust; ⑥ DNS is reliable under the default LocalDNS behavior in 1.37; ⑦ a review score ≥ 85%. Complete this on rg-aks-lab / aks-lab-net (if already deleted, rebuild it following Module 0).
Cost and cleanupThis lab uses a 2-node cluster, a NAT Gateway, a public IP, and a load balancer frontend. Together they cost roughly US$0.5–0.7 per hour (rough example estimate; see the pricing page). Run the final cleanup step when you finish.
Address plan review (M0, M1)
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.

Fixed outbound IP and capacity (M3)
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.

Control plane private (M4)
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.

Ingress (M5): Confirm that 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"
Zero-trust policies (M6): Apply 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" 
DNS reliability (M7): Check the LocalDNS profile on each node pool. Test VNet DNS from a node with 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.
Review scoring (M8): Open the “Animation” tab in Module 8, check off each item, and record the score and the remaining fixes. Run aks-net-check.sh (through command invoke or a jump box) and attach the output to the review log.
Cleanup:
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
Acceptance checklist

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

Basis for the verification of every technical fact in this lesson (verified on 2026-11-15; sources are the learn.microsoft.com pages as they stood that day)
TopicVerified conclusionSource
Network modelTwo 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 OverlayA 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
CiliumCan 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)
MigrationIPAM 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 typeloadBalancer / 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 Gateway64,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 outboundAllocatedOutboundPorts 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 integrationDelegates 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 routingingress-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 ContainersThe 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 policyComparison 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)
DNScoredns-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-NGINXRetirement 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 --sku syntax 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 only mode are 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 ApplicationLoadBalancer fields 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-name and 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.