Sub topic 13
Debugging Pending pods caused by taints
This chapter assumes you can read pod manifests, use kubectl describe, and already know the three taint effects and how tolerations match them. Here you will use that knowledge to find out why a pod is stuck in Pending and fix it.
Start with the scheduler's message
A pod that no node accepts stays in Pending. The scheduler records its reasoning as an event on the pod. Read it first, before you change anything.
# See why a pod is Pending
kubectl describe pod gpu-job
# Look in Events for a message like:
# 0/3 nodes are available: 3 node(s) had untolerated taint {dedicated: gpu}.
# List nodes with their taints
kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taintsThe message has the form 0/N nodes are available: followed by a count of nodes for each reason. A phrase such as had untolerated taint {dedicated: gpu} names the exact key and value that blocked the pod. The counts add up to N, and each node is listed under the first reason that rejected it.
A debugging workflow
flowchart TD
A[Pod is Pending] --> B[Run kubectl describe pod]
B --> C{Event mentions untolerated taint?}
C -- No --> D[Check resources, affinity, selectors]
C -- Yes --> E[List node taints]
E --> F{Should the pod run on those nodes?}
F -- Yes --> G[Add or fix the toleration]
F -- No --> H[Add nodes without the taint or remove the taint]The chart above is only a plan. Use the real diagram form below when you want to share it.
Common causes
| Symptom in the event | Likely cause | Fix |
|---|---|---|
| `had untolerated taint {dedicated: gpu}` | The pod has no toleration for that taint | Add a toleration with the same key, value, and effect |
| Toleration present, still Pending | Key, value, operator, or effect does not match | Compare each field against the node's taint |
| Pod schedules, but on the wrong nodes | Toleration permits but does not attract | Add node affinity or a node selector |
| `had untolerated taint {node.kubernetes.io/unreachable: }` | The node is unreachable and the pod has no matching toleration | Fix the node, or tolerate the taint on purpose |
| Pod runs, then is evicted | A `NoExecute` taint appeared, or `tolerationSeconds` expired | Check node conditions and the toleration timing |
Check each field of the toleration
A toleration must match the taint on key and effect. With Equal it must also match the value. A single typo is enough to leave the pod unschedulable. Suppose the node was tainted like this:
kubectl taint nodes node1 dedicated=gpu:NoScheduleThis toleration looks right but fails, because the value is GPU instead of gpu:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "GPU"
effect: "NoSchedule"Values are case-sensitive. Correct the value, or use Exists if any value should be accepted:
tolerations:
- key: "dedicated"
operator: "Exists"
effect: "NoSchedule"Remember that several taints are checked together
A node with two taints needs a toleration for each one. The scheduler ignores the taints the pod tolerates. If any untolerated NoSchedule or NoExecute taint remains, the node is rejected. A pod that tolerates dedicated=gpu still stays Pending if the node also carries a taint such as node.kubernetes.io/disk-pressure.
Rule out the other causes
Taints are only one reason for Pending. If the event does not mention a taint, look for other reasons in the same message, such as Insufficient cpu, didn't match Pod's node affinity/selector, or an unbound volume claim. When a pod has a toleration and still lands on the wrong node, the cause is usually missing affinity, not a taint problem.
Confirm the fix
After you edit the manifest or the node, check that the pod moved:
kubectl get pod gpu-job -o wideThe NODE column should show a node you expect. If you removed a taint from a node instead, remember the trailing minus: kubectl taint nodes node1 dedicated=gpu:NoSchedule-.
Exercise
A pod stays Pending. Its event says 0/3 nodes are available: 3 node(s) had untolerated taint {dedicated: gpu}. The pod has a toleration with key dedicated, operator Equal, value gpu, and effect NoExecute. The nodes were tainted with dedicated=gpu:NoSchedule. What is wrong, and how do you fix it?
Show answer
The toleration's effect (NoExecute) does not match the taint's effect (NoSchedule), so the toleration does not apply. Change the toleration's effect to NoSchedule, or remove the effect field so the toleration matches any effect for that key. Then confirm with kubectl get pod -o wide that the pod is scheduled.