k8s基础概念之七 污点

几个简单需要打污点的例子

1.不同的机房
2.不同的城市
3.不同的配置
    (1) GPU服务器
    (2) 纯固态硬盘服务器

污点和容忍的理念:
    taint在一类服务器上打上污点,让不能容忍这个污点的pod不能部署在这一类服务器上
    

 

 

污点简单使用

……
spec:
  containers:
  ……
  tolerations:
  - key: "master-test"       #打的污点的key
    operator: "Exists"       #不管污点的value是什么
    effect: "NoSchedule"     #打的污点的规则
---
kubectl taint node master01 master-test=test:NoSchedule
#给一个节点打上污点

#污点的一些规则
NoSchedule   禁止调度
NoExecute    如果不符合这个污点,马上被驱逐
PreferNoSchedule  尽量避免调度到该节点上,不强制

#删除污点
kubectl taint node master01 mater-test:NoSchedule-
---
#在配置yaml里面容忍该污点
……
spec:
  containers:
  ……
  tolerations:
  - key: "master-test"  #打的污点的key
    value: "test"       #打的污点的value
    effect: "NoSchedule"#打的污点的规则
    operator: "Equal"   #匹配 等于
---
……
spec:
  containers:
  ……
  tolerations:
  - key: "master-test"       #打的污点的key
    operator: "Exists"       #不管污点的value是什么
    effect: "NoSchedule"     #打的污点的规则
---
……
spec:
  containers:
  ……
  tolerations:
  - operator: "Exists"       #容忍所有污点
#一般用不到
---
……
spec:
  containers:
  ……
  tolerations:
  - operator: "Exists"       #容忍所有污点
    key: master-test
---
#在配置yaml里面容忍该污点
……
spec:
  containers:
  ……
  tolerations:
  - key: "master-test"  #打的污点的key
    value: "test"       #打的污点的value
    effect: "NoExecute"#打的污点的规则
    operator: "Equal"   #匹配 等于
    tolerationSeconds: 60  #匹配污点60秒后驱逐

 

 

污点补充

kubectl taint node node02 node-test=test:NoExecute        
[root@master01 ~]# kubectl describe pod nfsvb-57d8cc99c7-kfcnx | grep -A 1 Toler
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 360s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 360s #停留360秒后驱逐,根据业务来修改,如果要求可用非常高,参考设

 

posted @ 2021-12-16 18:05  念长卿  阅读(514)  评论(0)    收藏  举报