I have struggled with this a bit and the answer of @Bogd got me onto the right track. Too long to comment, so here are the steps taken to configure a stable Kubernetes 1.26 master on a new Ubuntu 22.04 node using Flannel.
sudo apt-get update
sudo apt install apt-transport-https curl
Install containerd (reference: https://docs.docker.com/engine/install/ubuntu/)
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install containerd.io
Create containerd configuration
sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml
Edit /etc/containerd/config.toml
sudo nano /etc/containerd/config.toml
set SystemdCgroup = true
sudo systemctl restart containerd
Install Kubernetes
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt install kubeadm kubelet kubectl kubernetes-cni
Disable swap
sudo swapoff -a
Check and remove any swap entry if exists
sudo nano /etc/fstab
Avoid error "/proc/sys/net/bridge/bridge-nf-call-iptables does not exist" on kubeinit (reference https://github.com/kubernetes/kubeadm/issues/1062). This is not necessary if docker is also installed in step 6.
sudo modprobe br_netfilter
sudo nano /proc/sys/net/ipv4/ip_forward
Edit entry in ip_forward file and change to 1.
(Or use sysctl -w net.ipv4.ip_forward=1
- thanks to @dpjanes, see comments)
kubeinit for use with Flannel
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Copy to config as kubadm command says
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Apply Flannel (reference https://github.com/flannel-io/flannel)
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.20.2/Documentation/kube-flannel.yml
All should be running now:
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-mcjmm 1/1 Running 0 76s
kube-system coredns-787d4945fb-fb59g 1/1 Running 0 8m8s
kube-system coredns-787d4945fb-t25tj 1/1 Running 0 8m8s
kube-system etcd-kube-master 1/1 Running 0 8m19s
kube-system kube-apiserver-kube-master 1/1 Running 0 8m19s
kube-system kube-controller-manager-kube-master 1/1 Running 0 8m19s
kube-system kube-proxy-2hz29 1/1 Running 0 8m8s
kube-system kube-scheduler-kube-master 1/1 Running 0 8m19s