Taints and tolerations
How nodes repel Pods: the three taint effects, matching tolerations, dedicated nodes, and how the node lifecycle controller taints failed nodes.
Taints and tolerations
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A taint on a node repels every Pod that doesn't tolerate it. NoSchedule blocks new Pods, PreferNoSchedule only discourages them, and NoExecute also evicts Pods already running.
- A toleration lets a Pod onto a tainted node but doesn't attract it there. Dedicated nodes need both a taint (keep others off) and node affinity (send these Pods there).
- With NoExecute, tolerationSeconds sets how long a tolerating Pod may stay after the taint appears. Without it, the Pod stays forever.
- The node lifecycle controller taints nodes it can't hear from (node.kubernetes.io/unreachable or not-ready), and every Pod gets a default 300-second toleration for those, so failed nodes are drained after five minutes.
- If every node in a zone or the whole cluster goes unhealthy at once, the controller stops evicting, on the theory that the control plane's view is the problem.
Keeping Pods away
Affinity attracts Pods to nodes. It can’t keep other Pods off. If you buy expensive GPU nodes and give your training jobs node affinity for them, nothing stops every web Pod in the cluster from filling those nodes too. You’d have to add anti-affinity to every other workload, including ones you don’t control.
Kubernetes turns it around. A taint is set on the node and repels every Pod that doesn’t explicitly tolerate it. Think of a “staff only” sign on a door: it doesn’t summon staff, it just keeps everyone else out, and staff carry a badge that lets them through.
Taints
kubectl taint node n3 gpu=true:NoSchedule
kubectl taint node n3 gpu=true:NoSchedule- # remove it
A taint is a key, an optional value and an effect:
NoSchedule: the scheduler won’t place Pods that don’t tolerate it. Running Pods stay.PreferNoSchedule: the scheduler tries to avoid the node (a scoring penalty, through the weight-3TaintTolerationscore plugin).NoExecute: no new Pods, and running Pods that don’t tolerate it are evicted.
kubectl cordon is related but separate. It sets spec.unschedulable, which the scheduler treats much like a node.kubernetes.io/unschedulable:NoSchedule taint.
Tolerations
spec:
tolerations:
- {key: gpu, operator: Equal, value: "true", effect: NoSchedule}
nodeSelector: {gpu: "true"}
operator: Equal matches key and value, Exists matches any value of the key, and a toleration with operator: Exists and no key tolerates everything (DaemonSets for node agents often use that). Leaving out effect matches all effects.
The nodeSelector above is the half people forget. A toleration lets a Pod onto the node. It doesn’t send it there. On our lab cluster, with n3 tainted gpu=true:NoSchedule, three plain Pods went to n1 and n2, and the one Pod with both the toleration and a gpu: "true" selector went to n3. Dedicated nodes always need the pair: the taint keeps others off, and the affinity keeps these Pods on.
Kubernetes 1.35 added Gt and Lt toleration operators as an alpha feature, off by default, for numeric taints like a node’s reliability score.
NoExecute and tolerationSeconds
NoExecute acts on running Pods, and tolerationSeconds sets a grace period. We ran three Pods on n2: plain-2 with no matching toleration, brief-1 tolerating maintenance for 20 seconds, and forever-1 tolerating it with no time limit. Then:
kubectl taint node n2 maintenance=true:NoExecute
The taint eviction controller marked plain-2 for deletion immediately (TaintManagerEviction: Marking for deletion Pod sched/plain-2), brief-1 about 20 seconds later, and left forever-1 alone. With no kubelet in the lab, evicted Pods sat in Terminating instead of disappearing, but the decision is the controller’s.
Nodes that stop talking
The most important taints are the ones nobody sets by hand. The kubelet heartbeats through a Lease in kube-node-lease. When a node goes quiet for the grace period (about 40 seconds), the node lifecycle controller sets its Ready condition to Unknown with Kubelet stopped posting node status. and adds node.kubernetes.io/unreachable taints, first NoSchedule, then NoExecute. (not-ready is used when the kubelet reports NotReady itself.) We saw exactly that on a fake node we stopped heartbeating, while keeping the others alive by renewing their Leases.
So why aren’t all Pods evicted 40 seconds into a hiccup? Because the DefaultTolerationSeconds admission plugin adds two tolerations to every Pod that doesn’t set its own:
[{"key":"node.kubernetes.io/not-ready","operator":"Exists","effect":"NoExecute","tolerationSeconds":300},
{"key":"node.kubernetes.io/unreachable","operator":"Exists","effect":"NoExecute","tolerationSeconds":300}]
That’s what our plain Pods carried. A dead node’s Pods are evicted after five minutes, and their controllers create replacements elsewhere. For a stateless service that should fail over faster, set those tolerations yourself with, say, 30 seconds. For a stateful Pod tied to a local disk, you might set them longer.
There’s one more safety valve, and our lab hit it by accident. When every node stopped heartbeating at once, the controller logged Controller detected that all Nodes are not-Ready. Entering master disruption mode and evicted nothing. It applies the same logic per zone: if a large share of a zone’s nodes are unhealthy, evictions there slow down or stop. A partition between the control plane and the nodes looks like every node dying, and evicting everything would turn a network problem into a full outage.
Taints you’ll meet
node-role.kubernetes.io/control-plane:NoSchedulekeeps workloads off control-plane nodes in kubeadm clusters.node.kubernetes.io/memory-pressure,disk-pressureandpid-pressure(NoSchedule), added from node conditions.node.kubernetes.io/unschedulablefrom a cordon.node.cloudprovider.kubernetes.io/uninitializeduntil the cloud controller has set the node up.- Autoscalers and spot handlers add their own, for example before a spot interruption or a scale-down, which ties into drains and disruptions.
About the video
The embed is a 25-minute clip, 0:34 to 25:49, of Shubham gour’s “Kubernetes Taints and Tolerations Explained: NoSchedule, NoExecute & nodeSelector (Hands-On)”, October 2026. The clip’s chapters cover how taints and tolerations work, taint syntax, the three effects, what a toleration is, then a three-node Minikube demo: tainting a node, deploying without tolerations, and a Pod with a toleration plus a nodeSelector, which is the dedicated-node pattern above. It doesn’t cover the node lifecycle taints, default tolerations or disruption modes, which this lesson adds from the lab. Judged from chapters, since transcripts can’t be fetched here, and from its “English (US) original” audio track. It’s a small channel. KodeKloud’s 10-minute 2018 explainer in deeper is the short classic. The API hasn’t changed since.
What was run: against a local v1.37.3 control plane with four fake Nodes, we tainted a node and placed Pods with and without tolerations, applied a NoExecute taint and watched the taint eviction controller evict at once, after tolerationSeconds, and never; read the default tolerations added by admission; stopped heartbeating one node while renewing the others’ Leases, and saw the unreachable NoSchedule and NoExecute taints appear; and saw “master disruption mode” when all nodes went quiet. No containers ran, checked 2026-11-29.
Where this fits
Taints and affinity choose acceptable nodes. Spreading replicas well, and deciding who wins when nodes are full, is next: topology spread, priority and preemption.
Check yourself
You taint GPU nodes with gpu=true:NoSchedule and give the training Pods a matching toleration. Some training Pods still land on CPU nodes. Why?
A toleration only permits; it doesn't attract. The training Pods are free to schedule anywhere untainted. Add node affinity or a nodeSelector for the GPU label so they are required on GPU nodes.
You add maintenance=true:NoExecute to a node. Pod A has no matching toleration, Pod B tolerates it with tolerationSeconds 20, Pod C tolerates it with no tolerationSeconds. What happens to each?
A is evicted at once, B is evicted about 20 seconds later, and C stays indefinitely.
A node loses power. How long until its Pods are replaced elsewhere, by default?
Roughly 40 seconds for the node lifecycle controller to mark it Unknown and add the unreachable NoExecute taint, then the 300-second default toleration every Pod carries, so about five and a half minutes. Lower tolerationSeconds for node.kubernetes.io/unreachable on Pods that should fail over faster.
During a network partition every node goes NotReady at once, but no Pods are evicted. Is the controller broken?
No. When all nodes (or all nodes in a zone) are unhealthy, it enters a disruption mode and stops or slows evictions, assuming the problem is between the control plane and the nodes. Mass-evicting every Pod would make a partial outage total.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.