Taint
A taint is a key-value property on a Kubernetes node that repels pods unless they have a matching toleration. Taints let you reserve nodes for specific workloads, such as GPU or compliance-scoped nodes, and keep everything else off them.
How taints work
A taint has a key, an optional value, and an effect. By default every pod without a matching toleration is kept away. Taints push pods away, which is the opposite of affinity.
taint workload=gpu"] --> X["Regular pod
no toleration"] N --> G["GPU pod
tolerates taint"] X -->|"repelled"| R["Scheduled elsewhere"] G -->|"allowed"| S["Can schedule here"] classDef node fill:#FFEDD5,color:#1E293B classDef pod fill:#DBEAFE,color:#1E293B classDef bad fill:#FEE2E2,color:#1E293B classDef ok fill:#D1FAE5,color:#1E293B class N node class X,G pod class R bad class S ok
Effects
| Effect | Behaviour |
|---|---|
| NoSchedule | New pods without a toleration are not scheduled |
| PreferNoSchedule | Scheduler tries to avoid the node |
| NoExecute | Blocks new pods and evicts running pods without a toleration |
Add and remove taints
kubectl taint nodes gpu-node-1 workload=gpu:NoSchedulekubectl taint nodes mumbai-worker-3 maintenance=patching:NoExecutekubectl describe node gpu-node-1 | grep -A 3 Taints # Remove with a trailing minuskubectl taint nodes gpu-node-1 workload=gpu:NoSchedule-Dedicate nodes properly
A taint alone only repels others. To dedicate nodes, combine all three pieces.
spec: tolerations: - key: "workload" operator: "Equal" value: "gpu" effect: "NoSchedule" nodeSelector: workload: gpuThe taint keeps others off, the toleration lets the pod on, and the nodeSelector (or affinity) makes the pod go only there.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Pending with taint message | No matching toleration | Add a toleration |
| Toleration present but Pending | Effect or value mismatch | Match the taint exactly |
| Wrong pods on tainted nodes | Wildcard toleration | Scope tolerations to a key |
| Taint stuck after maintenance | Missed trailing minus | Re-run removal with - |
RememberKubernetes also adds taints automatically, such as
node.kubernetes.io/not-readyandnode.kubernetes.io/unreachable, which drive failover.
SecurityTainted, dedicated nodes are a useful isolation control for regulated workloads like card processing, because other tenants cannot co-locate on them.
Common MistakeUsing
NoExecuteon the wrong node. Running pods without a toleration are evicted immediately.
Frequently Asked Questions
How is a taint different from node affinity?
Affinity is declared by pods that want to be somewhere. A taint is set on the node and repels all pods by default unless they tolerate it, which is what guarantees general workloads stay off dedicated nodes.
Does a toleration make a pod go to the tainted node?
No. It only permits it. Add node affinity or a nodeSelector so the pod is actually attracted to those nodes.
What is the difference between NoSchedule and NoExecute?
NoSchedule only blocks new scheduling. NoExecute also evicts running pods that lack a matching toleration.