kubelet从错误的配置文件中读取?

时间:2017-11-08 02:04:42

标签: kubernetes kubeadm kubelet

当我运行kubelet version时,收到一条错误消息,结尾于:

error: failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"

但是当我检查位于/etc/systemd/system/kubelet.service.d/10-kubeadm.conf的配置文件时,我看到了IS systemd的值。我更改了值并在每次更改之间完成了systemctl daemon-reloadsystemctl restart kubelet,并且错误消息始终相同。

我猜它必须从错误的配置文件中读取,但我怎样才能找到它的读取位置!

1 个答案:

答案 0 :(得分:0)

尝试一下:

kubelet  --cgroup-driver=systemd version

“ docker”软件包(1.13.1)已将“ systemd”作为默认的cgroup驱动程序,请参见this

文件驱动程序默认更改为systemd cgroupfs,而我们安装的docker文件驱动程序为systemd,这是由于不一致导致映像无法启动。

     docker info 

...
     Cgroup Driver: systemd

现在有两种方法,一种是修改docker,另一种是修改kubelet,

修改docker:# 修改或创建/etc/docker/daemon.json并添加以下内容:

{
  "exec-opts": ["native.cgroupdriver=systemd"]
}

重启docker:

systemctl restart docker
systemctl status docker

修改kubelet:#

vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/sysconfig/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

将以下内容--cgroup-driver=systemd添加到$ KUBELET_EXTRA_ARGS。

或者:

$ DOCKER_CGROUPS=$(docker info | grep 'Cgroup' | cut -d' ' -f3)
$ echo $DOCKER_CGROUPS

$ cat >/etc/sysconfig/kubelet<<EOF
KUBELET_CGROUP_ARGS="--cgroup-driver=$DOCKER_CGROUPS"
EOF

#restart
$ systemctl daemon-reload
$ systemctl enable kubelet && systemctl restart kubelet

或者:

DOCKER_CGROUPS=$(docker info | grep 'Cgroup' | cut -d' ' -f3)
echo $DOCKER_CGROUPS
cat >/etc/sysconfig/kubelet<<EOF
KUBELET_EXTRA_ARGS="--cgroup-driver=$DOCKER_CGROUPS"
EOF

# restart
$ systemctl daemon-reload
$ systemctl enable kubelet && systemctl restart kubelet