功能
Taints and Tolerations 是pod的一個屬性,它将允許某些pod在指定的節點上或者不允許指定的pod到指定節點上或者必須要有某些的pod才能排程到指定節點上
可以通過
kubectl taint
來執行
例如
添加 Taints and Tolerations
kubectl taint nodes node1 key=value:NoSchedule
-------node1:節點名稱
-------key 就是key
-------value 就是value
-------效果是 NoSchedule
意思是說隻有擁有: key=value:NoSchedule這個屬性的pod才能排程到node1上
删除Taints and Tolerations
該屬性是在
PodSpec
下,隻有這個值才能被排程到node1上
tolerations:
- key: "key"
operator: "Equal"
value: "value"
effect: "NoSchedule"
tolerations:
- key: "key"
operator: "Exists"
effect: "NoSchedule"
以上表示隻有key=’key’ value=’value’ 或者 存在key=’key’的pod才會排程到node1上
Operator
預設是
Equal
tolerations:
- operator: "Exists"
這中情況 Exists的空鍵比對所有的鍵,值和效果,這意味着這将容忍一切
tolerations:
- key: "key"
operator: "Exists"
比對key="key"鍵關鍵字的所有效果。
kubectl taint nodes node1 key1=value1:NoSchedule
kubectl taint nodes node1 key1=value1:NoExecute
kubectl taint nodes node1 key2=value2:NoSchedule
pod要生成以下
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute"
未完待續
參考
taint-and-toleration