Linux command
kubectl-taint 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Add taint to node
kubectl taint nodes [node-name] [key=value:NoSchedule]
Remove taint
kubectl taint nodes [node-name] [key:NoSchedule-]
Add NoExecute taint
kubectl taint nodes [node-name] [key=value:NoExecute]
Add PreferNoSchedule
kubectl taint nodes [node-name] [key=value:PreferNoSchedule]
Taint multiple nodes
kubectl taint nodes [node1] [node2] [key=value:NoSchedule]
说明
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.
参数
- 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.
FAQ
What is the kubectl-taint command used for?
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.
How do I run a basic kubectl-taint example?
Run `kubectl taint nodes [node-name] [key=value:NoSchedule]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does NoSchedule do in kubectl-taint?
Prevent scheduling.