Kubernetes: Fix ImagePullBackOff and Pending
ImagePullBackOff means Kubernetes cannot fetch the container image. Pending means the scheduler cannot place the pod anywhere.
See the pull failure
The pod list shows the pull status. The pod never reaches Running.
kubectl get pods -l app=webRead the pull error
Describe names the image it tried to fetch. A wrong tag shows up here in plain words.
kubectl describe pod web-7d9f4b6c8-x2k9m | grep -A 2 FailedSee a Pending pod
A Pending pod has no node yet. The scheduler event says why no node fits.
kubectl describe pod web-7d9f4b6c8-x2k9m | grep -A 2 'FailedScheduling'Load a local image first
Minikube runs its own image store. Load the image into it before you apply the pod.
minikube image load web:v2Example
kubectl get pods -l app=web
kubectl describe pod web-7d9f4b6c8-x2k9m | grep -A 2 Failed
kubectl set image deployment/web api=web:v2
kubectl get pods -l app=webKey points
- ImagePullBackOff: Kubernetes tried to pull the image and failed, then waits before it tries again
- Pending: the pod is waiting for a node, because the scheduler could not place it
- Use kubectl describe pod to read the pull error or the scheduling event
- A wrong image name or tag is the most common pull failure
- A local image needs minikube image load, because minikube cannot see images on your laptop
- Pending is not a cluster bug, because the scheduling event names the cause
In this example, the first command shows the pod in ImagePullBackOff. The second command reads the pull error. The output shows tag v99 does not exist. The third command points the Deployment at the real tag v2. The fourth command shows the pod running.
Note
LoadBalancer stays pending on a local cluster unless you run minikube tunnel or minikube service.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
A pod stays Pending and its event says 0/1 nodes are available with insufficient CPU. What is the cause?