1. Taint (stain)
1.1概念
Node affinity is a property of Pod, which makes Pod attracted to a specific type of node. This may be due to a preference or a rigid requirement. Taint (taint) is the opposite, it enables a node to exclude a specific type of Pod.
1.2设置污点
kubectl taint nodes [Node Name] key=value:[effect]
The effect can take three values:
NoSchedule #一定不能被调度【常用】
PreferNoShedule #尽量不要调度
NoExecute #不仅不会调度,而且还会驱逐Node上所有的Pod
E.g:
kubectl taint node k8smaster type=dev:NoSchedule
Add a stain to the k8smaster node, its key name is type, key value is dev, and the effect is NoSchedule. This means that only Pods with a tolerance matching this taint can be assigned to this node.
Remove stain
kubectl taint nodes [Node Name] key:[effect]-
2. Tolerations (stain tolerance)
2.1概念
Tolerance allows tainted nodes to be deployed to Pods with tolerance matching the taint
A tolerance and a taint "match" means that they have the same key name and effect, and:
如果 operator 是 Exists (此时容忍度不能指定 value)
如果 operator 是 Equal ,则它们的 value 应该相等
2.2示例
tolerations:
- key: "type"
operator: "Exists"
effect: "NoSchedule"
Indicates that the Pod can be scheduled to a node whose key is equal to type and whose action is NoSchedule