top of page
  • Writer's pictureRafael Natali

Use Kubeadm to upgrade your cluster

As part of the CKA Curriculum, the candidate is expected to known how to perform this action during the exam. This article explains how to upgrade a Kubernetes cluster control node created with kubeadm and is part of a series of CKA-related articles here in the blog.


Determine which version to upgrade to


Find the latest patch release for the Kubernetes version you want to upgrade to using the OS package manager:

# Find the latest 1.29 version in the list.
# It should look like 1.29.x-*, where x is the latest patch.
sudo apt update
sudo apt-cache madison kubeadm

Upgrading control plane nodes


The upgrade procedure on control plane nodes should be executed one node at a time.


For the first control plane node


  • Upgrade kubeadm:

# replace x in 1.29.x-* with the latest patch version
sudo apt-mark unhold kubeadm && \
sudo apt-get update && sudo apt-get install -y kubeadm='1.29.x-*' && \
sudo apt-mark hold kubeadm
  • Verify that the download works and has the expected version:

kubeadm version
  • Verify the upgrade plan:

sudo kubeadm upgrade plan
  • Choose a version to upgrade to, and run the appropriate command. For example:

# replace x with the patch version you picked for this upgrade
sudo kubeadm upgrade apply v1.29.x		
  • Once the command finishes you should see:

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.29.x". Enjoy!

[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.

For the other control plane nodes


Same as the first control plane node but use:

sudo kubeadm upgrade node

instead of:

sudo kubeadm upgrade apply

Drain the node


Prepare the node for maintenance by marking it unschedulable and evicting the workloads:

# replace <node-to-drain> with the name of your node
kubectl drain <node-to-drain> --ignore-daemonsets
  • Upgrade the kubelet and kubectl:

# replace x in 1.29.x-* with the latest patch version
sudo apt-mark unhold kubelet kubectl && \
sudo apt-get update && sudo apt-get install -y kubelet='1.29.x-*' kubectl='1.29.x-*' && \
sudo apt-mark hold kubelet kubectl
  • Restart the kubelet:

sudo systemctl daemon-reload
sudo systemctl restart kubelet
  • Bring the node back online by marking it schedulable:

# replace <node-to-uncordon> with the name of your node
kubectl uncordon <node-to-uncordon>
  • Verify the status of the cluster

kubectl get nodes

The STATUS column should show Ready for all your nodes, and the version number

should be updated.

References


6 views0 comments

Recent Posts

See All
bottom of page