❤️ ABS is one of the five Certified Kubernetes Service Providers in India ❤️

Upgrading kubeadm clusters

Kubernetes is a powerful container orchestration platform that continuously evolves to meet the demands of modern applications. To keep your cluster up-to-date and secure, it’s essential to understand the upgrade process. In this blog post, we’ll walk you through the steps required to upgrade your Kubernetes cluster created with kubeadm.

Before You Begin

Before diving into the upgrade process, it’s crucial to prepare your environment:

  1. Read the Release Notes: Start by carefully reading the release notes for the version you intend to upgrade to. This will help you understand what changes and improvements are included.

  2. Backup Critical Components: While kubeadm upgrade primarily targets Kubernetes internal components and not your workloads, it’s always a best practice to back up any critical components, like app-level data stored in a database.

  3. Disable Swap: Ensure that swap is disabled on your nodes. Kubernetes doesn’t work well with swap, so this step is essential for smooth operations.

Changing the Package Repository

If you are using the community-owned package repositories (pkgs.k8s.io), you should enable the package repository for the desired Kubernetes minor release. The legacy repositories (apt.kubernetes.io and yum.kubernetes.io) are deprecated and frozen. Make sure to use the new package repositories hosted at pkgs.k8s.io for versions released after September 13, 2023.

Determining Which Version to Upgrade To

To determine the latest patch release for Kubernetes 1.28 using the OS package manager, follow these commands based on your operating system:

Ubuntu, Debian, or HypriotOS:
				
					# Find the latest 1.28 version in the list.
apt update
apt-cache madison kubeadm

				
			
CentOS, RHEL, or Fedora:
				
					# Find the latest 1.28 version in the list.
yum list kubeadm --showduplicates | sort -r

				
			
Upgrading Control Plane Nodes

The control plane nodes are the heart of your Kubernetes cluster, and upgrading them is a crucial process. Here are the steps for upgrading a control plane node:

1.Upgrade kubeadm:
Ubuntu, Debian, or HypriotOS:
				
					# Replace x with the latest patch version
apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='1.28.x-*' && \
apt-mark hold kubeadm

				
			
CentOS, RHEL, or Fedora:
				
					# Replace x with the latest patch version
yum install kubeadm-1.28.x-*

				
			
2.Verify the upgrade:
				
					kubeadm version
kubeadm upgrade plan

				
			
3.Upgrade to the desired version:
				
					sudo kubeadm upgrade apply v1.28.x

				
			
4.Manually upgrade your CNI provider plugin if required.
5.Drain the node: Prepare the node for maintenance by marking it unschedulable and evicting the workloads:
				
					sudo kubeadm upgrade apply v1.28.x

				
			
6.Upgrade kubelet and kubectl:
Ubuntu, Debian, or HypriotOS:
				
					# Replace x with the latest patch version
apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='1.28.x-*' && \
apt-mark hold kubeadm

				
			
7.Restart the kubelet:
				
					kubeadm version
kubeadm upgrade plan

				
			
8.Uncordon the node: Bring the node back online by marking it schedulable:
				
					kubectl uncordon 

				
			
Upgrading Worker Nodes

Upgrading worker nodes is similar but should be executed carefully to avoid compromising the minimum required capacity for running your workloads. Detailed instructions for upgrading both Linux and Windows worker nodes can be found in the official documentation.

Verify the Status of the Cluster

After completing the upgrade process, ensure that all nodes are available and healthy by running:

				
					kubectl get nodes


				
			

The STATUS column should display “Ready” for all your nodes, and the version number should reflect the upgrade.

By following these steps, you can keep your Kubernetes cluster up-to-date and ensure its reliability and security. Stay tuned for further updates and enhancements in the Kubernetes ecosystem. Happy clustering!