We will be using docker as container run time, please follow the steps to install docker mentioned in this block
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)
step1
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
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
EOF
# Apply sysctl params without reboot
sudo sysctl --system
Step2: sudo mkdir -p -m 755 /etc/apt/keyrings curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/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.30/deb/ /' | 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.
step3
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 10.1.0.0/16
kubeadm init --pod-network-cidr=10.244.0.0/16
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 https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Run command after 5 min
kubectl get nodes #Node must come ready #NAME STATUS ROLES AGE VERSION #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 172.16.207.130:6443 --token r6i5ud.xyt1242cyo95ig68 --discovery-token-ca-cert-hash sha256:6717f453c5a347dcec6499b63fad0351d1986d19f2f8c3455dc8b3d03707e16a mkdir /root/.kube cp /etc/kubernetes/kubelet.conf /root/.kube/config kubectl get nodes