Kubernetes cgroup driver 变更方式
现象
failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
文件驱动默认由systemd
改成cgroupfs
, 而我们安装的docker
使用的文件驱动是systemd
, 造成不一致, 导致镜像无法启动
运行时更改方式
Docker 更改方式
修改或创建/etc/docker/daemon.json
, 加入下面内容:
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
重启docker
sudo systemctl restart docker
sudo systemctl status docker
Containerd 更改方式
修改或创建/etc/containerd/config.toml
, 加入下面内容:
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
...
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
sudo systemctl restart containerd
sudo systemctl status containerd
CRI-O 更改方式
编辑 /etc/crio/crio.conf
或在 /etc/crio/crio.conf.d/02-cgroup-manager.conf
中放置一个插入式配置
[crio.runtime]
conmon_cgroup = "pod"
cgroup_manager = "systemd"
Kubelet 更改方式
对于集群中的需要变更的节点:
- 执行命令
kubectl drain <node-name> --ignore-daemonsets
,以 腾空节点 - 执行命令
systemctl stop kubelet
,以停止kubelet
- 停止容器运行时
- 运行时更改方式: 修改容器运行时
cgroup
驱动为systemd
- 在文件
/var/lib/kubelet/config.yaml
中添加设置cgroupDriver: systemd
- 启动容器运行时
- 执行命令
systemctl start kubelet
,以启动kubelet
- 执行命令
kubectl uncordon <node-name>
,以 取消节点隔离
「如果这篇文章对你有用,请随意打赏」
FEATURED TAGS
agent
apiserver
application
bandwidth-limit
cgo
cgroupfs
ci/cd
client-go
cloudnative
cncf
cni
community
container
container-network-interface
containerd
controller
coredns
crd
custom-controller
deployment
docker
docker-build
docker-image
drop
ebpf
ecology
egress
etcd
gitee
github
gitlab
golang
governance
hpa
http2
image
ingress
iptables
jobs
kata
kata-runtime
kernel
kind
kubelet
kubenetes
kubernetes
library
linux-os
logging
loki
metrics
monitor
namespace
network
network-troubleshooting
node
nodeport
pingmesh
pod
prestop
prometheus
proxyless
pvc
rollingupdate
schedule
scheduler
serverless
sidecar
sigtrem
systemd
throttling
timeout
tools
traceroute