通过 journalctl -u kubelet | tail -n 300
命令查看日志发现下面3个错误:
错误1
cni.go:237] Unable to update cni config: no networks found in /etc/cni/net.d
错误2
Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
错误3
controller.go:135] failed to ensure node lease exists, will retry in 7s, error: leases.coordination.k8s.io "k8s-master0" is forbidden: User "system:node:blog-swarm-n0" cannot get resource "leases" in API group "coordination.k8s.io" in the namespace "kube-node-lease": can only access node lease with the same name as the requesting node
请问如何解决?
是修改 hostname 引起的,错误1与错误2是由于宿主机的 hostname 与节点名称不一致造成 calico-node 容器部署失败,错误3是由于修改了 /etc/kubernetes/kubelet.conf 中的 user: system:node:
与 name: system:node:
中的主机名,都改为相同的名称就解决了。