如果pod出错时会显示如下两种提示
[root@master ~]#kubectl get pods
NAME READY STATUS RESTARTS AGE
net-test1-7c9c4b94d6-5mddl 1/1 Running 0 2m41s
net-test1-7c9c4b94d6-xk8jp 0/1 ImagePullBackOff 0 5s
[root@master ~]#kubectl get pods
NAME READY STATUS RESTARTS AGE
net-test1-7c9c4b94d6-5mddl 1/1 Running 0 2m39s
net-test1-7c9c4b94d6-xk8jp 0/1 ErrImagePull 0 3s
检查pod的日志,发现是无法下载pod的镜像
[root@master ~]#kubectl logs net-test1-7c9c4b94d6-xk8jp
Error from server (BadRequest): container "net-test1" in pod "net-test1-7c9c4b94d6-xk8jp" is waiting to start: trying and failing to pull image
查看出问题的pod处于哪个节点之上,发现在node1节点上
[root@master ~]#kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE R
net-test1-7c9c4b94d6-xk8jp 0/1 ImagePullBackOff 0 13s 10.10.1.7 node1 <none> <
net-test1-7c9c4b94d6-5mddl 1/1 Running 0 14m 10.10.2.2 node2 <none>
在node1节点查看是否可以手动下载镜像,发现已经无法下载
[root@node1 ~]#docker pull alpine
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: server misbehaving
检查node1节点是否能够网络通讯,发现无法进行名称解析
[root@node1 ~]#ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution
修改该节点的DNS,当前主机为ubuntu系统
[root@node1 ~]#vim /etc/systemd/resolved.conf
#取消这一行注释,加入DNS解析地址
[Resolve]
DNS=8.8.8.8
在主节点上查看
[root@master ~]#kubectl get pods
NAME READY STATUS RESTARTS AGE
net-test1-7c9c4b94d6-5mddl 1/1 Running 0 5m44s
net-test1-7c9c4b94d6-xk8jp 1/1 Running 0 3m8s
原文:https://blog.51cto.com/14163901/2418403