k8s的flannel启动报错,查看日志:

kubectl describe pod kube-flannel-ds-v9j5t -n kube-flannel

Normal Pulled 39m (x4 over 40m) kubelet Container image "docker.io/rancher/mirrored-flannelcni-flannel:v0.20.2" already present on machine
Normal Created 39m (x4 over 40m) kubelet Created container kube-flannel
Warning Failed 39m (x4 over 40m) kubelet Error: failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error setting cgroup config for procHooks process: open /sys/fs/cgroup/memory/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podfe68f366_ef34_4535_9366_51041b92f3bf.slice/cri-containerd-kube-flannel.scope/memory.memsw.limit_in_bytes: no such file or directory: unknown
Warning BackOff 40s (x186 over 40m) kubelet Back-off restarting failed container

我们还不知道确切的原因,但它目前发生在 containerd.io 版本:1.6.13 中。

$ containerd --version
containerd containerd.io 1.6.13 78f51771157abb6c9ed224c22013cdf09962315d

解决方法是从版本 1.6.13 重新安装到版本 1.6.12-1。

$ sudo apt remove containerd.io -y
$ sudo apt install containerd.io=1.6.12-1 -y
$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-pzdw6 1/1 Running 0 6s
kube-flannel kube-flannel-ds-s844k 1/1 Running 0 6s
kube-flannel kube-flannel-ds-wqzjq 1/1 Running 0 6s