1、报错:
error: failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd
2、原因:
kubelet文件驱动默认cgroupfs, 而我们安装的docker使用的文件驱动是systemd, 造成不一致, 导致镜像无法启动。
3、处理:
现在有两种方式, 一种是修改docker, 另一种是修改kubelet。
网上大部分说修改daemon.josn
#修改daemon.json
vi /etc/docker/daemon.json
#添加如下属性
"exec-opts": [
"native.cgroupdriver=systemd"
]
这样会导致修改后,docker无法启动成功,提示daemon.json与/lib/systemd/system/docker.service中native.cgroupdriver=systemd重复存在。
4、操作修改docker.service
(1)修改前查看docker Cgroup Driver
shell> docker info | grep Driver
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Storage Driver: overlay2
Logging Driver: json-file
Cgroup Driver: systemd
...
(2)修改docker.service
shell> vi /lib/systemd/system/docker.service
找到
--exec-opt native.cgroupdriver=systemd
修改为:
--exec-opt native.cgroupdriver=cgroupfs
(3)重启docker
shell> systemctl daemon-reload
shell> systemctl restart docker
(4)重启kubelet
shell> systemctl restart kubelet
(5)查看k8s集群,node是否正常
shell> kubectl get node
NAME STATUS ROLES AGE VERSION
node140 Ready master 126d v1.17.0