Kubernetes Pod 反亲和力 - 基于标签均匀分布 Pod?

Joh*_*0te 4 scheduling affinity kubernetes

我们发现我们的 Kubernetes 集群往往存在热点,其中某些节点比其他节点获得更多的应用程序实例。

在本例中,我们部署了大量 Apache Airflow 实例,并且某些节点的 Web 或调度程序组件比其他节点多 3 倍。

是否可以使用反亲和性规则来强制 Pod 在集群中更均匀地分布?

例如“更喜欢标签最少的节点component=airflow-web?”

如果反亲和力不起作用,我们是否还应该研究其他机制?

Luk*_*man 7

尝试将其添加到 Deployment/StatefulSet .spec.template

      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: "component"
                  operator: In
                  values:
                  - airflow-web
              topologyKey: "kubernetes.io/hostname"
Run Code Online (Sandbox Code Playgroud)