Sub topic 7
Insufficient resources, taints, and node selectors
This chapter assumes you can read kubectl describe output and know what a pod's Pending phase means. A pod that stays Pending because of scheduling gets a FailedScheduling event. The event message lists, for each reason, how many nodes were rejected for it.
Reading the FailedScheduling message
kubectl describe pod web | grep -A 10 'Events:'A typical message looks like this:
Warning FailedScheduling default-scheduler 0/3 nodes are available: 1 Insufficient cpu, 1 node(s) had untolerated taint {dedicated: gpu}, 1 node(s) didn't match Pod's node affinity/selector.The counts add up to the total number of nodes. Every node was rejected, and each rejection has one stated cause. Fix the cause that applies to the nodes you actually want to use.
| Message fragment | Cause | Typical fix |
|---|---|---|
| `Insufficient cpu` or `Insufficient memory` | Requests exceed free allocatable capacity | Lower requests, add nodes, or free capacity |
| `untolerated taint` | Node repels pods without a matching toleration | Add a toleration, or schedule elsewhere |
| `didn't match Pod's node affinity/selector` | No node carries the required label | Fix the label or the selector |
Insufficient resources
The scheduler compares a pod's requests with what is left of each node's allocatable capacity. It ignores actual usage and limits. A node can look idle in kubectl top and still be full because other pods have reserved its capacity.
kubectl describe node <node-name>In the output, compare the Allocatable section with Allocated resources. If requested CPU is near 100%, no new pod with a CPU request will fit. Also check that a single pod's request is not larger than any one node. Such a pod will never schedule, however many nodes you add.
Taints and tolerations
A taint marks a node so that pods avoid it. A pod must carry a matching toleration to land there. To see the taints on a node:
kubectl describe node <node-name> | grep TaintsFor the taint dedicated=gpu:NoSchedule, the pod needs this under spec:
tolerations:
- key: dedicated
operator: Equal
value: gpu
effect: NoScheduleA toleration only permits scheduling on the tainted node. It does not require it.
Node selectors
A nodeSelector requires every listed label to exist on the node. A typo in the key or value rejects every node.
kubectl get nodes --show-labelsnodeSelector:
disktype: ssdExercise
A pod is Pending with the event "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 be unschedulable, and what do you check next?
Show answer
The scheduler uses requested memory, not live usage. Other pods' requests have likely reserved most of each node's allocatable memory. Run kubectl describe node <node-name> and compare "Allocated resources" with "Allocatable". Then lower the pod's memory request, free up requests from other pods, or add nodes.