detected “cgroupfs” as the Docker cgroup driver. The recommended driver is “systemd”

When you run kubeadm init to create a token for the cluster, cgroup driver error appears as below.

[email protected]:~# kubeadm init –apiserver-advertise-address=$IP_ADDR –apiserver-cert-extra-sans=$IP_ADDR –node-name $HOST_NAME –pod-network-cidr=193.168.0.0/16
W0416 21:25:59.142906 10872 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[init] Using Kubernetes version: v1.18.1
[preflight] Running pre-flight checks
[WARNING Firewalld]: no supported init system detected, skipping checking for services
[WARNING Service-Docker]: no supported init system detected, skipping checking for services
[WARNING IsDockerSystemdCheck]: detected “cgroupfs” as the Docker cgroup driver. The recommended driver is “systemd”. Please follow the guide at https://kubernetes.io/docs/setup/cri/
[WARNING Hostname]: hostname “vagrant-ubuntu-trusty-64” could not be reached
[WARNING Hostname]: hostname “vagrant-ubuntu-trusty-64”: lookup vagrant-ubuntu-trusty-64 on 10.0.2.3:53: no such host
[WARNING Service-Kubelet]: no supported init system detected, skipping checking for services error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR FileExisting-nsenter]: nsenter not found in system path
[preflight] If you know what you are doing, you can make a check non-fatal with –ignore-preflight-errors=…
To see the stack trace of this error execute with –v=5 or higher

kubelet, docker and containerd must run with the same cgroup driver called “systemd”.

  • Change the “kubelet” cgroup configuration from “cgroups” to “systemd”.

[email protected]:/sys# nano /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS=”–cgroup-driver=systemd–network-plugin=cni –pod-infra-container-image=k8s.gcr.io/pause:3.2″
[email protected]:/sys#

#### To use the systemd cgroup driver, set plugins.cri.systemd_cgroup ###
[email protected]:/sys# nano /etc/containerd/config.toml
[plugins.cri]
systemd_cgroup = true

systemctl restart containerd
systemctl daemon-reload
systemctl restart kubelet

  • Change the “docker” cgroup configuration to from “cgroups” to “systemd” with adding ” –exec-opt native.cgroupdriver=systemd” as below.

[email protected]:~#nano /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// –containerd=/run/containerd/containerd.sock –exec-opt native.cgroupdriver=systemd

systemctl daemon-reload
systemctl restart docker

Kubelet, docker and containerd services must be in “active(running)” state with the “systemd” cgroup driver.

[email protected]:~$ systemctl status kubelet.service | grep “Active\|cgroup”
Active: active (running) since Wed 2020-05-06 19:28:01 UTC; 10min ago
└─1231 /usr/bin/kubelet –bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf –kubeconfig=/etc/kubernetes/kubelet.conf –config=/var/lib/kubelet/config.yaml –cgroup-driver=systemd –network-plugin=cni –pod-infra-container-image=k8s.gcr.io/pause:3.2
[email protected]:~$

[email protected]:~$ systemctl status docker | grep “Active\|cgroup”
Active: active (running) since Wed 2020-05-06 19:28:08 UTC; 10min ago
└─1239 /usr/bin/dockerd -H fd:// –containerd=/run/containerd/containerd.sock –exec-opt native.cgroupdriver=systemd

[email protected]:~$ systemctl status containerd.service | grep “Active\|cgroup”
Active: active (running) since Wed 2020-05-06 19:28:01 UTC; 10min ago
├─ 2659 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/ef2dbe7c25125d55ccfb5f102dd854b41860e88b0494ead8c3279ade1bae8136 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc –systemd-cgroup
[email protected]:~$

Series Navigation<< Kubelet folder is missing on worker nodeNo supported authentication methods available [server sent:publickey] >>