K8S集群启动报错kubelet cgroup driver: “cgroupfs“ is different from docker cgroup driver: “systemd“

K8S集群启动报错 kubelet cgroup driver: “cgroupfs” is different from docker cgroup driver: “systemd”

master节点初始化的时候,docker配置如下,忘了设置cgroup driver: “systemd

vim /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=cgroupfs"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ],
  "registry-mirrors": ["https://pf5f57i3.mirror.aliyuncs.com"]
}

k8s 主节点安装k8s,有错误提示但是启动了,其他主节点和node节点加入也正常,看到整个集群都Ready,回去在修改主节点的 /etc/docker/daemon.json,native.cgroupdriver=systemd,改完重启kubelet后,发现3个主节点都起不来了。

journalctl -f -u kubelet 查看日志发现,报错如下:

kubelet cgroup driver: “cgroupfs” is different from docker cgroup driver: “systemd”

这个里要修改3个配置文件为systemd

1.vim /etc/docker/daemon.json

“exec-opts”: [“native.cgroupdriver=systemd”]

2.vim /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf

在KUBELET_KUBECONFIG_ARGS 后面追加 --cgroup-driver=systemd

Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --cgroup-driver=systemd"
3.vim /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.2"

systemctl daemon-reload
systemctl restart kubelet

然后重启kubelet,k8s集群就恢复了。

你可能感兴趣的:(k8s,docker,linux,kubernetes)