一、nodeAffinity
类似于nodeSelector,根据节点上的标签来调度Pod到哪些节点
二、调度策略
硬策略(required):必须满足,不满足则Pod处于Pending状态
软策略(preferred):尝试满足,但不保证
操作符:In、NotIn、Exists、DoseNotExist、Gt、Lt
三、示例
3.1.硬策略
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: nodeType
operator: In
values:
- dev
3.2.软策略
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: nodeType
operator: In
values:
- test
如果没有nodeType=test标签的节点,则会调度到其他节点,相对于硬策略,更宽松些