Exercise
In this exercise you will upgrade your cluster to the next minor version.
- Check the version of your cluster
$ kubectl get no
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 32m v1.32.4
worker1 Ready <none> 23m v1.32.4
worker2 Ready <none> 18m v1.32.4- Upgrade the controlplane Node
Run a shell on the controlplane Node and change the file /etc/apt/sources.list.d/kubernetes.list so it references version 1.33 instead of 1.32:
Before:
deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /After:
deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /Check the latest version of kubeadm
sudo apt update
sudo apt-cache madison kubeadmYou will be returned the available versions in the 1.33 family. In this exercice we will upgrade to version 1.33.0, but newer patch versions may exist at the time you are doing it.
First upgrade kubeadm to the new version:
VERSION=1.33.0-1.1
sudo apt-mark unhold kubeadm && \
sudo apt-get update && \
sudo apt-get install -y kubeadm=$VERSION && \
sudo apt-mark hold kubeadmNext simulate the upgrade
sudo kubeadm upgrade planIf the previous command went fine we can run the upgrade
sudo kubeadm upgrade apply v1.33.0Next drain the controlplane Node to prepare it for maintenance
kubectl drain controlplane --ignore-daemonsetsNext upgrade kubelet and kubectl:
VERSION=1.33.0-1.1
sudo apt-mark unhold kubelet kubectl && \
sudo apt-get update && \
sudo apt-get install -y kubelet=$VERSION kubectl=$VERSION && \
sudo apt-mark hold kubelet kubectlThen restart kubelet
sudo systemctl daemon-reload
sudo systemctl restart kubeletNext uncordon the controlplane Node
kubectl uncordon controlplaneIf we check the version, we can see the controlplane Node has been upgraded:
$ kubectl get no
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 35m v1.33.0
worker1 Ready <none> 26m v1.32.4
worker2 Ready <none> 21m v1.32.4kubeadm upgrade NODE_IDENTIFIER- Upgrade the worker Nodes
First run a shell on worker1.
As you did for the controlplane Node, change the file /etc/apt/sources.list.d/kubernetes.list so it references version 1.33 instead of 1.32.
Next, upgrade the kubeadm binary:
VERSION=1.33.0-1.1
sudo apt-mark unhold kubeadm && \
sudo apt-get update && \
sudo apt-get install -y kubeadm=$VERSION && \
sudo apt-mark hold kubeadmNext run the upgrade
sudo kubeadm upgrade nodeNext, drain the Node (run the following command from the controlplane Node):
kubectl drain worker1 --ignore-daemonsetsThen, upgrade kubelet and kubectl:
VERSION=1.33.0-1.1
sudo apt-mark unhold kubelet kubectl && \
sudo apt-get update && \
sudo apt-get install -y kubelet=$VERSION kubectl=$VERSION && \
sudo apt-mark hold kubelet kubectlThen restart kubelet
sudo systemctl daemon-reload
sudo systemctl restart kubeletNext, uncordon the worker Node, making it “schedulable” again (run the following command from the controlplane Node):
kubectl uncordon worker1If we check the versions, we can see the controlplane Node and the worker1 are now both upgraded:
$ kubectl get no
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 36m v1.33.0
worker1 Ready <none> 27m v1.33.0
worker2 Ready <none> 22m v1.32.4- Accessing the upgraded cluster
After the above steps are done on the other worker node, the cluster will be fully upgraded cluster:
$ kubectl get no
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 38m v1.33.0
worker1 Ready <none> 29m v1.33.0
worker2 Ready <none> 24m v1.33.0