记录一下 node affinity 的 多条件与或 yaml 写法, 每次用到时都有点晕,而且多数例子给出的都是单个条件的匹配,搜索时也没找到很好的例子
下面在 nodeSelectorTerms 下面存在 matchExpressions 数组, 这些数组表达式的关系是 与 的关系
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: gpu
operator: In
values:
- "no" // 这里这个no需要加引号,或许是关键字吧,否则报错
- matchExpressions:
- key: storagetype
operator: In
values:
- "yz"
复制代码
下面在 matchExpressions 下面的多个 key 之间 是 与 的关系
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: gpu
operator: In
values:
- "no"
- key: storagetype
operator: In
values:
- "yz"
复制代码
下面多个 nodeSelectorTerms 是 或 的关系
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: gpu
operator: In
values:
- "no"
nodeSelectorTerms:
- matchExpressions:
- key: storagetype
operator: In
values:
- "yz"
复制代码
评论