部署k8s时候,kubelet 报错failed to run Kubelet: misconfiguration: kubelet cgroup driver: “systemd” is different from docker cgroup driver: “cgroupfs”

这是因为kubelet的cgroup和docker的不一致所导致的,“kubelet cgroup驱动为systemd,而docker的为cgroupfs”,有两种决解决方式,方式一:修改docker的cgroup为systemd

修改docker服务的配置文件,“/etc/docker/daemon.json ”文件,添加如下

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://zydpncxr.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF

编辑完后需要重启 docker 服务

sudo systemctl daemon-reload
sudo systemctl restart docker

查看docker的cgroup

docker info |grep "Cgroup Driver"
 Cgroup Driver: systemd #表明已经更新为了systemd

然后重启下kuberlet:

sudo systemctl restart kubelet
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐