LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kubectl-taint

adds or removes node taints

TLDR

Add taint to node
$ kubectl taint nodes [node-name] [key=value:NoSchedule]
copy
Remove taint
$ kubectl taint nodes [node-name] [key:NoSchedule-]
copy
Add NoExecute taint
$ kubectl taint nodes [node-name] [key=value:NoExecute]
copy
Add PreferNoSchedule
$ kubectl taint nodes [node-name] [key=value:PreferNoSchedule]
copy
Taint multiple nodes
$ kubectl taint nodes [node1] [node2] [key=value:NoSchedule]
copy

SYNOPSIS

kubectl taint [options] node key=value:effect

DESCRIPTION

kubectl taint adds, updates, or removes node taints. A taint is a key=value:effect tuple attached to a node; pods are scheduled or kept on the node only if they carry a matching toleration in their pod spec. The supported effects are NoSchedule (block new pods that don't tolerate it), PreferNoSchedule (best-effort avoid), and NoExecute (evict running pods that don't tolerate it).Taints are the standard mechanism for dedicating nodes to a workload class (e.g., GPU nodes), keeping pods off control-plane nodes, and gracefully draining nodes for maintenance in conjunction with kubectl drain.

PARAMETERS

NODE

Node name.
KEY=VALUE:EFFECT
Taint specification.
NoSchedule
Prevent scheduling.
NoExecute
Evict existing pods.
PreferNoSchedule
Soft no-schedule.
- (suffix on the taint key)
Remove a taint matching the given key:effect pair (e.g. node1 dedicated:NoSchedule-).
--all
Apply the taint operation to every node in the cluster.
-l, --selector SELECTOR
Apply only to nodes matching the label selector (e.g. `--selector=role=worker`).
--overwrite
Allow updating the value of an existing taint (without it, attempting to add a taint with the same key produces an error).
--dry-run client|server|none
Print what would change without modifying the cluster.
--help
Display help information.

CAVEATS

NoExecute evicts already-scheduled pods that lack a matching toleration; ensure tolerations are in place before tainting a populated node. Overwriting an existing taint requires --overwrite. Removing a taint uses a trailing - on the taint key (no value needed).

HISTORY

kubectl taint provides taint management for Kubernetes advanced scheduling control.

SEE ALSO

Copied to clipboard
Kai