Setup Kubernetes Master using kubeadm

We will be using docker as container run time, please follow the steps to install docker mentioned in this block

Docker lab setup on Ubuntu 22.04 Server LTS

Use sudo or login as root user “sudo su -“


Lab :Configuring Repo and Installation for ubuntu 

Ubuntu 22.04

Run in both ubuntu vms (step 1 ,step2 and step3)


cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf

sudo modprobe overlay
sudo modprobe br_netfilter

# sysctl params required by setup, params persist across reboots
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1

# Apply sysctl params without reboot
sudo sysctl --system

curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

apt-get update

sudo apt-get install -y kubelet kubeadm kubectl

swap space can potentially interfere with this isolation. When a system is under memory pressure and starts swapping out memory to disk, it can lead to unpredictable performance and behavior for applications running inside containers.


swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab

Docker as runtime updating for k8s,This is important because Kubernetes requires all its components, and the container runtime uses systemd for cgroups.:

sh -c "containerd config default > /etc/containerd/config.toml"
sed -i 's/ SystemdCgroup = false/ SystemdCgroup = true/' /etc/containerd/config.toml
systemctl restart containerd.service
systemctl restart kubelet.service
systemctl enable kubelet.service

step4 : Runs only in master node

Initialize Cluster with kubeadm.kubeadm init, is used to initialize a Kubernetes control-plane node. The --pod-network-cidr flag specifies the range of IP addresses for the pod network in your cluster. The

kubeadm init --pod-network-cidr=

To start using your cluster, you need to run the following as a regular user:

Note: copy the kubeadm join output and save in notepad

Step5: Runs only in master node
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Install the network plugin in master node

step 6: only in master
 kubectl apply -f

Run command after 5 min

kubectl get nodes

#Node must come ready
#okdmaster Ready control-plane 4m40s v1.26.5

#If "Not Ready" persist, please restart the containerd service
systemctl restart containerd

Now run the kubeadm join command in client node (step 1,step2,step3)

Run the kubeadm join command which you have copied after kubeadm init

After kubeadm join command:

In case you missed the kubeadm join command, run the below command to get it again on master:

kubeadm token create --print-join-command
#On the worker node, please run,

modprobe br_netfilter

echo '1' > /proc/sys/net/ipv4/ip_forward

#Below is example, please run your copied kubeadm join command

#kubeadm join --token r6i5ud.xyt1242cyo95ig68 --discovery-token-ca-cert-hash sha256:6717f453c5a347dcec6499b63fad0351d1986d19f2f8c3455dc8b3d03707e16a
mkdir /root/.kube
cp /etc/kubernetes/kubelet.conf /root/.kube/config
kubectl get nodes