kubernetes-131-ubuntu-24-04-1

In this video I’ll explain how to set up a 3 nodes Kubernetes 1.31.3 cluster on Ubuntu 24.04.1 LTS.

I’m using my local IP space for the cluster nodes, which is in the 192.168.0.0/16 IP space, specifically 192.168.15.0/24. This means that I need to set the internal IP subnet of the cluster to something unrelated to that subnet, so technically it could be another /xx within the 192.168.0.0/16 IP space, but to make it obviously different for those that don’t understand subnetting, I’m going to set it to 10.10.0.0/16. This should even work for you, even if your home network is 10.0.0.0/24, because 10.10.0.0/16 doesn’t not overlap with 10.0.0.0/24. Either way, if your IP space is in the 10.0.0.0/8 space I’d recommend making the IP subnet in the Kubernetes cluster 192.168.0.0/16 instead.

We’re manually installing containerd, runc, cni plugins, and calico cni at specific version. I’ve updated the versions here to match what is required. But if you’d like you can review each of those components at the links below to see what you can use instead if you don’t want to follow the versions I’m using.

  _______  _______  _______  __  ___  __    __   _______     ___       _______
/ _____|| ____|| ____|| |/ / | | | | | ____| / \ | \
| | __ | |__ | |__ | ' / | |__| | | |__ / ^ \ | .--. |
| | |_ | | __| | __| | < | __ | | __| / /_\ \ | | | |
| |__| | | |____ | |____ | . \ | | | | | |____ / _____ \ | '--' |
\______| |_______||_______||__|\__\ |__| |__| |_______/__/ \__\ |_______/

UBUNTU SERVER LTS 24.04.1 - https://ubuntu.com/download/server
KUBERNETES 1.31.3 - https://kubernetes.io/releases/
CONTAINERD 1.7.24 - https://containerd.io/releases/
RUNC 1.2.2 - https://github.com/opencontainers/runc/releases
CNI PLUGINS 1.6.1 - https://github.com/containernetworking/plugins/releases
CALICO CNI 3.29.1 - https://docs.tigera.io/calico/3.29/getting-started/kubernetes/quickstart

3 NODES, 2 vCPU, 8 GB RAM, 50GB Disk EACH
k8s-control 192.168.15.93
k8s-1 192.168.15.94
k8s-2 192.168.15.95


### ALL:

sudo su

printf "\n192.168.15.93 k8s-control\n192.168.15.94 k8s-1\n192.168.15.95 k8s-1\n\n" >> /etc/hosts

printf "overlay\nbr_netfilter\n" >> /etc/modules-load.d/containerd.conf

modprobe overlay
modprobe br_netfilter

printf "net.bridge.bridge-nf-call-iptables = 1\nnet.ipv4.ip_forward = 1\nnet.bridge.bridge-nf-call-ip6tables = 1\n" >> /etc/sysctl.d/99-kubernetes-cri.conf

sysctl --system

wget https://github.com/containerd/containerd/releases/download/v1.7.24/containerd-1.7.24-linux-amd64.tar.gz -P /tmp/
tar Cxzvf /usr/local /tmp/containerd-1.7.24-linux-amd64.tar.gz
wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service -P /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now containerd

wget https://github.com/opencontainers/runc/releases/download/v1.2.2/runc.amd64 -P /tmp/
install -m 755 /tmp/runc.amd64 /usr/local/sbin/runc

wget https://github.com/containernetworking/plugins/releases/download/v1.6.1/cni-plugins-linux-amd64-v1.6.1.tgz -P /tmp/
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin /tmp/cni-plugins-linux-amd64-v1.6.1.tgz

<<<<<<<<<<< manually edit and change SystemdCgroup to true (not systemd_cgroup)
mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml
vi /etc/containerd/config.toml
systemctl restart containerd

swapoff -a <<<<<<<< just disable it in /etc/fstab instead

apt-get update
apt-get install -y apt-transport-https ca-certificates curl gpg

mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

apt-get update

reboot

sudo su

apt-get install -y kubelet=1.31.3-1.1 kubeadm=1.31.3-1.1 kubectl=1.31.3-1.1
apt-mark hold kubelet kubeadm kubectl

# check swap config, ensure swap is 0
free -m


############ ONLY RUN THE FOLLOWING ON CONTROL NODE .. control plane install ########
kubeadm init --pod-network-cidr 10.10.0.0/16 --kubernetes-version 1.31.3 --node-name k8s-control

export KUBECONFIG=/etc/kubernetes/admin.conf

# add Calico 3.29.1 CNI <<<<<< edit the CIDR for pods if its custom
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/tigera-operator.yaml
wget https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/custom-resources.yaml
vi custom-resources.yaml
kubectl apply -f custom-resources.yaml

# get worker node commands to run to join additional nodes into cluster
kubeadm token create --print-join-command
######################################################################################


### ONLY ON WORKER nodes
Run the command from the token create output above

### Tag nodes for worker
kubectl label node k8s-1 node-role.kubernetes.io/worker=worker