Understanding Kubernetes Cluster Upgrade— A Beginner’s Guide
How to keep your kubernetes cluster up-to-date?

Find Complete mind map of A Beginner’s Guide to Kubernetes
In this article, we will dive into another practical aspects of maintaining a Kubernetes cluster by focusing on the critical task of upgrading the cluster.
Keeping your Kubernetes cluster up-to-date is essential for gaining access to new features, bug fixes, and security enhancements.
We will present a step-by-step guide on how to upgrade a Kubernetes cluster built with Kubeadm, covering both the control plane and worker nodes, using a practical example on a Kubeadm-built cluster.
Check out “Understanding Kubernetes — A Beginner’s Guide” for the comprehensive series🚀
Kubernetes Versioning
Before we begin the upgrade process, let’s first understand Kubernetes versioning and the order in which components should be upgraded.
Kubernetes follows a semantic versioning scheme with major, minor, and patch versions. Major versions indicate significant changes that may require updates to your applications, while minor and patch versions contain bug fixes and improvements that are usually backward-compatible.
Upgrade Order
To ensure a smooth upgrade process, follow this order:
- Upgrade the control plane components (master nodes).
- Upgrade the worker nodes.
Upgrading the Control Plane
Let’s start by upgrading the control plane (master nodes) using Kubeadm.
- Update the Kubeadm Package:
sudo apt-mark unhold kubeadm
sudo apt-get update
sudo apt-cache policy kubeadm
sudo apt-get install -y kubeadm=$TARGET_VERSION
sudo apt-mark hold kubeadm
2.Drain the Control Plane Node:
Before upgrading, we need to drain the control plane node to prepare for the upgrade. This ensures that no new workloads are scheduled on the node during the upgrade process.
kubectl drain k8s-master --ignore-daemonsets
3.Plan the Upgrade:
Use kubeadm upgrade plan
to see which versions are available for the upgrade:
sudo kubeadm upgrade plan
example output:
[upgrade/config] Making sure the configuration is correct:
...
[upgrade/prepull] Will prepull images for components [kube-apiserver kube-controller-manager kube-scheduler etcd]
...
[upgrade/apply] Upgrading your Static Pod-hosted control plane to version "v1.26.8"...
...
[upgrade/successful] SUCCESS! Your control plane is upgraded to version "v1.26.3".
4. Apply the Upgrade:
Run kubeadm upgrade apply
to perform the upgrade of the control plane components:
sudo kubeadm upgrade apply v$TARGET_VERSION
Example output:
[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.26.8". Enjoy!
5. Uncordon the Control Plane Node:
After the upgrade is complete, uncordon the control plane node to allow workloads to be scheduled on it again:
kubectl uncordon k8s-master
6.Update kubelet and kubectl:
Finally, update the kubelet and kubectl on the control plane node to match the new version:
sudo apt-mark unhold kubelet kubectl
sudo apt-get update
sudo apt-get install -y kubelet=$TARGET_VERSION kubectl=$TARGET_VERSION
sudo apt-mark hold kubelet kubectl
After completing the upgrade on the control plane/master node, you will need to repeat a similar process on each worker node in the cluster. However, there are some key differences in the steps for upgrading worker nodes:
- Update Kubeadm on Worker Nodes: Just like the control plane node, you will need to update the
kubeadm
package on each worker node to match the target version. - Drain the Worker Node: Before performing the upgrade, you should drain the worker node to evict all the pods running on that node. This ensures that the upgrade process can proceed smoothly without any disruptions.
- Perform the Upgrade: Run the
kubeadm upgrade node
command on each worker node to upgrade the kubelet configuration. This step is different from the control plane upgrade process, where we usedkubeadm upgrade apply
. - Uncordon the Worker Node: After the upgrade is complete, uncordon the worker node to allow new pods to be scheduled on it.
- Update Kubelet and Kubectl: Finally, just like the control plane node, you need to update the
kubelet
andkubectl
packages on each worker node to match the target version.
Remember to repeat these steps on each worker node in your cluster to ensure that all nodes are upgraded to the desired version.
Once all the nodes have been upgraded, your Kubernetes cluster will be running the latest version with all the latest features and bug fixes. Happy upgrading!
🔔 Stay tuned or subscribe to my series: “Understanding Kubernetes — A Beginner’s Guide” to explore everything about Kubernetes. 🚀
➕Join the Medium Membership Program to support my work and connect with other writers.
📝 Have questions or suggestions? Leave a comment or message me through Medium. Let’s connect!
Thank you for your support! 🌟