Apply tpl() to affinity values to enable reuse of helpers / existing labels (#213)

The Helm tpl function [1] allows to use templates in values. This does make
sense where values might want reference existing labels of a Helm chart.
This is is the case for Pod affinity (or anti-affinity) which needs to match
the labels of the Pods created.

This is somewhat inspired by the way this was done for the NGINX Ingress
Controller with [2].

[1] https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function
[2] af9e5246ad

Resolves: #212

Signed-off-by: Christian Rohmann <christian.rohmann@inovex.de>
This commit is contained in:
Christian Rohmann
2024-08-12 15:08:28 +02:00
committed by GitHub
parent 3f5f953960
commit 1d4535c118
2 changed files with 14 additions and 1 deletions

View File

@@ -199,7 +199,7 @@ spec:
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:

View File

@@ -121,6 +121,19 @@ nodeSelector: {}
tolerations: []
affinity: {}
# podAntiAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# - labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - '{{ include "qdrant.name" . }}'
# - key: app.kubernetes.io/instance
# operator: In
# values:
# - '{{ .Release.Name }}'
# topologyKey: "kubernetes.io/hostname"
topologySpreadConstraints: []