执行 kubectl get nodes
,看到如下信息,显示节点未就绪
[root@xxxx cni]# kubectl get nodes NAME STATUS ROLES AGE VERSION 10.0.1.173 NotReady <none> 11h v1.28.4
执行kubectl describe node <node_name>
看到报错如下:
NotReady message:Network plugin returns error: cni plugin not initialized
执行journalctl -u kubelet | tee tmp.log
,检查kubelet的日志,看到如下报错:
12月 02 10:16:35 xxxxx kubelet[10037]: E1202 10:16:35.132701 10037 remote_runtime.go:193] "RunPodSandbox from runtime service failed" err="rpc error: code = Unknown desc = failed to get sandbox image \"registry.k8s.io/pause:3.8\": failed to pull image \"registry.k8s.io/pause:3.8\": failed to pull and unpack image \"registry.k8s.io/pause:3.8\": failed to resolve reference \"registry.k8s.io/pause:3.8\": failed to do request: Head \"https://us-west2-docker.pkg.dev/v2/k8s-artifacts-prod/images/pause/manifests/3.8\": dial tcp 64.233.189.82:443: i/o timeout"
解决办法:
从阿里云下载对应的镜像,并且将改一下新镜像的tag。
[root@xxxxx cni]# nerdctl pull registry.aliyuncs.com/google_containers/pause:3.8 registry.aliyuncs.com/google_containers/pause:3.8: resolved |++++++++++++++++++++++++++++++++++++++| index-sha256:9001185023633d17a2f98ff69b6ff2615b8ea02a825adffa40422f51dfdcde9d: done |++++++++++++++++++++++++++++++++++++++| manifest-sha256:f5944f2d1daf66463768a1503d0c8c5e8dde7c1674d3f85abc70cef9c7e32e95: done |++++++++++++++++++++++++++++++++++++++| config-sha256:4873874c08efc72e9729683a83ffbb7502ee729e9a5ac097723806ea7fa13517: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:9457426d68990df190301d2e20b8450c4f67d7559bdb7ded6c40d41ced6731f7: done |++++++++++++++++++++++++++++++++++++++| elapsed: 2.2 s total: 4.2 Ki (1.9 KiB/s) [root@xxxxx cni]# nerdctl tag registry.aliyuncs.com/google_containers/pause:3.8 registry.k8s.io/pause:3.8 [root@xxxxx cni]# date 2023年 12月 02日 星期六 10:23:12 CST
解决方案二:
执行 vim /etc/containerd/config.toml
,修改sandbox_iamge的行如下所示:
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.8"
改完之后,执行:systemctl restart containerd
重启containerd
查看效果
[root@xxxxcni]# kubectl get po -n kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-7ddc4f45bc-56wtb 0/1 ContainerCreating 0 65m calico-node-hn9dj 0/1 Init:2/3 0 65m
可以看到已经就绪2个了。
查看日志也能看到成功的消息:
几分钟之后,再次执行kubectl get all -n kube-system
可以看到服务杜娜都是READY的状态了
[root@xxxxx cni]# kubectl get all -n kube-system NAME READY STATUS RESTARTS AGE pod/calico-kube-controllers-7ddc4f45bc-56wtb 1/1 Running 0 96m pod/calico-node-hn9dj 1/1 Running 0 96m NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 96m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/calico-kube-controllers 1/1 1 1 96m NAME DESIRED CURRENT READY AGE replicaset.apps/calico-kube-controllers-7ddc4f45bc 1 1 1 96m