Video in progress
A new pod has been in Pending for a long time. How do you find the cause and fix it?
Pending means the pod has not been placed on a node yet, or its containers have not started. In the Events section of kubectl describe pod, the scheduler states the reason plainly: not enough resources, a taint, affinity, or an unbound PVC.
📖 Answer
The first step is always the same:
kubectl describe pod orders-6c9f-xk2lp | sed -n '/Events/,$p'
# Warning FailedScheduling 0/6 nodes are available:
# 3 Insufficient memory, 2 node(s) had untolerated taint {dedicated: kafka},
# 1 node(s) didn't match pod topology spread constraints.
The scheduler counts why each node did not fit. Common causes:
- Insufficient cpu/memory: the scheduler looks at the sum of
requests, not at real usage. If a Java service asked for 4Gi "just in case", the pod will not fit even if the nodes look empty on the graph. Look at theAllocated resourcessection inkubectl describe node. If there is a cluster autoscaler, it should have added a node, and why it did not is in its log (for example, the node pool has reached its maximum). - Taints and tolerations: the nodes are reserved for special workloads, and the pod has no matching
tolerations. - nodeSelector / affinity: a mistake in a label (
disk: ssdinstead ofdisktype: ssd), so no node matches. - Unbound PVC:
pod has unbound immediate PersistentVolumeClaims. There is no StorageClass, or the volume is in one zone and the pod wants to land in another.
If a ResourceQuota is exceeded, it is different: the pod is not created at all, and the error is in the ReplicaSet events (exceeded quota). It is easy to lose time looking for a pod that does not exist.
If the pod has been placed on a node but its container has not started, the status shows ContainerCreating or Init:0/1. That is a different direction: image pull, volume mount, init container.
One more subtle point is priorityClass. A high-priority pod that cannot find room pushes out low-priority pods (preemption). Sometimes a "Pending" problem "solves itself" because another team's pods got evicted, and they will come to you about it.
Sign up to mark studied questions and save your progress.