Cluster upgrades
Upgrade control plane and worker nodes one minor version with drain and uncordon.
By Invicly Tech, , in Kubernetes Administrator (CKA). About 9 minutes to read.
In short
kubeadm clusters upgrade one minor version at a time, control plane first, then workers. On each node you upgrade kubeadm, apply the upgrade, then drain, upgrade kubelet and kubectl, restart kubelet and uncordon. The official docs page lists every command and is allowed in the exam.
Explained simply
Kubernetes releases a new minor version about three times a year, and each one is supported for roughly fourteen months. So upgrading clusters is routine admin work. With kubeadm you move one minor version at a time, for example from 1.33 to 1.34.
Think of it like renovating a hotel while guests stay there. You never close the whole building. You fix the management office first (the control plane), then empty one floor at a time (drain a node), renovate it, and let guests back in (uncordon).
The order matters because of version rules. Newer control planes understand older kubelets, but not the other way round. Upgrading the control plane first keeps every part of the cluster able to talk to every other part during the process.
Press Play on a diagram to walk through it one step at a time.
- 1Upgrade kubeadm
Point repo at new minor; install exact version.
- 2kubeadm upgrade plan
Shows target versions and checks the cluster.
- 3kubeadm upgrade apply
First control plane node upgrades its components.
- 4Drain and upgrade kubelet
Install kubelet and kubectl, restart kubelet.
- 5Uncordon
Node accepts Pods again.
- 6Workers: upgrade node
kubeadm upgrade node, then drain, kubelet, uncordon.
- Upgrade kubeadm package
- kubeadm upgrade plan
- kubeadm upgrade apply v1.34.x
- Then drain, kubelet, uncordon
- Upgrade kubeadm package
- kubeadm upgrade node
- Drain from the control plane
- Upgrade kubelet and kubectl, restart
- Uncordon
- Admin to API server: Cordon: mark worker unschedulable1Cordon: mark worker unschedulable
- Admin to API server: Evict each Pod (respect PDBs)2Evict each Pod (respect PDBs)
- API server to Pods on worker: Terminate gracefully3Terminate gracefully
- API server to Other nodes: Controllers create replacements4Controllers create replacements
- Admin to API server: Uncordon after upgrade5Uncordon after upgrade
In depth
The version skew rules
Version skew means the allowed difference between component versions. The API server is the reference point. kubelets and kube-proxy may be up to three minor versions older than the API server, but never newer. The controller manager and scheduler may be at most one minor version older. kubectl may be one minor version older or newer.
In a cluster with several control plane nodes, the API servers may differ by at most one minor version. These rules are why you upgrade the control plane first and why you cannot jump two versions in one step.
- kubelet: up to 3 minors older than API server, never newer
- scheduler and controller manager: up to 1 minor older
- kubectl: within 1 minor either way
- 1kube-apiserver
N: the reference point
- 2Controller manager, scheduler
N or N-1
- 3kubelet, kube-proxy
N down to N-3, never newer
- 4kubectl
N-1, N or N+1
Changing the package repository
Since the move to pkgs.k8s.io, each minor version has its own package repository. Before upgrading from 1.33 to 1.34 you edit /etc/apt/sources.list.d/kubernetes.list (or the yum repo file) and change v1.33 to v1.34 in the URL, then run apt update.
This step is easy to forget, and the symptom is that apt cannot find the new kubeadm version. apt-cache madison kubeadm lists the versions the configured repository offers, so you can pick the exact patch release.
- Step 1Edit kubernetes.list
Change v1.33 to v1.34 in the URL
- Step 2apt update
Fetch the new repository index
- Step 3apt-cache madison kubeadm
List available patch versions
- Step 4Install the exact version
Then hold the package again
What drain really does
kubectl drain first cordons the node, marking it unschedulable so no new Pods land there. Then it evicts each Pod through the Eviction API, which respects PodDisruptionBudgets (PDBs). A PDB like minAvailable: 2 can make drain wait until enough replicas are healthy elsewhere.
DaemonSet Pods would just be recreated on the same node, so drain refuses to continue unless you pass --ignore-daemonsets. Pods using emptyDir need --delete-emptydir-data because their scratch data will be lost. Bare Pods with no controller need --force, since nothing will recreate them.
- --ignore-daemonsets for DaemonSet Pods
- --delete-emptydir-data for Pods with emptyDir
- --force for Pods without a controller
After the upgrade
kubeadm upgrade apply also renews the control plane certificates, which quietly fixes clusters near their one-year expiry. After all nodes are done, check kubectl get nodes: the VERSION column shows kubelet versions, and every node should show the new one.
Also check that control plane Pods are Running and that a test Deployment can still schedule Pods. If a node stays on the old version, you probably upgraded the packages but forgot to restart the kubelet.
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Read the upgrade docs procedure~45m
- 2Upgrade kubeadm and the control plane~45m
- 3Drain, upgrade and uncordon workers~45m
- 4Verify node versions after upgrade~45m
Key points
- You cannot skip minor versions; go 1.33 to 1.34, not 1.33 to 1.35.
- Use kubeadm upgrade apply on the first control plane node only.
- Other control plane nodes and workers use kubeadm upgrade node.
- Drain with --ignore-daemonsets so DaemonSet Pods do not block eviction.
- Run systemctl daemon-reload then restart kubelet after upgrading it.
Key terms
Tap a card to flip it. 0/5 known
Examples
# On the control plane (Debian/Ubuntu)
sudo apt-mark unhold kubeadm
sudo apt-get update && sudo apt-get install -y kubeadm='1.34.2-*'
sudo apt-mark hold kubeadm
sudo kubeadm upgrade plan
sudo kubeadm upgrade apply v1.34.2
kubectl drain cp1 --ignore-daemonsets
sudo apt-mark unhold kubelet kubectl
sudo apt-get install -y kubelet='1.34.2-*' kubectl='1.34.2-*'
sudo apt-mark hold kubelet kubectl
sudo systemctl daemon-reload && sudo systemctl restart kubelet
kubectl uncordon cp1Update the pkgs.k8s.io repo to the new minor first.
Upgrading the first control plane node to 1.34
Step 1: point the package repo at v1.34 and install the new kubeadm. Step 2: run upgrade plan to see the target and check for blockers. Step 3: apply the upgrade. Step 4: drain the node, upgrade kubelet and kubectl, restart the kubelet, then uncordon.
sudo sed -i 's/v1.33/v1.34/' /etc/apt/sources.list.d/kubernetes.list
sudo apt update && sudo apt-mark unhold kubeadm
sudo apt install -y kubeadm='1.34.1-*' && sudo apt-mark hold kubeadm
sudo kubeadm upgrade plan
sudo kubeadm upgrade apply v1.34.1
kubectl drain cp1 --ignore-daemonsets
sudo apt-mark unhold kubelet kubectl
sudo apt install -y kubelet='1.34.1-*' kubectl='1.34.1-*'
sudo apt-mark hold kubelet kubectl
sudo systemctl daemon-reload && sudo systemctl restart kubelet
kubectl uncordon cp1Upgrading a worker
Step 1: drain the worker from the control plane. Step 2: ssh to the worker, upgrade kubeadm and run kubeadm upgrade node, which updates the local kubelet config. Step 3: upgrade kubelet and kubectl and restart. Step 4: uncordon from the control plane and check the VERSION column.
kubectl drain worker1 --ignore-daemonsets --delete-emptydir-data
ssh worker1
# (repo already switched to v1.34)
sudo apt-mark unhold kubeadm kubelet kubectl
sudo apt install -y kubeadm='1.34.1-*'
sudo kubeadm upgrade node
sudo apt install -y kubelet='1.34.1-*' kubectl='1.34.1-*'
sudo apt-mark hold kubeadm kubelet kubectl
sudo systemctl daemon-reload && sudo systemctl restart kubelet
exit
kubectl uncordon worker1 && kubectl get nodesQuick reference
- One minor version per upgrade; control plane first, then workers
- Switch the pkgs.k8s.io repo URL to the new minor before apt update
- First control plane: kubeadm upgrade apply vX.Y.Z; all others: kubeadm upgrade node
- kubectl drain NODE --ignore-daemonsets --delete-emptydir-data
- systemctl daemon-reload && systemctl restart kubelet after upgrading kubelet
- kubectl get nodes VERSION column shows the kubelet version
- apt-cache madison kubeadm lists available patch versions
Common mistakes
- Forgetting to switch the pkgs.k8s.io repo to the new minor version.
- Running drain or uncordon from the worker, which has no admin kubeconfig.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Show the current version of every node and of the control plane.
- Exercise 2medium
A drain hangs because of a PodDisruptionBudget. Find the PDB and explain your options.
- Exercise 3hard
Upgrade a two-node lab cluster by one minor version and prove that a Deployment with 3 replicas stayed available throughout.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- How often do I need to upgrade?
- Each minor version gets about 14 months of patches. Upgrading every one or two minor releases keeps you supported.
- Do I need to upgrade etcd separately?
- No. On kubeadm clusters with stacked etcd, kubeadm upgrade apply upgrades etcd to the matching version for you.
- Can I roll back a failed kubeadm upgrade?
- kubeadm keeps backups of manifests and etcd data under /etc/kubernetes/tmp and rolls back automatically if the apply fails. For full safety, take an etcd snapshot before you start.