Pod 与具有相同标签的节点的亲和力

Pod affinity to nodes with the same label

我处于节点数量相当大的情况。节点是可消耗的,可以随时添加和删除(如果空闲)。所有节点都有标签

label.category=A or label.category=B

我想将我的 pods 安排到具有相同类别的节点上。我真的不想硬编码哪一个。我只想要一组 pods 最终会出现在同一类别节点中。

您可能想使用 Pod 拓扑扩展约束,如下例

apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
 topologySpreadConstraints:
    - maxSkew: <integer>
      topologyKey: <string>
      whenUnsatisfiable: <string>
      labelSelector: <object>