I have recently upgraded my kubernetes cluster (1 master & 3 worker nodes) from Ubuntu 20.04 to 22.04 LTS as host operating system. I have documented the procedure below so you can do it also without the small caveats I have run into. The upgrade procedure takes about 60-70 minutes per node. You should execute this procedure on every node. It's recommended to do the workers first, and the master last.
Below is the procedure I have used. The values in red are example values, you need to change to your own worker (or master) node name. In the example below the node we are going to upgrade is called k8s-worker-01
Before starting this procedure a backup of the node is always recommended.
1. First up is to check if everything is working ok on your cluster.
ssh into your master node and type the command
kubectl get nodesYou should see something similar as the screenshot below
kubectl drain k8s-worker-01 --ignore-daemonsets --delete-emptydir-data
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo systemctl stop kubelet
sudo apt update && sudo apt dist-upgrade -y sudo apt install update-manager-core sudo apt autoremove sudo do-release-upgrade -d
sudo rm /etc/apt/sources.list.d/docker.list sudo rm /etc/apt/sources.list.d/kubernetes.list sudo mv /etc/apt/sources.list.d/docker.list.distUpgrade /etc/apt/sources.list.d/docker.list sudo mv /etc/apt/sources.list.d/kubernetes.list.distUpgrade /etc/apt/sources.list.d/kubernetes.list sudo apt update
sudo nano /etc/sysctl.conf
sudo apt install linux-modules-extra-raspi sudo reboot
kubectl get nodes
kubectl uncordon k8s-worker-01 kubectl get nodes