Kubeadm init fails
Kubeadm init fails
Problem statement:
In Kubernetes(K8S) 1.22 version, performing K8S installation using kubeadm is resulting in below error.
kubeadm init
Kubelet : Kubelet service isn’t active
Systemctl status kubelet
Check the kubelet log using journalctl command
journalctl -xeu kubelet
Reason
Before we look at the actual reason , lets look what is cgroup
Cgroup : Control groups are used to constrain resources that are allocated to processes. Cgroups are the kernel feature that allows you to set limits for CPU, memory, and disk I/O for one or more processes. By using cgroups, you can isolate a process and the process’s network
Cgroup drivers :
- Systemd
- Cgroup fs
systemd driver is recommended for kubeadm based setups instead of the cgroupfs driver, because kubeadm manages the kubelet as a systemd service.
Reason for above error is cgroup driver being cgroupfs instead of systemd.
Solution :
Change the cgroup driver to systemd from cgroupfs . Follow below steps
- On Master node perform the following steps
sudo vim /etc/docker/daemon.json
{
“exec-opts”: [“native.cgroupdriver=systemd”]
}
### Enter the above three lines in daemon.json and save it ( :wq! ) ###
sudo systemctl daemon-reload
sudo systemctl restart kubelet.service
####reboot the machine before the init command ####
sudo kubeadm init –ignore-preflight-errors=all
# As you would have run kubeadm init command already, running the same command again will through error . To overcome that use the options –ignore-preflight-errors=all
- Repeat the same on worker node . But do not run kubeadm init on worker nodes.
- Once you have changed the cgroup driver, run the kubeadm join command
Register now at CubenSquare to know more!!