Upgrade AKS without downtime
In this task you'll move a cluster to a newer Kubernetes version while the apps keep running.
AKS supports each Kubernetes minor version for about a year, so plan an upgrade every few months. az aks upgrade upgrades the control plane, then each node pool: it adds a surge node, drains an old node (evicting its pods) and repeats.
A PodDisruptionBudget limits how many of an app's pods a drain may evict at once. It protects you, but a budget that can never be met (minAvailable 1 on a single replica) stalls the drain and fails the upgrade. Auto-upgrade channels keep patch versions and node images current without tickets.
Example. SS Kaiser upgrades its test cluster on the first Monday of each month and production a week later, with patch and NodeImage channels doing the small updates in between.
Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.
Before you start
You need: An AKS cluster. Time: 30 minutes.
Where to look
- Kubernetes services
- (cluster)
- Settings
- Cluster configuration
Steps
- List versions you can move to:
az aks get-upgrades -g <group> -n <cluster> -o table. - Check every PodDisruptionBudget:
kubectl get pdb -A. ALLOWED DISRUPTIONS 0 will block the drain. - Upgrade:
az aks upgrade -g <group> -n <cluster> -k <version>. Watch withkubectl get nodes -w. - Turn on channels:
az aks update --auto-upgrade-channel patch --node-os-upgrade-channel NodeImage.
Commands
# Connect kubectl to the cluster first
az aks get-credentials -g <group> -n <cluster>
az aks get-upgrades -g <group> -n <cluster> -o table
kubectl get pdb -A
az aks upgrade -g <group> -n <cluster> -k <version> --yes
Watch out for
- Cost
- The surge node costs extra for the length of the upgrade.
- Security
- Running an unsupported version means no security fixes: don't fall behind.
- Common mistakes
- Skipping more than one minor version (you can't), and single-replica apps with strict disruption budgets.
Clean up
Nothing to clean up.
Words to know
- PodDisruptionBudget
- Limits how many of an app's pods voluntary disruptions, such as drains, may take down at once.
- Surge node
- An extra node AKS adds during an upgrade so pods have somewhere to go.
- Auto-upgrade channel
- AKS setting that upgrades a cluster automatically, for example to each new patch version.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On