Error when creating pod
If the pod fails, the following two prompts will be displayed
[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
Troubleshoot the cause of the problem
Check the log of pod and find that it is unable to download the image of 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
Check which node the pod in question is on, and find that it is on node1 node.
[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>
Check whether the image can be downloaded manually in node1 node. It is found that the image cannot be downloaded.
[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
Check whether node1 node can communicate with the network, and find that name resolution cannot be performed.
[root@node1 ~]#ping www.baidu.com ping: www.baidu.com: Temporary failure in name resolution
Solve the problem
Modify the DNS of this node. The current host is ubuntu system.
[root@node1 ~]#vim /etc/systemd/resolved.conf #Uncomment this line and add DNS resolution address [Resolve] DNS=8.8.8.8
View on primary node
[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