DEV Community

Cover image for Upgrading a Kubernetes v1.28 Cluster using kubeadm
Unni P
Unni P

Posted on • Edited on • Originally published at iamunnip.hashnode.dev

Upgrading a Kubernetes v1.28 Cluster using kubeadm

In this article, we will look how we can upgrade a three node Kubernetes v1.28 cluster using kubeadm

Prerequisites

  • We need a working Kubernetes cluster created using kubeadm

  • If you haven’t created the cluster, please check my previous article below
    This will guide you to create a Kubernetes v1.28.0 cluster
    Building a Kubernetes v1.28 Cluster using kubeadm

Upgrade Process

Control Plane

Verify the version of our cluster

# control-plane kubectl get nodes NAME STATUS ROLES AGE VERSION control-plane Ready control-plane 3m6s v1.28.0 node-1 Ready <none> 43s v1.28.0 node-2 Ready <none> 37s v1.28.0 
Enter fullscreen mode Exit fullscreen mode

Update the package index and find the latest kubeadm patch available in the repository

# control-plane sudo apt update sudo apt-cache madison kubeadm 
Enter fullscreen mode Exit fullscreen mode

Unhold the kubeadm package for upgrading

# control-plane sudo apt-mark unhold kubeadm 
Enter fullscreen mode Exit fullscreen mode

Upgrade the kubeadm package to version v1.28.1 and hold the package from automatic upgrading

# control-plane sudo apt install -y kubeadm=1.28.1-1.1 sudo apt-mark hold kubeadm 
Enter fullscreen mode Exit fullscreen mode

Check the upgraded kubeadm version and verify the upgrade plan

# control-plane sudo kubeadm version sudo kubeadm upgrade plan 
Enter fullscreen mode Exit fullscreen mode

Once our plan is verified, we can upgrade the control-plane by executing the below command

# control-plane sudo kubeadm upgrade apply v1.28.1 
Enter fullscreen mode Exit fullscreen mode

Prepare the control-plane for maintenance by marking it unschedulable and evicting the workloads

# control-plane kubectl drain control-plane --ignore-daemonsets 
Enter fullscreen mode Exit fullscreen mode

Unhold the kubelet and kubectl packages for an upgrade

# control-plane sudo apt-mark unhold kubelet kubectl 
Enter fullscreen mode Exit fullscreen mode

Upgrade kubelet and kubectl packages to version v1.28.1 and hold the packages from automatic upgrading

# control-plane sudo apt install kubelet=1.28.1-1.1 kubectl=1.28.1-1.1 sudo apt-mark hold kubelet kubectl 
Enter fullscreen mode Exit fullscreen mode

Restart the kubelet service on control-plane

# control-plane sudo systemctl daemon-reload sudo systemctl restart kubelet 
Enter fullscreen mode Exit fullscreen mode

Uncordon the control-plane for marking it as schedulable

# control-plane kubectl uncordon control-plane 
Enter fullscreen mode Exit fullscreen mode

Verify the nodes, now we can see control-plane is upgraded to v1.28.1

# control-plane kubectl get nodes NAME STATUS ROLES AGE VERSION control-plane Ready control-plane 9m17s v1.28.1 node-1 Ready <none> 6m54s v1.28.0 node-2 Ready <none> 6m48s v1.28.0 
Enter fullscreen mode Exit fullscreen mode

Nodes

Update the package index on node-1 and node-2 and unhold the kubeadm package for upgrading

# node-1 and node-2 sudo apt update sudo apt-mark unhold kubeadm 
Enter fullscreen mode Exit fullscreen mode

Upgrade the kubeadm package to version v1.28.1 on node-1 and node-2 and hold the package from automatic upgrading

# node-1 and node-2 sudo apt install kubeadm=1.28.1-1.1 sudo apt-mark hold kubeadm 
Enter fullscreen mode Exit fullscreen mode

Upgrade the cluster configuration on node-1 and node-2 using the below command

# node-1 and node-2 sudo kubeadm upgrade node 
Enter fullscreen mode Exit fullscreen mode

Prepare node-1 and node-2 for maintenance by marking them as unschedulable and evicting the workloads

Execute the below drain command on control-plane

# control-plane kubectl drain node-1 --ignore-daemonsets --force kubectl drain node-2 --ignore-daemonsets --force 
Enter fullscreen mode Exit fullscreen mode

Unhold the kubelet and kubectl packages for an upgrade

# node-1 and node-2 sudo apt-mark unhold kubelet kubectl 
Enter fullscreen mode Exit fullscreen mode

Upgrade kubelet and kubectl packages to version v1.28.1 and hold the packages from automatic upgrading

# node-1 and node-2 sudo apt install kubelet=1.28.1-1.1 kubectl=1.28.1-1.1 sudo apt-mark hold kubelet kubectl 
Enter fullscreen mode Exit fullscreen mode

Restart the kubelet service on node-1 and node-2

# node-1 and node-2 sudo systemctl daemon-reload sudo systemctl restart kubelet 
Enter fullscreen mode Exit fullscreen mode

Uncordon node-1 and node-2 for marking it as schedulable

Execute the below uncordon command on the control-plane

# control-plane kubectl uncordon node-1 kubectl uncordon node-2 
Enter fullscreen mode Exit fullscreen mode

Now our cluster is fully upgraded to v1.28.1

Verify the same by executing the below command on the control-plane

# control-plane kubectl get nodes NAME STATUS ROLES AGE VERSION control-plane Ready control-plane 14m v1.28.1 node-1 Ready <none> 11m v1.28.1 node-2 Ready <none> 11m v1.28.1 
Enter fullscreen mode Exit fullscreen mode

Reference

https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/

Top comments (0)