Computer Science
Algorithm
Data Processing
Digital Life
Distributed System
Distributed System Infrastructure
Upgrade Kubernetes from 1.23 to 1.24 (2023)
Machine Learning
Operating System
Android
Linux
Tizen
Windows
iOS
Programming Language
C++
Erlang
Go
Scala
Scheme
Type System
Software Engineering
Storage
UI
Flutter
Javascript
Virtualization
Life
Life in Guangzhou (2013)
Recent Works (2013)
东京之旅 (2014)
My 2017 Year in Review (2018)
My 2020 in Review (2021)
十三年前被隔离的经历 (2022)
A Travel to Montreal (2022)
My 2022 in Review (2023)
Travel Back to China (2024)
Projects
Bard
Blog
RSS Brain
Scala2grpc
Comment Everywhere (2013)
Fetch Popular Erlang Modules by Coffee Script (2013)
Psychology
耶鲁大学心理学导论 (2012)
Thoughts
Chinese
English

Upgrade Kubernetes from 1.23 to 1.24

Posted on 22 May 2023, tagged KubernetescontainerDockerLinux

In the last blog post, I introduced using Kubernetes to setup high available infrastructure. I had that setup a long time ago. I did the long overdue upgrade for Kubernetes from 1.23 to 1.24 recently. Since GlusterFS is deprecated(though not removed) in 1.25, I have no plans to continue the upgrade without exploring alternative storage options.

There is a big change from 1.23 to 1.24 as well, namely, Docker Engine support has been removed. I migrated the container engine to containerd. But the process is not without pain. I need to search different sources to fix the issues. So I list my upgrade steps so that if anyone has the same issue, this may help.

My Kubernetes cluster is set up locally with kubeadm. There is an official upgrade guide for kubeadm to upgrade from 1.23 to 1.24, but it doesn’t mention any steps to remove Docker and setup containerd. So here are the steps I took:

  1. Add --container-runtime-endpoint option to kubelet. The way I did it is adding KUBELET_ARGS="--container-runtime-endpoint=/run/containerd/containerd.sock" to /etc/kubernetes/kublet.env. Without this, Kubelet will fail to start.
  2. Remove --network-plugin=cni from /var/lib/kubelet/kubeadm-flags.env.
  3. Add the following configuration in /etc/crictl.yaml, otherwise kubeadm will not be able to pull needed images:
    runtime-endpoint: unix:///run/containerd/containerd.sock
    image-endpoint: unix:///run/containerd/containerd.sock
    timeout: 10
    debug: false
    
  4. Configure SystemdCgroup permission for containerd. Otherwise kube-apiserver will always be restarted because of “sandbox environment changes” (see more in Github issue):
    sudo mkdir -p /etc/containerd/
    containerd config default | sudo tee /etc/containerd/config.toml
    sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
    sudo systemctl restart containerd
    
  5. Follow the official upgrade guide.
  6. After the upgrade, remember to restart Docker so that the old containers started by Docker will be stopped.