Skip to content

Affinity

Stéphane Brunner edited this page Jun 26, 2024 · 4 revisions

This corresponds to the versions > 2.3.0.

On the containers we can specify the affinity as row e.g. like that:

affinity:
  nodeAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 1
        preference:
          matchExpressions:
            - key: disktype
              operator: In
              values:
                - ssd

But this will be no easy to don't that two pods of the deployment not on the same node, for that, you can use:

affinity:
  podAntiAffinity:
    topologyKey: kubernetes.io/hostname

And if you want to use your own labels:

affinity:
  podAntiAffinity:
    labelSelector:
        k1: v1
Clone this wiki locally