calico-kube-controllers pod容器未就绪
####### 在一台机器上装k8s单节点集群,因/目录空间较小,便将docker和kubelet的存储目录迁移至新盘挂载目录。将数据拷贝时没注意目录权限问题,导致重启docker和kubelet后 ,calico容器未就绪,查看日志提示没有权限写入就绪状态到/sttaus/status.json文件。 因为进入pod命令行提示无bash ,sh,故通过修改calico-kube-controllers deployments,增加volume挂载到本地,赋权修改属组后容器就绪正常
报错日志
Warning FailedCreatePodSandBox 82s kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "8e4802781f47bdb99ddef852e0220d830d429d0277f1d17f8b569621743a5aaa" network for pod "calico-kube-controllers-56c7cdffc6-mqcjr": networkPlugin cni failed to set up pod "calico-kube-controllers-56c7cdffc6-mqcjr_kube-system" network: stat /var/lib/calico/nodename: no such file or directory: check that the calico/node container is running and has mounted /var/lib/calico/
Normal Pulled 81s kubelet Container image "docker.io/calico/kube-controllers:v3.18.6" already present on machine
Normal Created 81s kubelet Created container calico-kube-controllers
Normal Started 81s kubelet Started container calico-kube-controllers
Warning Unhealthy 2s (x8 over 72s) kubelet Readiness probe failed: Failed to read status file /status/status.json: unexpected end of JSON
编辑deployments/calico-kube-controllers
kubectl edit deployments/calico-kube-controllers -n kube-system
添加如下
volumeMounts:
- mountPath: /status
name: status
volumes:
- hostPath:
path: /var/run/calico/status
type: ""
name: status
到宿主机目录查看/var/run/calico/status
发现status.json文件是polkitd:root 用户属组,修改/var/run/calico/status目录属组用户为polkitd:root后,容器正常