Difficulty: Advanced
What are the three taint effects in Kubernetes, and how does NoExecute behave differently from the other two?
The three taint effects are NoSchedule, PreferNoSchedule and NoExecute. NoSchedule blocks new Pods that do not tolerate the taint, PreferNoSchedule is a soft version that the scheduler tries to honour but may ignore, and NoExecute both blocks new Pods and evicts Pods already running on the node unless they tolerate it. Only NoExecute affects running Pods.
| Effect | New Pods without toleration | Running Pods without toleration | Typical use |
|---|---|---|---|
NoSchedule | Not scheduled | Left alone | Dedicated nodes, control plane nodes, cordoned nodes |
PreferNoSchedule | Avoided if other nodes fit | Left alone | Soft steering, e.g. keep batch work off a node pool when possible |
NoExecute | Not scheduled | Evicted | Node failures, urgent node draining by automation |
Taints and effects are enforced by different components. The scheduler handles NoSchedule and PreferNoSchedule at placement time. NoExecute is enforced continuously by the taint eviction logic in the controller manager.
A toleration for a NoExecute taint can include tolerationSeconds. The Pod is allowed to stay bound for that long after the taint appears, then it is evicted. Without tolerationSeconds, a matching toleration means it stays forever; with no toleration, it is evicted immediately.
This is how Kubernetes handles node failures:
node.kubernetes.io/unreachable:NoExecute (or not-ready).tolerationSeconds: 300 for these two taints, added by the DefaultTolerationSeconds admission plugin.For a latency-sensitive service like a payment gateway, five minutes is long. You can set your own toleration with tolerationSeconds: 30 so replacements start sooner. For a stateful Pod that is expensive to move, you might increase it instead.
node-role.kubernetes.io/control-plane:NoSchedule on control plane nodes.node.kubernetes.io/unschedulable:NoSchedule, added when you kubectl cordon a node.node.kubernetes.io/memory-pressure, disk-pressure and pid-pressure with NoSchedule, added when the kubelet reports resource pressure.node.kubernetes.io/not-ready and unreachable with NoExecute, as above.DaemonSet Pods automatically tolerate most of these, which is why log agents keep running on cordoned or pressured nodes.
NoExecute taint to a busy node is effectively an instant drain that ignores PodDisruptionBudgets. Prefer kubectl drain for planned maintenance.operator: Exists and no key tolerates every taint. Use it only for system agents.gpu=true:NoSchedule and gpu=true:NoExecute are two separate taints on the same node.# Hard block for new Pods
kubectl taint nodes node-a dedicated=search:NoSchedule
# Soft preference
kubectl taint nodes node-b batch=avoid:PreferNoSchedule
# Block new Pods AND evict running ones without a toleration
kubectl taint nodes node-c maintenance=true:NoExecute
# See taints on all nodes
kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
The effect after the colon decides whether the taint only affects scheduling or also evicts running Pods.
spec:
tolerations:
- key: node.kubernetes.io/unreachable
operator: Exists
effect: NoExecute
tolerationSeconds: 30 # default would be 300
- key: node.kubernetes.io/not-ready
operator: Exists
effect: NoExecute
tolerationSeconds: 30
Overriding the default tolerations lets a critical service be rescheduled about 30 seconds after its node fails instead of five minutes.
NoSchedule, PreferNoSchedule, NoExecute, tolerationSeconds, Taint-based Eviction