Skip to content

Commit

Permalink
Apply tpl() to affinity values to enable reuse of helpers / existing …
Browse files Browse the repository at this point in the history
…labels

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] kubernetes/ingress-nginx@af9e524

Resolves: #212
Signed-off-by: Christian Rohmann <[email protected]>
  • Loading branch information
frittentheke committed Jul 22, 2024
1 parent 0d78af2 commit c8e82f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/qdrant/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
spec:
replicas: {{ .Values.replicaCount }}
podManagementPolicy: {{ .Values.podManagementPolicy }}
selector:
:
matchLabels:
{{- include "qdrant.selectorLabels" . | nindent 6 }}
serviceName: {{ include "qdrant.fullname" . }}-headless
Expand Down Expand Up @@ -199,7 +199,7 @@ spec:
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
Expand Down
13 changes: 13 additions & 0 deletions charts/qdrant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand Down

0 comments on commit c8e82f4

Please sign in to comment.