bjw-s / helm-charts

A collection of Helm charts
https://bjw-s.github.io/helm-charts/
Apache License 2.0
606 stars 109 forks source link

Enable Helm Template for the Pod affinity #353

Open joachimBurket opened 2 months ago

joachimBurket commented 2 months ago

Details

Describe the solution you'd like:

Allow to use Helm Template for fields in the affinity block (e.g. defaultPodOptions.affinity).

Additional Information:

I like to set the podAntiAffinity on the hostname to avoid having two Pods of the same application running on the same hosts. Generally, I configure it like so:

[....]
podAntiAffinity:
  requiredDuringSchedulingIgnoredDuringExecution:
    - labelSelector:
        matchExpressions:
          - key: app
            operator: In
            values:
              - "my-app"
      topologyKey: kubernetes.io/hostname
  preferredDuringSchedulingIgnoredDuringExecution:
    - podAffinityTerm:
        labelSelector:
          matchExpressions:
            - key: app
              operator: In
              values:
                - "my-app"
        topologyKey: region
[....]

Enabling Helm Template for the affinity block would allow me to make this re-usable for all my applications, changing my-app by {{ Release.Name }}

joachimBurket commented 2 months ago

Huge thanks for your incredible work btw! 🙏