When I am first learning about Kubernetes, I am using minikube. But it was all too easy. I want to learn how to set it up from the ground up. What packages are involved, what dependencies, what configuration files should I look for. The answer to this is kubeadm.

kubeadm is a command line tool that lets me create a Kubernetes cluster from scratch. But before I can usekubeadm, I have to install some packages and configure some os-level stuff.

I will use Red Hat Enterprise Linux (RHEL) to run my Kubernetes cluster. These are the steps in broad strokes:

  1. Install all kubernetes package dependencies
dnf install curl gpg ca-certificates iproute-tc -y
  1. Create and activate modprobe modules for Kubernetes networking
touch /etc/modules-load.d/containerd.conf
echo "overlay" > /etc/modules-load.d/containerd.conf
echo "br_netfilter" >> /etc/modules-load.d/containerd.conf
modprobe overlay
modprobe br_netfilter
  1. Configure kernel parameters using sysctl for networking
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.d/99-kubernetes-cri.conf
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.d/99-kubernetes-cri.conf
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.d/99-kubernetes-cri.conf
sysctl --system
  1. Download and setup containerd
wget https://github.com/containerd/containerd/releases/download/v1.7.16/containerd-1.7.16-linux-amd64.tar.gz -P /tmp/

tar Cxzvf /usr/local /tmp/containerd-1.7.16-linux-amd64.tar.gz

wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service -P /etc/systemd/system
  1. Download and setup runc
wget https://github.com/opencontainers/runc/releases/download/v1.1.12/runc.amd64 -P /tmp/

dnf install -m 755 /tmp/runc.amd64 /usr/local/sbin/runc
  1. Download and configure cni
wget https://github.com/containernetworking/plugins/releases/download/v1.4.0/cni-plugins-linux-amd64-v1.4.0.tgz -P /tmp/

mkdir -p /opt/cni/bin
tar Cxvzf /opt/cni/bin /tmp/cni-plugins-linux-amd64-v1.4.0.tgz
  1. Disable swap on OS
vi /etc/fstab # comment-out the line with SWAP

swapoff -a
  1. Setup the Kubernetes repository on the server
vi /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key
  1. Download Kubernetes packages
dnf install  kubeadm kubelet kubectl
  1. Create a kubernetes control-plane which will act as the main brain of the Kubernetes cluster
kubeadm init --pod-network-cidr 192.168.120.0/24 --kubernetes-version 1.30.0 --node-name k8s-control
  1. Create kubernetes workers and join them to the kubernetes control-plane server
# run on control-plane
kubeadm token create --print-join-command

# run the output of previous command on worker node/s

I know this is far from perfect but its definitely a start.

With this, I can further learn how Kubernetes works on a deeper level. One step at a time..