From 83345011ce74d0ef10e18620337fcf06d718beef Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 2 Feb 2025 13:56:01 +0100 Subject: [PATCH 1/9] feat(common): add basic support for pod affinity --- charts/library/common/Chart.yaml | 2 +- .../common/templates/lib/pod/_affinity.tpl | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 charts/library/common/templates/lib/pod/_affinity.tpl diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 01ff0df1ac486..42fe1986c256c 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -48,4 +48,4 @@ sources: - https://hub.docker.com/_/ - https://hub.docker.com/r/mikefarah/yq type: library -version: 26.0.1 +version: 26.1.0 diff --git a/charts/library/common/templates/lib/pod/_affinity.tpl b/charts/library/common/templates/lib/pod/_affinity.tpl new file mode 100644 index 0000000000000..ddb7287dfd6a1 --- /dev/null +++ b/charts/library/common/templates/lib/pod/_affinity.tpl @@ -0,0 +1,27 @@ +{{/* Returns pod affinity */}} +{{/* Call this template: +{{ include "tc.v1.common.lib.pod.affinity" (dict "rootCtx" $ "objectData" $objectData) }} +rootCtx: The root context of the chart. +objectData: The object data to be used to render the Pod. +*/}} +{{- define "tc.v1.common.lib.pod.affinity" -}} + {{- $rootCtx := .rootCtx -}} + {{- $objectData := .objectData -}} + + {{- $affinity := list -}} + + {{/* Initialize from the "global" option */}} + {{- with $rootCtx.Values.podOptions.affinity -}} + {{- $affinity = . -}} + {{- end -}} + + {{/* Override with pods option */}} + {{- with $objectData.podSpec.affinity -}} + {{- $affinity = . -}} + {{- end -}} + + {{- $validTypes := (list "Deployment" "StatefulSet") -}} + {{- with $affinity -}} {{/* TODO: Template this, so we can add some validation around easy to make mistakes. Low Prio */}} + {{- . | toYaml | nindent 0 }} + {{- end -}} +{{- end -}} From 33af87d94577df9af1a9f11c3f16c171071488b4 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 2 Feb 2025 13:56:27 +0100 Subject: [PATCH 2/9] hmm --- charts/library/common-test/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/library/common-test/Chart.yaml b/charts/library/common-test/Chart.yaml index a5e228cc56a64..195b2cc4970d5 100644 --- a/charts/library/common-test/Chart.yaml +++ b/charts/library/common-test/Chart.yaml @@ -7,7 +7,7 @@ apiVersion: v2 appVersion: unknown dependencies: - name: common - version: ~26.0.0 + version: ~26.1.0 repository: file://../common/ condition: "" alias: "" From 89fd9f6474506201a9458544aa94ef69f320ec4c Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Thu, 6 Feb 2025 10:48:08 +0100 Subject: [PATCH 3/9] add template for default affinity for storage tweaking --- .../common/templates/lib/pod/_affinity.tpl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/charts/library/common/templates/lib/pod/_affinity.tpl b/charts/library/common/templates/lib/pod/_affinity.tpl index ddb7287dfd6a1..6756a679b1c03 100644 --- a/charts/library/common/templates/lib/pod/_affinity.tpl +++ b/charts/library/common/templates/lib/pod/_affinity.tpl @@ -21,6 +21,21 @@ objectData: The object data to be used to render the Pod. {{- end -}} {{- $validTypes := (list "Deployment" "StatefulSet") -}} + {{- if and (mustHas $objectData.type $validTypes) $rootCtx.Values.podOptions.defaultAffinity }} + {{/* +TODO: We need to label pods with the PVCs that are attached, then use those labels here +EXAMPLE FORMAT: + podAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - PERSITENCE NAME LABEL + topologyKey: "kubernetes.io/hostname" + */}} + {{- end -}} {{- with $affinity -}} {{/* TODO: Template this, so we can add some validation around easy to make mistakes. Low Prio */}} {{- . | toYaml | nindent 0 }} {{- end -}} From e9633e499deb710127a8cfc3795a1575e8a38824 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Thu, 6 Feb 2025 11:44:52 +0100 Subject: [PATCH 4/9] create labels for PVCs added to pods --- .../templates/lib/metadata/_podLabels.tpl | 1 + .../templates/lib/metadata/_volumeLabels.tpl | 66 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 charts/library/common/templates/lib/metadata/_volumeLabels.tpl diff --git a/charts/library/common/templates/lib/metadata/_podLabels.tpl b/charts/library/common/templates/lib/metadata/_podLabels.tpl index 0f6b5370f7f6d..4766f4d6f5217 100644 --- a/charts/library/common/templates/lib/metadata/_podLabels.tpl +++ b/charts/library/common/templates/lib/metadata/_podLabels.tpl @@ -23,4 +23,5 @@ {{- fail "PodLabels - Template used in a place that is not designed to be used" -}} {{- end }} pod.lifecycle: {{ $label }} +{{include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)}} {{- end -}} diff --git a/charts/library/common/templates/lib/metadata/_volumeLabels.tpl b/charts/library/common/templates/lib/metadata/_volumeLabels.tpl new file mode 100644 index 0000000000000..7eff61f4e79ce --- /dev/null +++ b/charts/library/common/templates/lib/metadata/_volumeLabels.tpl @@ -0,0 +1,66 @@ +{{/* Labels that are added to podSpec */}} +{{/* Call this template: +{{ include "tc.v1.common.lib.metadata.volumeLabels" $ }} +*/}} +{{- define "tc.v1.common.lib.metadata.volumeLabels" -}} + + {{- $rootCtx := .rootCtx -}} + {{- $objectData := .objectData -}} + {{- $pvcNames := "" -}} + + {{- range $name, $persistenceValues := $rootCtx.Values.persistence -}} + {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $rootCtx "objectData" $persistenceValues + "name" $name "caller" "Volumes" + "key" "persistence")) -}} + {{- if (eq $enabled "true") -}} + {{- $persistence := (mustDeepCopy $persistenceValues) -}} + {{- $_ := set $persistence "shortName" $name -}} + + {{- $selected := false -}} + + {{/* If set to true, define volume */}} + {{- if $persistence.targetSelectAll -}} + {{- $selected = true -}} + + {{/* If the pod is the autopermission */}} + {{- else if eq $objectData.shortName "autopermissions" -}} + {{- if $persistence.autoPermissions -}} + {{- if $persistence.autoPermissions.enabled -}} + {{- $selected = true -}} + {{- end -}} + {{- end -}} + + {{/* If targetSelector is set, check if pod is selected */}} + {{- else if $persistence.targetSelector -}} + {{- if not (kindIs "map" $persistence.targetSelector) -}} + {{- fail (printf "Persistence - Expected [targetSelector] to be [dict], but got [%s]" (kindOf $persistence.targetSelector)) -}} + {{- end -}} + + {{- if (mustHas $objectData.shortName (keys $persistence.targetSelector)) -}} + {{- $selected = true -}} + {{- end -}} + + {{/* If no targetSelector is set or targetSelectAll, check if pod is primary */}} + {{- else if $objectData.primary -}} + {{- $selected = true -}} + {{- end -}} + + {{/* If pod selected */}} + {{- if $selected -}} + {{/* Define the volume based on type */}} + {{- $type := ($persistence.type | default $rootCtx.Values.global.fallbackDefaults.persistenceType) -}} + + {{- if eq "pvc" $type }} + {{- if $pvcNames -}} + {{ $pvcNames = ( printf "%s+%s" $pvcNames $name ) }} + {{- else -}} + {{ $pvcNames = $name }} + {{- end -}} + {{ end -}} + {{- end -}} + + {{- end -}} + {{- end -}} +"truecharts.org/pvc": {{ $pvcNames }} +{{- end -}} From 6c330967652215ae5b266e1602475ce9f844a20c Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Thu, 6 Feb 2025 11:45:21 +0100 Subject: [PATCH 5/9] Create default affinity rule, to keep pods with same PVCs on same nodes --- charts/library/common/templates/lib/pod/_affinity.tpl | 11 +++++------ charts/library/common/templates/lib/workload/_pod.tpl | 4 ++++ charts/library/common/values.yaml | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/charts/library/common/templates/lib/pod/_affinity.tpl b/charts/library/common/templates/lib/pod/_affinity.tpl index 6756a679b1c03..c038b032b1272 100644 --- a/charts/library/common/templates/lib/pod/_affinity.tpl +++ b/charts/library/common/templates/lib/pod/_affinity.tpl @@ -21,10 +21,8 @@ objectData: The object data to be used to render the Pod. {{- end -}} {{- $validTypes := (list "Deployment" "StatefulSet") -}} + {{/* TODO: We need to merge default with user input */}} {{- if and (mustHas $objectData.type $validTypes) $rootCtx.Values.podOptions.defaultAffinity }} - {{/* -TODO: We need to label pods with the PVCs that are attached, then use those labels here -EXAMPLE FORMAT: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: @@ -32,11 +30,12 @@ EXAMPLE FORMAT: - key: app operator: In values: - - PERSITENCE NAME LABEL + - {{include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)}} topologyKey: "kubernetes.io/hostname" - */}} - {{- end -}} + {{- else -}} {{- with $affinity -}} {{/* TODO: Template this, so we can add some validation around easy to make mistakes. Low Prio */}} {{- . | toYaml | nindent 0 }} {{- end -}} + {{- end -}} + {{- end -}} diff --git a/charts/library/common/templates/lib/workload/_pod.tpl b/charts/library/common/templates/lib/workload/_pod.tpl index 31e414cf77a3d..cb4b5219814e4 100644 --- a/charts/library/common/templates/lib/workload/_pod.tpl +++ b/charts/library/common/templates/lib/workload/_pod.tpl @@ -30,6 +30,10 @@ priorityClassName: {{ . }} nodeSelector: {{- . | nindent 2 }} {{- end -}} + {{- with (include "tc.v1.common.lib.pod.affinity" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }} +affinity: + {{- . | nindent 2 }} + {{- end -}} {{- with (include "tc.v1.common.lib.pod.topologySpreadConstraints" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }} topologySpreadConstraints: {{- . | nindent 2 }} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index e5c5e49a31d5e..1b61459fc92dd 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -150,6 +150,7 @@ podOptions: kubernetes.io/arch: "amd64" # -- Used to enforce a good spread for Deployments and StatefulSets by default defaultSpread: true + defaultAffinity: true topologySpreadConstraints: [] tolerations: [] schedulerName: "" From 104d5f74461205fc710c18672a654a0d90f8992f Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Thu, 6 Feb 2025 11:55:58 +0100 Subject: [PATCH 6/9] 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 */}} From 6e856ef4cceea91ee1c782871711a0d487f340f6 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 9 Feb 2025 11:48:43 +0100 Subject: [PATCH 7/9] Update _podLabels.tpl Signed-off-by: Kjeld Schouten --- charts/library/common/templates/lib/metadata/_podLabels.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/library/common/templates/lib/metadata/_podLabels.tpl b/charts/library/common/templates/lib/metadata/_podLabels.tpl index 4766f4d6f5217..f513d2b9aa9cd 100644 --- a/charts/library/common/templates/lib/metadata/_podLabels.tpl +++ b/charts/library/common/templates/lib/metadata/_podLabels.tpl @@ -23,5 +23,5 @@ {{- fail "PodLabels - Template used in a place that is not designed to be used" -}} {{- end }} pod.lifecycle: {{ $label }} -{{include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)}} + {{- end -}} From b53a74c2cc4e5e9f46d45d421614c1dadf0fd1ce Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 9 Feb 2025 11:53:54 +0100 Subject: [PATCH 8/9] move label inclusion --- charts/library/common/templates/class/_cronjob.tpl | 1 + charts/library/common/templates/class/_deployment.tpl | 1 + charts/library/common/templates/class/_job.tpl | 1 + charts/library/common/templates/class/_statefulset.tpl | 1 + 4 files changed, 4 insertions(+) diff --git a/charts/library/common/templates/class/_cronjob.tpl b/charts/library/common/templates/class/_cronjob.tpl index 0eeea41cad7b3..4e4e90e47465b 100644 --- a/charts/library/common/templates/class/_cronjob.tpl +++ b/charts/library/common/templates/class/_cronjob.tpl @@ -34,6 +34,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/class/_deployment.tpl b/charts/library/common/templates/class/_deployment.tpl index d4219186d05eb..e1b35c574bd5a 100644 --- a/charts/library/common/templates/class/_deployment.tpl +++ b/charts/library/common/templates/class/_deployment.tpl @@ -37,6 +37,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/class/_job.tpl b/charts/library/common/templates/class/_job.tpl index 6813bdbfbd8f6..c4ec15ea20b17 100644 --- a/charts/library/common/templates/class/_job.tpl +++ b/charts/library/common/templates/class/_job.tpl @@ -34,6 +34,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/class/_statefulset.tpl b/charts/library/common/templates/class/_statefulset.tpl index 157bc84868c88..7d56397449d0f 100644 --- a/charts/library/common/templates/class/_statefulset.tpl +++ b/charts/library/common/templates/class/_statefulset.tpl @@ -37,6 +37,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: From 50512cbf434aac532261e8653d9edab7e75dc1cb Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Sun, 9 Feb 2025 12:00:39 +0100 Subject: [PATCH 9/9] hmm --- charts/library/common/templates/class/_cronjob.tpl | 2 +- charts/library/common/templates/class/_deployment.tpl | 2 +- charts/library/common/templates/class/_job.tpl | 2 +- charts/library/common/templates/class/_statefulset.tpl | 2 +- charts/library/common/templates/lib/pod/_affinity.tpl | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/charts/library/common/templates/class/_cronjob.tpl b/charts/library/common/templates/class/_cronjob.tpl index 4e4e90e47465b..b7b92af00c838 100644 --- a/charts/library/common/templates/class/_cronjob.tpl +++ b/charts/library/common/templates/class/_cronjob.tpl @@ -34,7 +34,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) - (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/class/_deployment.tpl b/charts/library/common/templates/class/_deployment.tpl index e1b35c574bd5a..2e6540936c06f 100644 --- a/charts/library/common/templates/class/_deployment.tpl +++ b/charts/library/common/templates/class/_deployment.tpl @@ -37,7 +37,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) - (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/class/_job.tpl b/charts/library/common/templates/class/_job.tpl index c4ec15ea20b17..a3e4e9aa3da00 100644 --- a/charts/library/common/templates/class/_job.tpl +++ b/charts/library/common/templates/class/_job.tpl @@ -34,7 +34,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) - (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/class/_statefulset.tpl b/charts/library/common/templates/class/_statefulset.tpl index 7d56397449d0f..8de6c390bbcfc 100644 --- a/charts/library/common/templates/class/_statefulset.tpl +++ b/charts/library/common/templates/class/_statefulset.tpl @@ -37,7 +37,7 @@ spec: {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml) (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) - (include "tc.v1.common.lib.metadata.podLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) + (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml) (include "tc.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}} {{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }} labels: diff --git a/charts/library/common/templates/lib/pod/_affinity.tpl b/charts/library/common/templates/lib/pod/_affinity.tpl index 562d538f7bd4b..4da6e27cd06f8 100644 --- a/charts/library/common/templates/lib/pod/_affinity.tpl +++ b/charts/library/common/templates/lib/pod/_affinity.tpl @@ -22,7 +22,7 @@ objectData: The object data to be used to render the Pod. {{- $validTypes := (list "Deployment" "StatefulSet") -}} {{/* TODO: We need to merge default with user input */}} - {{- $pvcLabels := (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData)) -}} + {{- $pvcLabels := (include "tc.v1.common.lib.metadata.volumeLabels" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml ) -}} {{- if and (mustHas $objectData.type $validTypes) $pvcLabels $rootCtx.Values.podOptions.defaultAffinity }} podAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -31,7 +31,7 @@ objectData: The object data to be used to render the Pod. - key: app operator: In values: - - {{ $pvcLabels }} + - {{ $pvcLabels | toYaml }} topologyKey: "kubernetes.io/hostname" {{- else -}} {{- with $affinity -}} {{/* TODO: Template this, so we can add some validation around easy to make mistakes. Low Prio */}}