问题:在master上查看刚加入的node节点状态发现STATUS:NotReady

[root@k8s-master jenkins-yaml]# kubectl get nodes
NAME         STATUS     ROLES    AGE    VERSION
k8s-master   Ready      master   2d1h   v1.15.2
k8s-node1    Ready      <none>   2d1h   v1.15.2
k8s-node2    NotReady   <none>   11m    v1.15.2

问题排查:从 No networks found in /etc/cni/net.d 这行错误信息来看,猜想大概是网络配置问题,有可能是安装Flannel的过程有问题。

在node节点上查看日志

root@k8s-node2 ~]# journalctl -f -u kubelet
-- Logs begin at 一 2019-10-28 16:09:21 CST. --
10月 28 16:50:48 k8s-node2 kubelet[14216]: W1028 16:50:48.984435   14216 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
10月 28 16:50:49 k8s-node2 kubelet[14216]: E1028 16:50:49.506102   14216 kubelet.go:2169] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
10月 28 16:50:53 k8s-node2 kubelet[14216]: W1028 16:50:53.984746   14216 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
10月 28 16:50:54 k8s-node2 kubelet[14216]: E1028 16:50:54.507916   14216 kubelet.go:2169] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
10月 28 16:50:58 k8s-node2 kubelet[14216]: W1028 16:50:58.985254   14216 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
10月 28 16:50:59 k8s-node2 kubelet[14216]: E1028 16:50:59.509542   14216 kubelet.go:2169] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
10月 28 16:51:03 k8s-node2 kubelet[14216]: W1028 16:51:03.985612   14216 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
10月 28 16:51:04 k8s-node2 kubelet[14216]: E1028 16:51:04.518004   14216 kubelet.go:2169] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
10月 28 16:51:08 k8s-node2 kubelet[14216]: W1028 16:51:08.985934   14216 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
10月 28 16:51:09 k8s-node2 kubelet[14216]: E1028 16:51:09.520076   14216 kubelet.go:2169] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

 在master上查看pods发现flannel镜像下载失败

[root@k8s-master jenkins-yaml]# kubectl get pods -n kube-system
NAME                                 READY   STATUS              RESTARTS   AGE
coredns-bccdc95cf-dzgz8              1/1     Running             0          2d1h
coredns-bccdc95cf-xfp4s              1/1     Running             0          2d1h
etcd-k8s-master                      1/1     Running             0          2d1h
kube-apiserver-k8s-master            1/1     Running             0          2d1h
kube-controller-manager-k8s-master   1/1     Running             0          2d1h
kube-flannel-ds-amd64-c769s          1/1     Running             0          2d1h
kube-flannel-ds-amd64-lphkb          1/1     Running             0          2d1h
kube-flannel-ds-amd64-vv9m5          0/1     Init:ErrImagePull   0          10m
kube-proxy-8bw84                     1/1     Running             0          2d1h
kube-proxy-s9v8g                     1/1     Running             0          10m
kube-proxy-ttwcg                     1/1     Running             0          2d1h
kube-scheduler-k8s-master            1/1     Running             0          2d1h
kuboard-7bb8d57995-5qth2             1/1     Running             0          2d1h

解决方案:

很明显是因为node节点下载网络镜像的时候失败了,那么是不是可以手动在node节点上去pull一个flannel镜像呢

[root@k8s-node2 ~]# docker images
REPOSITORY                                           TAG                 IMAGE ID            CREATED             SIZE
registry.aliyuncs.com/google_containers/kube-proxy   v1.15.2             167bbf6c9338        2 months ago        82.4MB
registry.aliyuncs.com/google_containers/pause        3.1                 da86e6ba6ca1        22 months ago       742kB
[root@k8s-node2 ~]# 
[root@k8s-node2 ~]# 
[root@k8s-node2 ~]# docker pull quay.io/coreos/flannel:v0.11.0-amd64
v0.11.0-amd64: Pulling from coreos/flannel
cd784148e348: Already exists 
04ac94e9255c: Pull complete 
e10b013543eb: Pull complete 
005e31e443b1: Pull complete 
74f794f05817: Pull complete 
Digest: sha256:7806805c93b20a168d0bbbd25c6a213f00ac58a511c47e8fa6409543528a204e
Status: Image is up to date for quay.io/coreos/flannel:v0.11.0-amd64

下载完成镜像后再次到master上查看pods状态

[root@k8s-master jenkins-yaml]# kubectl get pods -n kube-system
NAME                                 READY   STATUS    RESTARTS   AGE
coredns-bccdc95cf-dzgz8              1/1     Running   0          2d1h
coredns-bccdc95cf-xfp4s              1/1     Running   0          2d1h
etcd-k8s-master                      1/1     Running   0          2d1h
kube-apiserver-k8s-master            1/1     Running   0          2d1h
kube-controller-manager-k8s-master   1/1     Running   0          2d1h
kube-flannel-ds-amd64-c769s          1/1     Running   0          2d1h
kube-flannel-ds-amd64-lphkb          1/1     Running   0          2d1h
kube-flannel-ds-amd64-vv9m5          1/1     Running   0          11m
kube-proxy-8bw84                     1/1     Running   0          2d1h
kube-proxy-s9v8g                     1/1     Running   0          11m
kube-proxy-ttwcg                     1/1     Running   0          2d1h
kube-scheduler-k8s-master            1/1     Running   0          2d1h
kuboard-7bb8d57995-5qth2             1/1     Running   0          2d1h

ok  现在网络已经启动,那么再次查看node状态

[root@k8s-master jenkins-yaml]# kubectl get nodes
NAME         STATUS   ROLES    AGE    VERSION
k8s-master   Ready    master   2d1h   v1.15.2
k8s-node1    Ready    <none>   2d1h   v1.15.2
k8s-node2    Ready    <none>   11m    v1.15.2

问题解决

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐