Kubernetes 1.26 on Ubuntu 22.04 LTS

Ubuntu is a very suitable distribution to run kubernetes because we have an up to date kernel with up to date features and packages are available widely.

Running kubernetes on Ubuntu is straight forward - except it requires packages that are newer than the upstream provides. This is the case on Kubernetes 1.26. As kubernetes 1.26 finally removes v1alpha2 CRI API it requires containerd >= 1.6.

Kubernetes Removals, Deprecations, and Major Changes in 1.26
Author: Frederico Muñoz (SAS)Change is an integral part of the Kubernetes life-cycle: as Kubernetes grows and matures, features may be deprecated, removed, or replaced with improvements for the health of the project. For Kubernetes v1.26 there are several planned: this article identifies and descri…

Get containerd 1.6 on Ubuntu 22.04

The regular ubuntu upstream mirrors provide (as of today) containerd with version 1.5 but not yet 1.6.

A suitable and trusted source for more recent builds of containerd is the use of a docker repository (which does not mean that we will install docker).

Removal of containerd

Before installing containerd from docker we need to remove containerd in it's current installation. The reason is that ubuntu upstream calls the package containerd whereas docker distributes it as containerd.io.

apt-mark unhold containerd
apt remove containerd -y
remove current containerd installation

Install containerd from docker repo

The installation is straight forward:

# kubernetes 1.26 requires at least 1.6
CONTAINERDVERSION=1.6.16-*
 
# add docker repo to apt (as docker distributes recent versions of containerd)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 
# install containerd and mark package for hold
apt-mark unhold containerd.io
apt update && apt install -y containerd.io=$CONTAINERDVERSION
apt-mark hold containerd.io
 
mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml
systemctl restart containerd
install containerd

It's also important to note that we provide a configuration file for containerd & restart the daemon afterwards. Otherwise the socket will not provide the appropriate response to kubeadm.

Adjust cgroup if required

It might happen (probably on new installations) that your pods keep crashing, especially noticable on etcd. This might depend on the cgroup driver you want to use. On ubuntu we're using systemd for this. To get it running, make an adjustment on the /etc/containerd/config.toml and enable the SystemdCgroup driver.

[plugins]
  [plugins."io.containerd.grpc.v1.cri"]
   [plugins."io.containerd.grpc.v1.cri".containerd]
      [plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
        [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
          runtime_type = "io.containerd.runc.v2"
          [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
            SystemdCgroup = true
/etc/containerd/config.toml

Source is here:

etcd keeps shutting down randomly on new self-managed k8s cluster via kubeadm · Issue #13670 · etcd-io/etcd
What happened? I'm following the Kubernetes documentation to set up a k8s cluster with kubeadm, using the containerd runtime. After setting up the k8s cluster with kubeadm, the following occurs...

That's all you need - have fun with kubernetes 1.26.