From 104d5f74461205fc710c18672a654a0d90f8992f Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Thu, 6 Feb 2025 11:55:58 +0100 Subject: [PATCH] only add default affinity when there are pvc labels known --- charts/library/common/templates/lib/pod/_affinity.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/charts/library/common/templates/lib/pod/_affinity.tpl b/charts/library/common/templates/lib/pod/_affinity.tpl index c038b032b1272..562d538f7bd4b 100644 --- a/charts/library/common/templates/lib/pod/_affinity.tpl +++ b/charts/library/common/templates/lib/pod/_affinity.tpl @@ -22,7 +22,8 @@ objectData: The object data to be used to render the Pod. {{- $validTypes := (list "Deployment" "StatefulSet") -}} {{/* TODO: We need to merge default with user input */}} - {{- if and (mustHas $objectData.type $validTypes) $rootCtx.Values.podOptions.defaultAffinity }} + {{- $pvcLabels := (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)) -}} + {{- if and (mustHas $objectData.type $validTypes) $pvcLabels $rootCtx.Values.podOptions.defaultAffinity }} podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: @@ -30,7 +31,7 @@ objectData: The object data to be used to render the Pod. - key: app operator: In values: - - {{include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)}} + - {{ $pvcLabels }} topologyKey: "kubernetes.io/hostname" {{- else -}} {{- with $affinity -}} {{/* TODO: Template this, so we can add some validation around easy to make mistakes. Low Prio */}}