Skip to content
Latchkey

kubectl taint: Repel Pods From Nodes

kubectl taint adds a taint to a node so pods without a matching toleration are kept off (or evicted from) it.

Taints reserve nodes for specific workloads or mark them for maintenance. The effect (NoSchedule, PreferNoSchedule, NoExecute) decides how strict it is.

What it does

kubectl taint sets a key=value:effect on a node. NoSchedule blocks new pods lacking a toleration, PreferNoSchedule is a soft preference, and NoExecute also evicts already-running pods that do not tolerate it. Appending - to the taint removes it.

Common usage

Terminal
kubectl taint nodes node-1 dedicated=ci:NoSchedule
# evict non-tolerating pods too
kubectl taint nodes node-1 maintenance=true:NoExecute
# remove a taint (note the trailing -)
kubectl taint nodes node-1 dedicated=ci:NoSchedule-

Options

Syntax / FlagWhat it does
<key>=<value>:NoScheduleBlock scheduling of non-tolerating pods
<key>=<value>:NoExecuteAlso evict running non-tolerating pods
<key>=<value>:PreferNoScheduleSoft preference to avoid the node
<key>:<effect>-Remove the taint with that key and effect
--overwriteReplace an existing taint value for the key
-l, --selectorTaint all nodes matching a label

In CI

Pods need a matching toleration to land on a tainted node, so taint and toleration are edited together; tainting a node without updating the workloads will leave pods Pending. NoExecute is disruptive: it evicts immediately, so combine it with a PodDisruptionBudget-aware drain for graceful maintenance.

Common errors in CI

"error: Node node-1 already has dedicated taint(s) with same key and effect" means the taint exists; add --overwrite to change the value or remove it first. "error: ... not found" for the key on removal means the taint was not present. Pods stuck Pending with "node(s) had untolerated taint" confirm the taint is doing its job but the workload lacks a toleration.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →