节点亲和性 nodeAffinity和之前nodeSelector基本一样的,根据节点上标签约束来决定Pod调度到哪些节点上
两类亲和性:
(1)硬亲和性
约束条件必须满足
(2)软亲和性
尝试满足,不保证一定满足
支持常用操作符
In NotIn Exists Gt Lt DoesNoteExists
apiVersion: v1
kind: Pod
metadata:
name: with-node-affinity
spec:
affinity:
nodeAffinity:
requireDuringSchedulingIgnoreDuringExcution:
nodeSelectorTerms:
- matchExpressions:
- key: env_role
operator: In
values:
- dev
- test
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: group
operator:In
values:
- otherprod
containers:
- name: webdemo
image: nginx
反亲和性 :notIn