Infrastructure
Azure AKS: diagnose upgrade subnet IP capacity before reducing surge
A production runbook for qualifying SubnetIsFull during an AKS upgrade, calculating real IP headroom and deciding surge reduction, a new subnet, hold or recovery.
An AKS upgrade starts on a production node pool. No existing node has been drained, but the first surge node cannot be created. The pool reports SubnetIsFull or InsufficientSubnetSize. Workloads are still running, the maintenance window is closing, and the quick options look attractive: set maxSurge to zero, reduce maxPods, or retry immediately.
Those actions do not address the same cause. IP consumption depends on the networking model, the subnets actually used, target pool size, autoscaler bounds and upgrade strategy. Reducing surge can also move the risk from IP capacity to application availability. This runbook ends with a bounded decision: reclaim proven headroom, use a lower surge within a compatible maintenance window, migrate to a pool on a correctly sized subnet, hold the upgrade, or recover a pool that has already entered Failed state.
Freeze the failure before retrying
Pause automatic upgrades and leave the pool configuration unchanged. Capture the failed operation, full error, source and target versions, UTC window, provisioning state and actual node count. Preserve Kubernetes events too: they distinguish a capacity failure before drain from a later eviction refused by a PDB.
RG="rg-platform-prod"
CLUSTER="aks-platform-prod"
POOL="user01"
az aks nodepool show --resource-group "$RG" --cluster-name "$CLUSTER" --name "$POOL" --query '{state:provisioningState,count:count,maxPods:maxPods,subnet:vnetSubnetId,upgrade:upgradeSettings,version:orchestratorVersion}' --output json
az aks show --resource-group "$RG" --name "$CLUSTER" --query '{nodeResourceGroup:nodeResourceGroup,networkProfile:networkProfile,autoScaler:agentPoolProfiles[].{name:name,enabled:enableAutoScaling,min:minCount,max:maxCount}}' --output json
kubectl get nodes -o wide
kubectl get events -A --sort-by=.lastTimestamp If the error names a subnet, pool or VMSS other than the one expected, stop the local diagnosis. Capacity-path inventory is the first problem. A cluster can use several subnets, and an operation can be rejected because another pool is already close to its limit.
Identify the actual IP allocation model
Do not start with a formula. First record networkPlugin, networkPluginMode, podCidr, the node subnet, any separate pod subnet, maxPods, current size and the autoscaler ceiling.
With Azure CNI configurations where nodes and pods obtain addresses from a subnet, one surge node can require its node address plus capacity for its pods. With Azure CNI Overlay, pods use a separate address space and pressure on the node subnet is different. With a separate pod subnet or dynamic allocation, measure node and pod headroom independently. A correct equation applied to the wrong model is still a wrong diagnosis.
change: CHG-AKS-317
cluster: aks-platform-prod
pool: user01
window_utc: <start>/<end>
network:
plugin: <observed-networkPlugin>
mode: <observed-networkPluginMode>
node_subnet_id: <resource-id>
pod_subnet_id: <resource-id-or-none>
pod_cidr: <cidr-or-none>
pool_capacity:
current_nodes: <count>
autoscaler_max_nodes: <maxCount-or-none>
max_pods_per_node: <maxPods>
max_surge: <count-or-percent>
max_unavailable: <count-or-percent>
evidence:
subnet_prefixes: [<cidr>]
observed_ip_configurations: <count>
other_consumers: [<resource-types>]
provisioning_state: <state>
error_code: <code> Convert a percentage maxSurge into an effective node count for the observed pool. Record the rounding behavior returned by the platform instead of assuming that 33% always means one node.
Measure subnet headroom, not only its CIDR
Resolve the subnet from the node pool profile, then inventory its prefixes and IP configurations. Azure reserves five addresses in each IPv4 subnet. The remainder is not automatically available to AKS: network interfaces, Private Endpoints or other resources may share the subnet, and some allocations are temporary.
SUBNET_ID=$(az aks nodepool show --resource-group "$RG" --cluster-name "$CLUSTER" --name "$POOL" --query vnetSubnetId --output tsv)
az network vnet subnet show --ids "$SUBNET_ID" --query '{name:name,prefix:addressPrefix,prefixes:addressPrefixes,used:length(ipConfigurations),delegations:delegations[].serviceName}' --output json
az network nic list --query "[?ipConfigurations[?subnet.id=='$SUBNET_ID']].{nic:name,group:resourceGroup,ips:ipConfigurations[].privateIPAddress}" --output table The ipConfigurations count is a snapshot, not a future budget. Compare it with pool inventory, autoscaler ceilings and concurrent operations. A planned scale-out in the same window can consume the headroom reserved for the upgrade.
Calculate the upgrade peak for each scenario
For an Azure CNI model where each pod consumes an address from the subnet, a useful planning bound is:
(target nodes + surge nodes) × (1 + maxPods)
Add expected growth and the consumption of other pools or resources sharing the subnet. For a 12-node pool with maxSurge: 33% and maxPods: 30, the peak is not 12 node addresses. First establish the effective surge count, then reserve the corresponding node and pod budget. In an Overlay model, do not apply the pod multiplier to the node subnet; validate pod address space and mode-specific limits separately.
Calculate at least three cases before changing production: the current strategy, a reduced-surge strategy, and target capacity including growth plus the next maintenance event. A correction that only allows today’s upgrade recreates the incident at the next scale-out.
Exclude false IP-capacity diagnoses
A surge node can fail for another constraint: vCPU quota, SKU or zone capacity, policy, a lock, bootstrap dependency routing or the node image. Conversely, a PDB blocks drain after replacement capacity exists; it does not explain SubnetIsFull before the first new node.
Reconstruct the event order: new instance request, network allocation, bootstrap, node registration, cordon and drain. The first failing boundary owns the diagnosis. Do not lower maxSurge for a regional quota failure, and do not remove a PDB for an IP allocation failure.
Choose one bounded correction
Four options are defensible, with different tradeoffs:
- reclaim allocations that are proven orphaned, after identifying their owner and absence of use;
- lower
maxSurgewhen the pool still has capacity to absorb drain and the window accepts a longer upgrade; - use
maxUnavailableonly after validating replicas, PDBs, topology spread, downstream capacity and the outage budget; - create a new node pool on a larger subnet, canary workloads there, then drain the old pool.
Do not change maxPods as an instant fix without qualifying the impact on existing nodes, scheduling capacity and the network model. Do not assume that the CIDR of a subnet attached to an existing pool can be enlarged in place either. Treat a new subnet and pool as an explicit recovery path.
Canary the upgrade and protect the way back
Apply the correction to one non-critical pool or a representative canary pool. Before upgrade, prove IP headroom, compute quota, replacement capacity and disruptionsAllowed. During the operation, watch node creation, readiness, Pending pods, refused evictions and IP use. Include a negative control: no resource outside the pool should disappear merely to manufacture temporary headroom.
Define abort conditions before starting: another allocation error, a node that never becomes Ready, headroom falling below the reserved threshold, a critical pod that cannot be rescheduled, a PDB with no headroom, or the pool entering Failed. Do not start a second pool until the first has completed drain and released temporary allocations.
Decide validation, hold or recovery
Validate when calculation and measurement agree, the surge node is created, workloads stay available and residual headroom covers the next documented scale-out. Hold when the network model or subnet consumers are unknown, the correction depends on deleting an unattributed allocation, or the disruption budget cannot support lower surge.
If no new node was created, restore the previous upgrade settings and keep the current version. If the pool is already in Failed state, freeing a few addresses and retrying is not a sufficient recovery plan. Prepare a new pool on a correctly sized subnet, canary scheduling, cordon and drain the old pool, then delete it only after workload and evidence validation.
Conclusion
An AKS upgrade blocked by SubnetIsFull is a planned-capacity incident, not a routine maintenance error. A useful diagnosis connects the CNI model, actual subnets, maxPods, autoscaler, surge, concurrent allocations and application availability.
The production decision is then readable: retain surge with proven headroom, reduce it under a validated disruption budget, migrate to a correctly sized pool, or hold. If the pool has already failed, rollback means preserving workloads and building a verifiable replacement path, not repeating the operation in the hope that an address becomes free.