Sub topic 6
Why a pod stays Pending
This chapter assumes you can run kubectl get and kubectl describe, read a pod manifest, and know that the scheduler assigns pods to nodes. Here you will learn what Pending means and how to find the cause.
What Pending means
A pod's phase is Pending when the API server has accepted it but one or more containers are not yet running. Two situations produce this phase:
- The scheduler has not yet assigned the pod to a node.
- The pod is assigned, but the node is still pulling images or setting up volumes.
The first case is the most common. A pod that has no node assigned shows <none> in the NODE column of kubectl get pod -o wide. That tells you the scheduler is the place to look.
Find the reason in the events
The scheduler records why it could not place a pod. Read the Events section of describe, then check the node and the claims.
kubectl describe pod web | grep -A 10 'Events:'
kubectl describe node <node-name>
kubectl get pvcA typical event looks like this:
Warning FailedScheduling default-scheduler 0/3 nodes are available: 3 Insufficient cpu.The message counts the nodes and gives the reason each one was rejected. Read it as a list of filters that every node failed.
Common causes
| Event text | Cause | Usual fix |
|---|---|---|
| `Insufficient cpu` or `Insufficient memory` | Requests exceed free allocatable capacity | Lower requests, add nodes, or free capacity |
| `node(s) had untolerated taint` | Nodes are tainted and the pod has no matching toleration | Add a toleration or use other nodes |
| `didn't match Pod's node affinity/selector` | `nodeSelector` or affinity matches no node | Fix the labels or the selector |
| `unbound immediate PersistentVolumeClaims` | A claim is not bound to a volume | Fix the claim, as described below |
For resource shortages, compare the "Allocatable" and "Allocated resources" sections in describe node. The scheduler uses requests, not actual usage. A node can look idle in kubectl top and still be full, because other pods have reserved its capacity.
Pending because of a volume
If the pod mounts a PersistentVolumeClaim (PVC) that is itself Pending, the pod cannot be scheduled. Run kubectl get pvc and look at the STATUS column. Then run kubectl describe pvc <name>. Common reasons are a missing or misspelled StorageClass, no PersistentVolume large enough, or a provisioner that is failing.
Putting it together
- Run
kubectl get pod web -o wideand check whetherNODEis set. - If it is
<none>, read theFailedSchedulingevent. - Match the message to a cause in the table above.
- If the message mentions a claim, inspect the PVC.
Exercise
A pod is Pending and its event says "0/4 nodes are available: 4 Insufficient memory." kubectl top nodes shows each node using under 40% of its memory. Why can the pod still not be scheduled, and what do you check?
Show answer
The scheduler compares the pod's memory request with each node's allocatable memory minus the requests of pods already placed there, not with live usage. The nodes are fully reserved even though they are lightly used. Check "Allocated resources" in kubectl describe node, then lower the pod's request, reduce other pods' requests, or add capacity.