kubectl-taint
Mark nodes to prevent pod scheduling
TLDR
Apply taint to a node
Remove taint from a node
Remove all taints from a node
SYNOPSIS
kubectl taint NODE KEY_1[=value_1]:effect_1 [KEY_2[=value_2]:effect_2 ...] [--all] [--selector selector] [--overwrite] [--dry-run=server]
PARAMETERS
NODE
Name of the node to taint (or selector).
KEY[=VALUE]:EFFECT
Taint spec; use EFFECT- to remove. Effects: NoSchedule, PreferNoSchedule, NoExecute.
--all
Select all nodes in the cluster.
--selector string
Label selector to filter nodes.
--overwrite
Replace existing taints with same key.
--dry-run string[=none]
Dry run: none, server, client (default none).
--field-selector string
Field selector for nodes.
--timeout duration[=0]
Timeout for request.
DESCRIPTION
The kubectl taint command manages taints on Kubernetes nodes, marking them with key-value pairs and effects to control pod scheduling. Taints repel pods unless they have matching tolerations in their spec.
Taints consist of a key, optional value, and effect: NoSchedule (prevents new pods), PreferNoSchedule (soft avoidance), or NoExecute (evicts running pods without toleration and blocks new ones).
To add a taint: kubectl taint nodes node1 key1=value1:NoSchedule. Remove with '-': kubectl taint nodes node1 key1:NoSchedule-. Use --all or --selector for multiple nodes.
This enables node maintenance, dedicating nodes to specific workloads, or handling faulty hardware by isolating nodes. Effects propagate via scheduler decisions, ensuring high availability. Requires cluster-admin privileges. Changes are immediate for scheduling; NoExecute triggers pod eviction with grace periods.
CAVEATS
NoExecute evicts pods—use tolerations first. Requires admin access. Test in dry-run to avoid outages.
EXAMPLES
# Add taint
kubectl taint nodes node1 disktype=ssd:NoSchedule
# Remove
kubectl taint nodes node1 disktype:NoSchedule-
# All nodes
kubectl taint nodes --all key1=value1:NoExecute --overwrite
EFFECTS DETAILS
NoSchedule: Scheduler skips tainted nodes.
PreferNoSchedule: Avoids but allows if needed.
NoExecute: Evicts + no new pods (v1.6+).
HISTORY
Introduced in Kubernetes v1.1 (alpha), beta in v1.6 with NoExecute, stable by v1.13. Evolved for node isolation in cloud-native orchestration.
SEE ALSO
kubectl(1), kubectl-label(1), kubectl-get(1), kubectl-describe(1)


