Taint(污点)和 Toleration(容忍)能够做用于 node 和 pod 上,其目的是优化 pod 在集群间的调度,这跟节点亲和性相似,只不过它们做用的方式相反,具备 taint 的 node 和 pod 是互斥关系,而具备节点亲和性关系的 node 和 pod 是相吸的。另外还有能够给 node 节点设置 label,经过给 pod 设置 nodeSelector 将 pod 调度到具备匹配标签的节点上。node
Taint 和 toleration 相互配合,能够用来避免 pod 被分配到不合适的节点上。每一个节点上均可以应用一个或多个 taint ,这表示对于那些不能容忍这些 taint 的 pod,是不会被该节点接受的。若是将 toleration 应用于 pod 上,则表示这些 pod 能够(但不要求)被调度到具备相应 taint 的节点上。ide
NoSchedule: 必定不能被调度 PreferNoSchedule: 尽可能不要调度 NoExecute: 不只不会调度, 还会驱逐Node上已有的Pod kubectl taint nodes node1 key1=value1:NoSchedule kubectl taint nodes node1 key1=value1:NoExecute kubectl taint nodes node1 key2=value2:NoSchedule
kubectl describe node node1
kubectl taint node node1 key1:NoSchedule- # 这里的key能够不用指定value kubectl taint node node1 key1:NoExecute- kubectl taint node node1 key1- # 删除指定key全部的effect kubectl taint node node1 key2:NoSchedule-
详细使用方法请参考
配置污点优化
kubectl taint nodes 172.16.8.100 node-role.kubernetes.io/etcd=true:NoExecute node-role.kubernetes.io/controlplane=true:NoSchedule