Bootstrap

Kubernetes Pod 提示 : Init:ImagePullBackOff

如果有pod提示Init:ImagePullBackOff,说明这个pod的镜像在对应节点上拉取失败,我们可以通过 kubectl describe pod 查看 Pod 具体情况,以确认拉取失败的镜像:

[root@master ~]# kubectl get pods -n kube-system
NAME                             READY   STATUS                  RESTARTS   AGE
coredns-7ff77c879f-lssvc         1/1     Running                 0          27m
coredns-7ff77c879f-vt5tm         1/1     Running                 0          27m
etcd-master                      1/1     Running                 0          28m
kube-apiserver-master            1/1     Running                 0          28m
kube-controller-manager-master   1/1     Running                 0          28m
kube-flannel-ds-hwz4l            1/1     Running                 0          4m
kube-flannel-ds-m47tz            0/1     Init:ImagePullBackOff   0          4m
kube-flannel-ds-nwtkx            0/1     Init:ImagePullBackOff   0          4m
kube-proxy-6hxbp                 1/1     Running                 0          27m
kube-proxy-d5x2c                 1/1     Running                 0          19m
kube-proxy-s9gr9                 1/1     Running                 0          19m
kube-scheduler-master            1/1     Running                 0          28m

[root@master ~]# kubectl describe pod kube-flannel-ds-m47tz --namespace=kube-system
## 这里看最后events输出内容,可以看到在下载 image 时失败,
## 如果网络质量不好,这种情况是很常见的。我们可以耐心等待,
## 因为 Kubernetes 会重试,我们也可以自己手工执行 docker pull 去下载这个镜像。
Events:
  Type     Reason     Age                   From               Message
  ----     ------     ----                  ----               -------
  Normal   Scheduled  6m53s                 default-scheduler  Successfully assigned kube-system/kube-flannel-ds-m47tz to node1
  Warning  Failed     6m32s                 kubelet, node1     Failed to pull image "quay.io/coreos/flannel:v0.13.0-rc2": rpc error: code = Unknown desc = Error response from daemon: Get https://quay.io/v2/coreos/flannel/manifests/v0.13.0-rc2: dial tcp: lookup quay.io on 8.8.8.8:53: read udp 192.168.136.202:34456->8.8.8.8:53: i/o timeout
  Warning  Failed     2m8s (x2 over 6m32s)  kubelet, node1     Error: ErrImagePull
  Warning  Failed     2m8s                  kubelet, node1     Failed to pull image "quay.io/coreos/flannel:v0.13.0-rc2": rpc error: code = Unknown desc = context canceled
  Normal   BackOff    116s (x2 over 6m32s)  kubelet, node1     Back-off pulling image "quay.io/coreos/flannel:v0.13.0-rc2"
  Warning  Failed     116s (x2 over 6m32s)  kubelet, node1     Error: ImagePullBackOff
  Normal   Pulling    102s (x3 over 6m51s)  kubelet, node1     Pulling image "quay.io/coreos/flannel:v0.13.0-rc2"
  Normal   Pulled     57s                   kubelet, node1     Successfully pulled image "quay.io/coreos/flannel:v0.13.0-rc2"
  Normal   Created    57s                   kubelet, node1     Created container install-cni
  Normal   Started    57s                   kubelet, node1     Started container install-cni
  Normal   Pulled     56s                   kubelet, node1     Container image "quay.io/coreos/flannel:v0.13.0-rc2" already present on machine
  Normal   Created    56s                   kubelet, node1     Created container kube-flannel
  Normal   Started    56s                   kubelet, node1     Started container kube-flannel

因此手动拉取下载失败的image

[root@master ~]# docker pull quay.io/coreos/flannel:v0.13.0-rc2
v0.13.0-rc2: Pulling from coreos/flannel
df20fa9351a1: Already exists 
0fbfec51320e: Already exists 
734a6c0a0c59: Already exists 
83826c3eac62: Pull complete 
c45d7b8ac5ad: Pull complete 
071b96dd834b: Pull complete 
5c3f16974444: Pull complete 
Digest: sha256:5391451071695141d8d40604c88b76017fa72d5ea7d80f2e87cfe0aaec71dfcb
Status: Image is up to date for quay.io/coreos/flannel:v0.13.0-rc2

;