Unattended upgrades on AKS are safe only when three things line up: the channels decide what gets upgraded, the maintenance windows decide when, and surge, drain and PodDisruptionBudgets decide how disruptive it is. Most "auto-upgrade broke production" incidents come from setting one of the three and leaving the rest at their defaults.
The two channels are separate
AKS upgrades two independent layers, and each has its own channel:
| Setting | Controls | Values |
|---|---|---|
--auto-upgrade-channel | Kubernetes version of the control plane and node pools | none, patch, stable, rapid, node-image |
--node-os-upgrade-channel | OS and security updates on nodes, independent of the Kubernetes version | None, Unmanaged, SecurityPatch, NodeImage |
How the main choices behave:
- patch: moves to the latest supported patch of your current minor version. It never changes the minor version.
- stable: moves to the latest patch of minor version N-1, where N is the newest supported minor. Minor upgrades happen without you, one step at a time.
- rapid: tracks the newest minor version. Avoid it in production.
- NodeImage (node OS): reimages nodes with the weekly node image, which includes OS patches. Every patch is a node rollout.
- SecurityPatch (node OS): applies security patches in place where possible and reimages only when it must. Fewer rollouts, but on some OS SKUs nodes can drift from the published image.
- Unmanaged: the OS's own updater (for example unattended-upgrades on Ubuntu) patches nodes. AKS doesn't coordinate reboots, so you need something like kured.
Warning
--auto-upgrade-channel node-imageis the legacy way to get node images. When the node OS channel is set, it supersedes this value. Don't use both. Set the cluster channel topatchorstable, and handle node images with--node-os-upgrade-channel NodeImage.
A sensible production default is patch with NodeImage, plus a manual, tested minor upgrade each quarter. Use stable only if you can't keep to that cadence, and only if your deprecated API checks run continuously.
Step 1: see what is configured now
az aks show -g rg-aks -n aks-prod \
--query "{k8s:kubernetesVersion, channel:autoUpgradeProfile.upgradeChannel, nodeOs:autoUpgradeProfile.nodeOsUpgradeChannel}" -o table
az aks nodepool list -g rg-aks --cluster-name aks-prod \
--query "[].{pool:name, k8s:orchestratorVersion, image:nodeImageVersion, surge:upgradeSettings.maxSurge, drain:upgradeSettings.drainTimeoutInMinutes}" -o table
az aks maintenanceconfiguration list -g rg-aks --cluster-name aks-prod -o table
Check what upgrades are available now, so you know what the channel will do in the next window:
az aks get-upgrades -g rg-aks -n aks-prod -o table
az aks nodepool get-upgrades -g rg-aks --cluster-name aks-prod --nodepool-name user01
Step 2: set the channels
az aks update -g rg-aks -n aks-prod \
--auto-upgrade-channel patch \
--node-os-upgrade-channel NodeImage
Step 3: pin each channel to its own window
Each channel has its own maintenance configuration, identified by a reserved name:
| Configuration name | Governs |
|---|---|
aksManagedAutoUpgradeSchedule | Cluster auto-upgrade channel |
aksManagedNodeOSUpgradeSchedule | Node OS upgrade channel |
default | Legacy planned maintenance for AKS platform updates; don't use it to control upgrade channels |
Put Kubernetes patches in a monthly window and node images in a weekly one, so the two kinds of change don't land on the same night:
# Kubernetes patch upgrades: first Sunday of the month, 01:00-09:00 local
az aks maintenanceconfiguration add -g rg-aks --cluster-name aks-prod \
--name aksManagedAutoUpgradeSchedule \
--schedule-type RelativeMonthly --day-of-week Sunday --week-index First \
--interval-months 1 --start-time 01:00 --duration 8 --utc-offset +01:00
# Node OS images: every Tuesday 02:00-06:00 local
az aks maintenanceconfiguration add -g rg-aks --cluster-name aks-prod \
--name aksManagedNodeOSUpgradeSchedule \
--schedule-type Weekly --day-of-week Tuesday --interval-weeks 1 \
--start-time 02:00 --duration 4 --utc-offset +01:00
Windows have a minimum duration, which is 4 hours at the time of writing. Size the window for your largest pool. A rollout that runs past the end of the window may continue or may be held until the next window, so check the planned maintenance documentation for the current behaviour and keep a margin.
Freeze periods (peak trading, change freezes) are handled with not-allowed date ranges. The JSON config file form is the most portable way to set them across CLI versions:
cat > autoupgrade-window.json <<'EOF'
{
"properties": {
"maintenanceWindow": {
"schedule": {
"relativeMonthly": { "intervalMonths": 1, "dayOfWeek": "Sunday", "weekIndex": "First" }
},
"durationHours": 8,
"utcOffset": "+01:00",
"startTime": "01:00",
"notAllowedDates": [
{ "start": "2026-11-20", "end": "2027-01-05" }
]
}
}
}
EOF
az aks maintenanceconfiguration update -g rg-aks --cluster-name aks-prod \
--name aksManagedAutoUpgradeSchedule --config-file autoupgrade-window.json
Check the schema in the planned maintenance documentation for your CLI version before you rely on it. Then run az aks maintenanceconfiguration show to confirm the dates were stored.
Caution
A long freeze can leave a cluster on a version that is close to, or past, the end of support. Out-of-support clusters lose platform support, and AKS may apply mandatory upgrades on its own schedule. Keep freezes short and check
az aks get-upgradesbefore one starts.
Step 4: make each node rollout gentle
The windows control when an upgrade runs. These settings control how disruptive it is:
az aks nodepool update -g rg-aks --cluster-name aks-prod -n user01 \
--max-surge 33% --drain-timeout 45 --node-soak-duration 5
- max-surge: extra nodes created during the upgrade. A higher value is faster, but needs more quota and more subnet IPs. With Azure CNI (non-overlay), each surge node takes its full pod IP allocation from the subnet, so check that the subnet has room.
- drain-timeout: how long AKS waits for pod evictions on a node. A blocked eviction fails the upgrade once this passes.
- node-soak-duration: wait after each node before the next one. It gives probes and caches time to warm up. It needs a recent CLI.
PodDisruptionBudgets are what usually block drains. Find the ones that can never be satisfied:
kubectl get pdb -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,MIN:.spec.minAvailable,MAXU:.spec.maxUnavailable,ALLOWED:.status.disruptionsAllowed
Any PDB with ALLOWED at 0 in steady state, such as a single replica with minAvailable: 1, will block every drain. Fix the workload before the window, not during it.
Step 5: watch upgrades you didn't start
During a window, follow progress from the cluster side:
kubectl get nodes -L kubernetes.azure.com/node-image-version -w
kubectl get events -A --field-selector reason=Drain --sort-by=.lastTimestamp
For history, the Activity Log shows operations run by the platform. You can also subscribe to the AKS Event Grid events (for example new Kubernetes version available, node pool rolling started and finished) and route them to your on-call channel. Event names vary by API version, so check the Event Grid schema for Microsoft.ContainerService.
az monitor activity-log list --resource-group rg-aks --offset 7d \
--query "[?contains(operationName.value,'managedClusters')].{time:eventTimestamp, op:operationName.value, status:status.value, caller:caller}" -o table
Gate minor versions on deprecated APIs
With stable, a minor upgrade can remove an API version your manifests still use. AKS can detect recent calls to deprecated APIs and stop the upgrade, but don't rely on that. Run a check in CI against the target version and look at the cluster's own signal:
kubectl get --raw /metrics | grep apiserver_requested_deprecated_apis
Any series returned there names a group, version and resource that a client still calls. Find and update the caller before the next minor window.
Prevent it next time
- Set channels, both maintenance configurations and node pool upgrade settings in the cluster IaC module, so new clusters never start on defaults.
- Stagger windows across environments: dev on Monday, staging on Wednesday, production the following week. A bad node image then hits non-production first.
- Alert on node pools whose
provisioningStateisFailed, and on PDBs with zero allowed disruptions. - Review
az aks get-upgradesoutput and the AKS release notes once a month. Unattended doesn't mean unwatched.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get