This is a quick and short text on how to install Kubernetes on Ubuntu 22.04. Spend the last 2 weeks solving issues with Containerd and Kubernetes.
After reviewing the GitHub issue for Kubernetes - found this to solve a problem that I have.
The problem manifests as up/down for Kubernetes health and running buggy. On Ubuntu 20.04 there was no problem. The issue is connected with Containerd Cgroups settings for version 1.5.9 (any above this version would work fine, read a link that I provided on information). So let us start with installation.
Kubernetes map - from cloudsigma.com
Kubernetes setup on Ubuntu 22.04
Let me guess you have 2 machines, with Ubuntu 22.04 installed. First, will be used for the k8s control pane. The second will be used as a worker/pod.
Both machines have the same steps for k8s installation.
Please notice that the IP addresses I am using are from my network - so add proper IP for cp1 and worker1
Here you go for the k8s control pane and worker:
apt update apt upgrade echo is this IP of your machine? echo "192.168.50.204 worker1.example.com worker1" >> /etc/hosts echo "192.168.50.165 cp1.example.com cp1" >> /etc/hosts hostnamectl set-hostname cp1 hostnamectl set-hostname worker1 modprobe br_netfilter modprobe overlay cat << EOF | tee /etc/modules-load.d/k8s-modules.conf br_netfilter overlay EOF cat << EOF | tee /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 EOF sysctl --system apt-get update ; apt-get install -y containerd mkdir -p /etc/containerd containerd config default | tee /etc/containerd/config.toml sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml systemctl restart containerd swapoff -a apt-get install -y apt-transport-https curl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main" apt install -y kubeadm kubelet kubectl
After you finish these commands on both machines, you have an exclusive command for the k8s control pane and for the worker. For Control Pane:
kubeadm init --pod-network-cidr=192.168.0.0/16 mkdir -p $HOME/.kube cp -i /etc/kubernetes/admin.conf $HOME/.kube/config chown $(id -u):$(id -g) $HOME/.kube/config kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
After you finish this on the Control Pane machine, there will be a command printed similar to this and copy to CLI of worker1:
kubeadm join 192.168.50.165:6443 --token azlcfh.36lef5ty7890en1r6 --discovery-token-ca-cert-hash sha256:47a02b63e60278025d3423883a05a48e06f943195f06ebe414d929f60028e
Or you can execute on Control Pane and get printed:
kubeadm token create --print-join-command
and then execute on Worker1 command that is printed The output of this command is copied/past on the worker machine. You can add more worker machines with no problem.
If all goes ok you will be able to check with:
kubectl run curl --image=radial/busyboxplus:curl -i --tty
this would run a container on pods and you can see if the network and other parts are running ok. Type exit to leave the container. to delete this pod:
kubectl delete pods curl
You can also see how this goes with my video:
Thanks to this people
@Jocix84 and @Bojana_dev for support, direction, and inspiration!