“Failed to run kubelet” err=”failed to run Kubelet: misconfiguration: kubelet cgroup driver: \”systemd\” is different from docker cgroup driver

With support of different type of container runtimes provided with current kubernetes release, one of important aspect to consider is using same cgroup manager for both kubelet and container runtime engines so resource allocation to pods can be managed centrally.

While, kubelet service itself integrates with linux default “systemd” as cgroup manager, runtime engines like docker use “cgroupfs”. You may verify this by running docker info for your setup.

root@ubworker:/home/ubuntu# docker info | grep cgroup
WARNING: No swap limit support
 Cgroup Driver: cgroupfs
root@ubmaster:/home/ubuntu# cat /var/lib/kubelet/config.yaml | grep cgroup
cgroupDriver: systemd

Now as you can get idea here, if we leave both services to use their default resource manager, design of my kubernetes cluster may not work as expected. To avoid, we need to change resource group manager for either of them.

Solution 1 : Changing resource manager for docker from cgroupfs to systemd

Steps may be different for Solution 1 if we using CentOS or Ubuntu. Since my lab is running on Ubuntu 20 LTS, I will share steps for same. Since you know now, reason for this error, jut google yourself steps for CentOS, LOL.

root@ubmaster:/home/ubuntu# vi /usr/lib/systemd/system/docker.service

Specify, inside above system file for docker service, below parameter under “[Service] section,

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd

Reload system daemon and restart docker service

root@ubworker:/home/ubuntu#  systemctl daemon-reload
root@ubworker:/home/ubuntu# systemctl restart docker

Verify changes by docker info,

root@ubworker:/home/ubuntu# docker info | grep Cgroup
WARNING: No swap limit support
 Cgroup Driver: systemd

Solution 2 : Changing resource manager for kubelet to systemd

While default cgroup manager is “systemd”, we may have scenario where while initializing cluster, argument of using “cgroupfs” may be specified. To revert back to systemd in this case can be done by initializing cluster using kubeadm.

# kubeadm-config.yaml
kind: ClusterConfiguration
apiVersion: kubeadm.k8s.io/v1beta3
kubernetesVersion: v1.21.0
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
cgroupDriver: systemd

Initializing using kubeadm,

kubeadm init --config kubeadm-config.yaml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s