Skip to content
Visual explainer 3h to learn 4 steps

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.

Topic 7 of 33

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.

FlowUpgrade order
  1. 1
    Upgrade kubeadm

    Point repo at new minor; install exact version.

  2. 2
    kubeadm upgrade plan

    Shows target versions and checks the cluster.

  3. 3
    kubeadm upgrade apply

    First control plane node upgrades its components.

  4. 4
    Drain and upgrade kubelet

    Install kubelet and kubectl, restart kubelet.

  5. 5
    Uncordon

    Node accepts Pods again.

  6. 6
    Workers: upgrade node

    kubeadm upgrade node, then drain, kubelet, uncordon.

CompareFirst control plane node vs every other node
First control plane node
  • Upgrade kubeadm package
  • kubeadm upgrade plan
  • kubeadm upgrade apply v1.34.x
  • Then drain, kubelet, uncordon
Other control planes and workers
  • Upgrade kubeadm package
  • kubeadm upgrade node
  • Drain from the control plane
  • Upgrade kubelet and kubectl, restart
  • Uncordon
SequenceDraining a worker
Admin
API server
Pods on worker
Other nodes
  1. 1Cordon: mark worker unschedulable
    Admin to API server: Cordon: mark worker unschedulable
  2. 2Evict each Pod (respect PDBs)
    Admin to API server: Evict each Pod (respect PDBs)
  3. 3Terminate gracefully
    API server to Pods on worker: Terminate gracefully
  4. 4Controllers create replacements
    API server to Other nodes: Controllers create replacements
  5. 5Uncordon after upgrade
    Admin to API server: Uncordon 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
LayersAllowed versions vs API server N
  1. 1
    kube-apiserver

    N: the reference point

  2. 2
    Controller manager, scheduler

    N or N-1

  3. 3
    kubelet, kube-proxy

    N down to N-3, never newer

  4. 4
    kubectl

    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.

FlowPointing apt at the next minor
  1. Step 1
    Edit kubernetes.list

    Change v1.33 to v1.34 in the URL

  2. Step 2
    apt update

    Fetch the new repository index

  3. Step 3
    apt-cache madison kubeadm

    List available patch versions

  4. Step 4
    Install 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.

  1. 1
    Read the upgrade docs procedure~45m
  2. 2
    Upgrade kubeadm and the control plane~45m
  3. 3
    Drain, upgrade and uncordon workers~45m
  4. 4
    Verify 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

bash
# 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 cp1

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

bash
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 cp1

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

bash
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 nodes

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

Question 1

1Your cluster runs 1.32. You need 1.34. What is the correct path?

Question 2

2On a second control plane node, which command upgrades its components?

Question 3

3kubectl drain stops with an error about DaemonSet-managed Pods. What flag fixes it?

Question 4

4After upgrading the kubelet package, kubectl get nodes still shows the old version. What was missed?

Question 5

5Which version may a kubelet NOT run against a 1.34 API server?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Show the current version of every node and of the control plane.

  2. Exercise 2medium

    A drain hangs because of a PodDisruptionBudget. Find the PDB and explain your options.

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

Go deeper

ShareXLinkedInWhatsApp