At some point, if you are the kubernetes administrator, you might be tasked to upgrade the kubernetes cluster. The best way to upgrade kube is using kubeadm tool. The recommendation approach is to upgrade all the components of cluster kubeadm, kubelet, kubectl and all system pods/ daemon to the same version. In this post, I walk you through the upgrade of kubernetes cluster to 1.27.0.
Fist verify existing cluster details information …
kubectl get nodes -o wide
kubelet --version
kubectl version --short
kubeadm version
Here the existing kubernets version is v1.26.0
Let’s prepare and upgrade.
## Upgrade apt-get repo and view the available kubeadm version
sudo apt-get update && sudo apt-cache madison kubeadm
##Install kubeadm tool
sudo apt-get install -y --allow-change-held-packages kubeadm=1.27.0-00
##This command verifies the cluster upgrade plan and checks for any potential issues before performing the actual upgrade...
kubeadm upgrade plan
##upgrade cluster and system daemon
kubeadm upgrade apply v1.27.0
After upgrade the kubeadm and system daemon, drain the application pods to other hosts and place the node into maintenance mode. Once the node is in the maintenance mode, the scheduler will not be scheduled kubernetes pods into that node.
#drain and cordon the node (cordon mean put into maintenance mode)
##when you apply drain command, the node is automatically put into cordon
kubectl drain <node-name>
##upgrade kubelet and kubectl client tool to version 1.27.0
sudo apt-get install -y --allow-change-held-packages kubelet=1.27.0-00 kubectl=1.27.0-00
##Restart the service
systemctl daemon-reload
systemctl restart kubelet
##Verification
kubectl get nodes -o wide
kubelet --version
kubectl version --short
kubeadm version
## Make sure to leave from maintenance mode
kubectl uncordon <node-name>
It is highly recommended that the cluster status and version should be checked in every steps if upgrading production cluster.
0 Comments