Kubernetes Cluster Upgradation Process- Part 1

🗼Introduction

Upgrading a Kubernetes cluster is a critical task that ensures you are benefiting from the latest features, security patches, and performance improvements. This blog is the part 1 of Kubernetes cluster upgradation process, in this part will guide you through the process of Control Plan node upgrade, focusing on the best practices and commands needed for a smooth upgrade using kubeadm.

🗼Upgrading the Control Plane Node

The first step in upgrading a Kubernetes cluster is to upgrade the control plane node. During this process:

  • No new pods can be scheduled.

  • The cluster is not accessible using kubectl.

  • No new pods will be created if a pod fails.

  • Running applications, pods, and nodes are not affected.

🗼Steps of Upgrading with Kubeadm

Step 1: Check the Linux Distribution

First, determine the Linux distribution you are using:

cat /etc/*release*

Step 2: Add the Kubernetes APT Repository

Add the Kubernetes APT repository to your system:

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list

Step 3: Add the Kubernetes APT Key

Add the APT key for the Kubernetes repository:

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

Step 4: Update the Package List

Update the package list:

sudo apt-get update

Step 5: Find the Latest Patch Release for Kubernetes

Find the latest patch release for Kubernetes 1.29 using the OS package manager:

sudo apt update
sudo apt-cache madison kubeadm

Step 6: Upgrade the Control Plane Nodes

Upgrade the kubeadm tool:

sudo apt-mark unhold kubeadm
sudo apt-get update
sudo apt-get install -y kubeadm=1.29.x-*
sudo apt-mark hold kubeadm

Make sure to change the kubeadm version to the one obtained in the previous step.

Step 7: Run the Upgrade Plan

Run the upgrade plan to get information about the update and warnings if something might go wrong:

sudo kubeadm upgrade plan

Step 8: Apply the Upgrade

Apply the upgrade to the control plane:

sudo kubeadm upgrade apply v1.29.x

Make sure to change the version appropriately.

Step 9: Upgrade Kubelet and Kubectl

Upgrade kubelet and kubectl:

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

Step 10: Restart the Upgraded Resources

Finally, restart the upgraded resources to ensure all changes take effect:

sudo systemctl daemon-reload
sudo systemctl restart kubelet

🗼Conclusion

Upgrading your Kubernetes cluster using kubeadm ensures you stay up-to-date with the latest improvements and security patches. By following the steps outlined in this guide, you can perform a smooth and efficient upgrade of both control plane and worker nodes. Remember to always backup your cluster and thoroughly test the upgrade process in a staging environment before applying it to production.

1
Subscribe to my newsletter

Read articles from Ashutosh Mahajan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ashutosh Mahajan
Ashutosh Mahajan

Proficient in variety of DevOps technologies, including AWS, Linux, Shell Scripting, Python, Docker, Terraform, Jenkins and Computer Networking. They have strong ability to troubleshoot and resolve issues and are consistently motivated to expand their knowledge and skills through expantion of new technologies.