Skip to content

affinity

affinity value enables defining of raw affinity rules.

When defined, it disables/overrides automatic podAntiAffinity rules.

Note

By default affinity is undefined.

Define custom affinity rules

values.yaml
nameOverride: my-app
image:
  repository: nginx
  tag: latest

replicaCount: 3

affinity:
  podAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
    - labelSelector:
        matchExpressions:
        - key: app.kubernetes.io/instance
          operator: In
          values:
          - backend-app
      topologyKey: topology.kubernetes.io/hostname
Deploy command
helm install webapp sysbee/kubedeploy -f values.yaml

In the above example three replicas of application would require to be scheduled on Kubernetes nodes that also host the application with instance name backend-app.

For more examples on custom affinity rules, please read the official documentation.

See also: