Kubernetes YAML 详解之污点和容忍度(taints
2023-02-17 本文已影响0人
河码匠
一、Node 的 node.spec.taints
字段,节点定义污点
字段 | 值类型 | 说明 |
---|---|---|
* effect |
string |
污点效果NoExecute : 完全不允许在节点上运行资源,已运行的会被驱逐NoSchedule : 此节点不参与资源创建的调度,但不影响已经创建的资源PreferNoSchedule : 软污点,满足条件使用该节点,所有节点都不能满足也可以创建资源 |
* key |
string |
标签的 key |
timeAdded |
string |
|
value |
string |
标签的值 |
节点定义污点
kubectl taint nodes node1 node-aaa=bbbbbb:NoSchedule
二、 pod 的 pod.spec.tolerations
字段,容忍程度
kubectl explain pod.spec.tolerations
字段 | 值类型 | 说明 |
---|---|---|
operator |
string |
匹配方式 (类似 pod 亲和性中的 operator: In )equal :相同Exists :有一个匹配就行 |
effect |
string |
容忍程度,当但 operator 为 Exist 可空,都容忍NoExecute : 完全不允许在节点上运行资源,已运行的会被驱逐NoSchedule : 此节点不参与资源创建的调度,但不影响已经创建的资源PreferNoSchedule : 软污点,满足条件使用该节点,所有节点都不能满足也可以创建资源 |
key |
string |
标签的 key |
tolerationSeconds |
string |
与effect 的 NoExecute 配合,否则无效,能容忍 pod 存在多久,多久以后驱逐 pod |
value |
string |
标签的值,当 operator 为 Exist 可空 |
示例:
pod 容忍污点
spec:
......
tolerations: # 定义容忍度
- key: "node-aaa" # node 中污点的 key
operator: "Equal" # 匹配策略 相等
value: "bbbbbb" # 污点 key 的值
effect: "NoExecute" # 污点策略
tolerationSeconds: 3600 # 3600 秒后被驱逐 和 NoExecute 类型配合