From 1d4535c1185c86dca2c1354b03b4075a46040722 Mon Sep 17 00:00:00 2001 From: Christian Rohmann Date: Mon, 12 Aug 2024 15:08:28 +0200 Subject: [PATCH] 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] https://github.com/kubernetes/ingress-nginx/commit/af9e5246ad09a304ef68d11f1467185dbd12fe72 Resolves: #212 Signed-off-by: Christian Rohmann --- charts/qdrant/templates/statefulset.yaml | 2 +- charts/qdrant/values.yaml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/charts/qdrant/templates/statefulset.yaml b/charts/qdrant/templates/statefulset.yaml index fcfdbfb..f471123 100644 --- a/charts/qdrant/templates/statefulset.yaml +++ b/charts/qdrant/templates/statefulset.yaml @@ -199,7 +199,7 @@ spec: {{- end }} {{- with .Values.affinity }} affinity: - {{- toYaml . | nindent 8 }} + {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: diff --git a/charts/qdrant/values.yaml b/charts/qdrant/values.yaml index a343204..d520690 100644 --- a/charts/qdrant/values.yaml +++ b/charts/qdrant/values.yaml @@ -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: []