k8s:worke节点启动后,node处于NotReady状态

通过kubeadm join 方式,添加一个node到kubernetes集群后,发现节点的状态是NotReady

#kubectl get nodes
NAME                   STATUS     ROLES    AGE    VERSION
bd011088191033.na610   Ready      master   10h    v1.18.0
bd011088191046.na610   NotReady      131m   v1.18.0
bd011088191061.na610   Ready         131m   v1.18.0

查看该节点的pod状态

#kubectl get pods --all-namespaces -o wide | grep bd011088191046.na610
kube-system   kube-proxy-4h4ft                               0/1     ContainerCreating   0          132m   11.88.191.46   bd011088191046.na610              
kube-system   weave-net-4z6ws                                0/2     ContainerCreating   0          132m   11.88.191.46   bd011088191046.na610              

发现kube-proxy的pod没有启动成功,继续查看该pod的状态

#kubectl describe pod kube-proxy-4h4ft  --namespace=kube-system
...
Events:
  Type     Reason                  Age                     From                           Message
  ----     ------                  ----                    ----                           -------
  Warning  FailedCreatePodSandBox  3m14s (x231 over 133m)  kubelet, bd011088191046.na610  Failed to create pod sandbox: rpc error: code = Unknown desc = failed pulling image "k8s.gcr.io/pause:3.2": Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

从报错信息看出,是拉取镜像的时候网络异常:failed pulling image “k8s.gcr.io/pause:3.2”: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

因此通过docker pull先拉取镜像到本地

#!/bin/bash
url=registry.cn-hangzhou.aliyuncs.com/google_containers
version=v1.18.0
images=(`kubeadm config images list --kubernetes-version=$version|awk -F '/' '{print $2}'`)
for imagename in ${images[@]} ; do
  echo $imagename
  docker pull $url/$imagename
  docker tag $url/$imagename k8s.gcr.io/$imagename
  docker rmi -f $url/$imagename
done

拉取成功后,等待几分钟,等Pod重新拉起后,即可看到状态变成Running

你可能感兴趣的:(云原生)