天天看点

K8S节点亲和性nodeAffinity

一、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      

继续阅读