From 31abd8c885d766ea13a676381defdc534fdb97e2 Mon Sep 17 00:00:00 2001 From: juan131 Date: Thu, 3 Aug 2023 11:43:35 +0200 Subject: [PATCH 1/7] [bitnami/common] Add support for customizing standard labels Signed-off-by: juan131 --- bitnami/common/Chart.yaml | 4 +-- bitnami/common/templates/_affinities.tpl | 10 ++++--- bitnami/common/templates/_labels.tpl | 35 +++++++++++++++++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/bitnami/common/Chart.yaml b/bitnami/common/Chart.yaml index 3c1c131dab1128..b622b6953dd6fb 100644 --- a/bitnami/common/Chart.yaml +++ b/bitnami/common/Chart.yaml @@ -6,7 +6,7 @@ annotations: licenses: Apache-2.0 apiVersion: v2 # Please make sure that version and appVersion are always the same. -appVersion: 2.8.0 +appVersion: 2.9.0 description: A Library Helm Chart for grouping common logic between bitnami charts. This chart is not deployable by itself. home: https://bitnami.com icon: https://bitnami.com/downloads/logos/bitnami-mark.png @@ -23,4 +23,4 @@ name: common sources: - https://github.com/bitnami/charts type: library -version: 2.8.0 +version: 2.9.0 diff --git a/bitnami/common/templates/_affinities.tpl b/bitnami/common/templates/_affinities.tpl index 0e571028f56085..b77534bb9c9766 100644 --- a/bitnami/common/templates/_affinities.tpl +++ b/bitnami/common/templates/_affinities.tpl @@ -60,15 +60,16 @@ Return a topologyKey definition {{/* Return a soft podAffinity/podAntiAffinity definition -{{ include "common.affinities.pods.soft" (dict "component" "FOO" "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "context" $) -}} +{{ include "common.affinities.pods.soft" (dict "component" "FOO" "customLabels" .Values.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "context" $) -}} */}} {{- define "common.affinities.pods.soft" -}} {{- $component := default "" .component -}} +{{- $customLabels := default (dict) .customLabels -}} {{- $extraMatchLabels := default (dict) .extraMatchLabels -}} preferredDuringSchedulingIgnoredDuringExecution: - podAffinityTerm: labelSelector: - matchLabels: {{- (include "common.labels.matchLabels" .context) | nindent 10 }} + matchLabels: {{- (include "common.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 10 }} {{- if not (empty $component) }} {{ printf "app.kubernetes.io/component: %s" $component }} {{- end }} @@ -81,14 +82,15 @@ preferredDuringSchedulingIgnoredDuringExecution: {{/* Return a hard podAffinity/podAntiAffinity definition -{{ include "common.affinities.pods.hard" (dict "component" "FOO" "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "context" $) -}} +{{ include "common.affinities.pods.hard" (dict "component" "FOO" "customLabels" .Values.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "context" $) -}} */}} {{- define "common.affinities.pods.hard" -}} {{- $component := default "" .component -}} +{{- $customLabels := default (dict) .customLabels -}} {{- $extraMatchLabels := default (dict) .extraMatchLabels -}} requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: - matchLabels: {{- (include "common.labels.matchLabels" .context) | nindent 8 }} + matchLabels: {{- (include "common.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 8 }} {{- if not (empty $component) }} {{ printf "app.kubernetes.io/component: %s" $component }} {{- end }} diff --git a/bitnami/common/templates/_labels.tpl b/bitnami/common/templates/_labels.tpl index a1d7a95bc41a94..a1f0036544d630 100644 --- a/bitnami/common/templates/_labels.tpl +++ b/bitnami/common/templates/_labels.tpl @@ -4,20 +4,41 @@ SPDX-License-Identifier: APACHE-2.0 */}} {{/* vim: set filetype=mustache: */}} + {{/* Kubernetes standard labels +{{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}} */}} {{- define "common.labels.standard" -}} -app.kubernetes.io/name: {{ include "common.names.name" . }} -helm.sh/chart: {{ include "common.names.chart" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- $customLabels := default (dict) .customLabels -}} +{{- if not (hasKey $customLabels "app.kubernetes.io/name") }} +app.kubernetes.io/name: {{ include "common.names.name" .context }} +{{- end }} +{{- if not (hasKey $customLabels "helm.sh/chart") }} +helm.sh/chart: {{ include "common.names.chart" .context }} +{{- end }} +{{- if not (hasKey $customLabels "app.kubernetes.io/instance") }} +app.kubernetes.io/instance: {{ .context.Release.Name }} +{{- end }} +{{- if not (hasKey $customLabels "app.kubernetes.io/managed-by") }} +app.kubernetes.io/managed-by: {{ .context.Release.Service }} +{{- end }} +{{- range $key, $value := $customLabels }} +{{ $key }}: {{ $value }} +{{- end }} {{- end -}} {{/* -Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector +Labels to use on inmutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector +{{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels "context" $) -}} + +We don't want to loop over custom labels appending them to the selector +since it's very likely that it will break deployemnts, services, etc. +However, it's important to overwrite the standard labels to if the user +overwrote them on metadata.labels fields. */}} {{- define "common.labels.matchLabels" -}} -app.kubernetes.io/name: {{ include "common.names.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} +{{- $customLabels := default (dict) .customLabels -}} +app.kubernetes.io/name: {{ ternary (get $customLabels "app.kubernetes.io/name") (include "common.names.name" .context) (hasKey $customLabels "app.kubernetes.io/name") }} +app.kubernetes.io/instance: {{ ternary (get $customLabels "app.kubernetes.io/instance") .context.Release.Name (hasKey $customLabels "app.kubernetes.io/instance") }} {{- end -}} From 13ee7dc75924c98efa7b8a95dd948a2564baea91 Mon Sep 17 00:00:00 2001 From: Juan Ariza Toledano Date: Thu, 3 Aug 2023 13:38:23 +0200 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: David Gomez Signed-off-by: Juan Ariza Toledano Signed-off-by: juan131 --- bitnami/common/templates/_labels.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitnami/common/templates/_labels.tpl b/bitnami/common/templates/_labels.tpl index a1f0036544d630..556f120d636927 100644 --- a/bitnami/common/templates/_labels.tpl +++ b/bitnami/common/templates/_labels.tpl @@ -29,12 +29,12 @@ app.kubernetes.io/managed-by: {{ .context.Release.Service }} {{- end -}} {{/* -Labels to use on inmutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector +Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector {{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels "context" $) -}} We don't want to loop over custom labels appending them to the selector since it's very likely that it will break deployemnts, services, etc. -However, it's important to overwrite the standard labels to if the user +However, it's important to overwrite the standard labels if the user overwrote them on metadata.labels fields. */}} {{- define "common.labels.matchLabels" -}} From 34b868db7c9b48f011c0bab4b828bc6d1de09387 Mon Sep 17 00:00:00 2001 From: juan131 Date: Fri, 4 Aug 2023 08:19:41 +0200 Subject: [PATCH 3/7] fix: typo in comment Signed-off-by: juan131 --- bitnami/common/templates/_labels.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitnami/common/templates/_labels.tpl b/bitnami/common/templates/_labels.tpl index 556f120d636927..6858920cefaf9e 100644 --- a/bitnami/common/templates/_labels.tpl +++ b/bitnami/common/templates/_labels.tpl @@ -33,7 +33,7 @@ Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc. {{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels "context" $) -}} We don't want to loop over custom labels appending them to the selector -since it's very likely that it will break deployemnts, services, etc. +since it's very likely that it will break deployments, services, etc. However, it's important to overwrite the standard labels if the user overwrote them on metadata.labels fields. */}} From f7d41e1f51aba4542c92307c1cdc5fc632cebf7a Mon Sep 17 00:00:00 2001 From: juan131 Date: Tue, 8 Aug 2023 15:55:47 +0200 Subject: [PATCH 4/7] feat: update template to use new helpers' format Signed-off-by: juan131 --- .../templates/clusterrolebinding.yaml | 5 +-- template/CHART_NAME/templates/configmap.yaml | 5 +-- template/CHART_NAME/templates/daemonset.yaml | 20 ++++------- template/CHART_NAME/templates/deployment.yaml | 20 ++++------- template/CHART_NAME/templates/hpa.yaml | 6 ++-- template/CHART_NAME/templates/ingress.yaml | 14 ++------ template/CHART_NAME/templates/pdb.yaml | 8 ++--- template/CHART_NAME/templates/pvc.yaml | 14 ++------ template/CHART_NAME/templates/role.yaml | 5 +-- template/CHART_NAME/templates/secret.yaml | 5 +-- .../CHART_NAME/templates/service-account.yaml | 14 ++------ template/CHART_NAME/templates/service.yaml | 17 +++------- .../CHART_NAME/templates/servicemonitor.yaml | 23 +++++-------- .../CHART_NAME/templates/statefulset.yaml | 33 +++++++------------ template/CHART_NAME/templates/tls-secret.yaml | 10 ++---- 15 files changed, 56 insertions(+), 143 deletions(-) diff --git a/template/CHART_NAME/templates/clusterrolebinding.yaml b/template/CHART_NAME/templates/clusterrolebinding.yaml index 72d1fe83ffb910..fcabaedd710f81 100644 --- a/template/CHART_NAME/templates/clusterrolebinding.yaml +++ b/template/CHART_NAME/templates/clusterrolebinding.yaml @@ -7,11 +7,8 @@ kind: ClusterRoleBinding apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }} metadata: name: {{ template "common.names.fullname" . }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} diff --git a/template/CHART_NAME/templates/configmap.yaml b/template/CHART_NAME/templates/configmap.yaml index 0d87f4b23aabbd..ea71a0e7cc1c49 100644 --- a/template/CHART_NAME/templates/configmap.yaml +++ b/template/CHART_NAME/templates/configmap.yaml @@ -8,11 +8,8 @@ kind: ConfigMap metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} diff --git a/template/CHART_NAME/templates/daemonset.yaml b/template/CHART_NAME/templates/daemonset.yaml index 38abf0d54c8258..b8c59be9ff986e 100644 --- a/template/CHART_NAME/templates/daemonset.yaml +++ b/template/CHART_NAME/templates/daemonset.yaml @@ -8,11 +8,8 @@ kind: DaemonSet metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} @@ -20,22 +17,17 @@ spec: {{- if .Values.%%MAIN_OBJECT_BLOCK%%.updateStrategy }} updateStrategy: {{- toYaml .Values.%%MAIN_OBJECT_BLOCK%%.updateStrategy | nindent 4 }} {{- end }} + {{- $podLabels := merge .Values.%%MAIN_OBJECT_BLOCK%%.podLabels .Values.commonLabels }} selector: - matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} + matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }} app.kubernetes.io/component: %%COMPONENT_NAME%% template: metadata: {{- if .Values.%%MAIN_OBJECT_BLOCK%%.podAnnotations }} annotations: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.podAnnotations "context" $) | nindent 8 }} {{- end }} - labels: {{- include "common.labels.standard" . | nindent 8 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.%%MAIN_OBJECT_BLOCK%%.podLabels }} - {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.podLabels "context" $) | nindent 8 }} - {{- end }} - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} - {{- end }} spec: serviceAccountName: {{ template "%%TEMPLATE_NAME%%.serviceAccountName" . }} {{- include "%%TEMPLATE_NAME%%.imagePullSecrets" . | nindent 6 }} @@ -46,8 +38,8 @@ spec: affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.affinity "context" $) | nindent 8 }} {{- else }} affinity: - podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" "%%COMPONENT_NAME%%" "context" $) | nindent 10 }} - podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" "%%COMPONENT_NAME%%" "context" $) | nindent 10 }} + podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" "%%COMPONENT_NAME%%" "customLabels" $podLabels "context" $) | nindent 10 }} + podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" "%%COMPONENT_NAME%%" "customLabels" $podLabels "context" $) | nindent 10 }} nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.type "key" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.key "values" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.values) | nindent 10 }} {{- end }} {{- if .Values.%%MAIN_OBJECT_BLOCK%%.nodeSelector }} diff --git a/template/CHART_NAME/templates/deployment.yaml b/template/CHART_NAME/templates/deployment.yaml index c311725af6a9a1..425f1dcc134d85 100644 --- a/template/CHART_NAME/templates/deployment.yaml +++ b/template/CHART_NAME/templates/deployment.yaml @@ -8,11 +8,8 @@ kind: Deployment metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} @@ -23,22 +20,17 @@ spec: {{- if .Values.%%MAIN_OBJECT_BLOCK%%.updateStrategy }} strategy: {{- toYaml .Values.%%MAIN_OBJECT_BLOCK%%.updateStrategy | nindent 4 }} {{- end }} + {{- $podLabels := merge .Values.%%MAIN_OBJECT_BLOCK%%.podLabels .Values.commonLabels }} selector: - matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} + matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }} app.kubernetes.io/component: %%COMPONENT_NAME%% template: metadata: {{- if .Values.%%MAIN_OBJECT_BLOCK%%.podAnnotations }} annotations: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.podAnnotations "context" $) | nindent 8 }} {{- end }} - labels: {{- include "common.labels.standard" . | nindent 8 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.%%MAIN_OBJECT_BLOCK%%.podLabels }} - {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.podLabels "context" $) | nindent 8 }} - {{- end }} - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} - {{- end }} spec: serviceAccountName: {{ template "%%TEMPLATE_NAME%%.serviceAccountName" . }} {{- include "%%TEMPLATE_NAME%%.imagePullSecrets" . | nindent 6 }} @@ -49,8 +41,8 @@ spec: affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.affinity "context" $) | nindent 8 }} {{- else }} affinity: - podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" "%%COMPONENT_NAME%%" "context" $) | nindent 10 }} - podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" "%%COMPONENT_NAME%%" "context" $) | nindent 10 }} + podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" "%%COMPONENT_NAME%%" "customLabels" $podLabels "context" $) | nindent 10 }} + podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" "%%COMPONENT_NAME%%" "customLabels" $podLabels "context" $) | nindent 10 }} nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.type "key" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.key "values" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.values) | nindent 10 }} {{- end }} {{- if .Values.%%MAIN_OBJECT_BLOCK%%.nodeSelector }} diff --git a/template/CHART_NAME/templates/hpa.yaml b/template/CHART_NAME/templates/hpa.yaml index 3c51f016f65bc8..c267f84f5ea341 100644 --- a/template/CHART_NAME/templates/hpa.yaml +++ b/template/CHART_NAME/templates/hpa.yaml @@ -9,10 +9,8 @@ kind: HorizontalPodAutoscaler metadata: name: {{ include "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} + app.kubernetes.io/component: %%COMPONENT_NAME%% {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} diff --git a/template/CHART_NAME/templates/ingress.yaml b/template/CHART_NAME/templates/ingress.yaml index 42c7c29afbd40c..a0663b7cc9457a 100644 --- a/template/CHART_NAME/templates/ingress.yaml +++ b/template/CHART_NAME/templates/ingress.yaml @@ -9,19 +9,11 @@ kind: Ingress metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if or .Values.ingress.annotations .Values.commonAnnotations }} - annotations: - {{- if .Values.ingress.annotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.ingress.annotations "context" $) | nindent 4 }} - {{- end }} - {{- if .Values.commonAnnotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} - {{- end }} + {{- $annotations := merge .Values.ingress.annotations .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }} {{- end }} spec: {{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }} diff --git a/template/CHART_NAME/templates/pdb.yaml b/template/CHART_NAME/templates/pdb.yaml index 5f373ecc153e06..508ad20df21e85 100644 --- a/template/CHART_NAME/templates/pdb.yaml +++ b/template/CHART_NAME/templates/pdb.yaml @@ -10,11 +10,8 @@ kind: PodDisruptionBudget metadata: name: {{ include "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} @@ -25,7 +22,8 @@ spec: {{- if .Values.%%MAIN_OBJECT_BLOCK%%.pdb.maxUnavailable }} maxUnavailable: {{ .Values.%%MAIN_OBJECT_BLOCK%%.pdb.maxUnavailable }} {{- end }} + {{- $podLabels := merge .Values.%%MAIN_OBJECT_BLOCK%%.podLabels .Values.commonLabels }} selector: - matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} + matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }} app.kubernetes.io/component: %%COMPONENT_NAME%% {{- end }} diff --git a/template/CHART_NAME/templates/pvc.yaml b/template/CHART_NAME/templates/pvc.yaml index f1675a0eb05315..80fe9b8bb6a1ac 100644 --- a/template/CHART_NAME/templates/pvc.yaml +++ b/template/CHART_NAME/templates/pvc.yaml @@ -9,19 +9,11 @@ apiVersion: v1 metadata: name: {{ include "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if or .Values.persistence.annotations .Values.commonAnnotations }} - annotations: - {{- if .Values.persistence.annotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.persistence.annotations "context" $ ) | nindent 4 }} - {{- end }} - {{- if .Values.commonAnnotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} - {{- end }} + {{- $annotations := merge .Values.persistence.annotations .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }} {{- end }} spec: accessModes: diff --git a/template/CHART_NAME/templates/role.yaml b/template/CHART_NAME/templates/role.yaml index 7f3e14631f7d18..af41e2281a1dc1 100644 --- a/template/CHART_NAME/templates/role.yaml +++ b/template/CHART_NAME/templates/role.yaml @@ -9,11 +9,8 @@ apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }} metadata: name: {{ include "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} diff --git a/template/CHART_NAME/templates/secret.yaml b/template/CHART_NAME/templates/secret.yaml index c99fee9d238a3d..e20f54abafcf8e 100644 --- a/template/CHART_NAME/templates/secret.yaml +++ b/template/CHART_NAME/templates/secret.yaml @@ -8,11 +8,8 @@ kind: Secret metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} diff --git a/template/CHART_NAME/templates/service-account.yaml b/template/CHART_NAME/templates/service-account.yaml index 2d032bbfbe2087..4bfe421174f2c1 100644 --- a/template/CHART_NAME/templates/service-account.yaml +++ b/template/CHART_NAME/templates/service-account.yaml @@ -9,19 +9,11 @@ kind: ServiceAccount metadata: name: {{ include "%%TEMPLATE_NAME%%.serviceAccountName" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if or .Values.serviceAccount.annotations .Values.commonAnnotations }} - annotations: - {{- if .Values.commonAnnotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} - {{- end }} - {{- if .Values.serviceAccount.annotations }} - {{- include "common.tplvalues.render" (dict "value" .Values.serviceAccount.annotations "context" $) | nindent 4 }} - {{- end }} + {{- $annotations := merge .Values.serviceAccount.annotations .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }} {{- end }} automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} {{- end }} diff --git a/template/CHART_NAME/templates/service.yaml b/template/CHART_NAME/templates/service.yaml index 3c8a05282fedb1..8cb159673fce01 100644 --- a/template/CHART_NAME/templates/service.yaml +++ b/template/CHART_NAME/templates/service.yaml @@ -8,19 +8,11 @@ kind: Service metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if or .Values.service.annotations .Values.commonAnnotations }} - annotations: - {{- if .Values.service.annotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }} - {{- end }} - {{- if .Values.commonAnnotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} - {{- end }} + {{- $annotations := merge .Values.service.annotations .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }} {{- end }} spec: type: {{ .Values.service.type }} @@ -54,5 +46,6 @@ spec: {{- if .Values.service.extraPorts }} {{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }} {{- end }} - selector: {{- include "common.labels.matchLabels" . | nindent 4 }} + {{- $podLabels := merge .Values.%%MAIN_OBJECT_BLOCK%%.podLabels .Values.commonLabels }} + selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% diff --git a/template/CHART_NAME/templates/servicemonitor.yaml b/template/CHART_NAME/templates/servicemonitor.yaml index 5b8c1c1405dc9b..e155a5f4a5d83f 100644 --- a/template/CHART_NAME/templates/servicemonitor.yaml +++ b/template/CHART_NAME/templates/servicemonitor.yaml @@ -9,24 +9,17 @@ kind: ServiceMonitor metadata: name: {{ include "common.names.fullname" . }} namespace: {{ default (include "common.names.namespace" .) .Values.metrics.serviceMonitor.namespace | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} - {{- if .Values.metrics.serviceMonitor.labels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.labels "context" $ ) | nindent 4 }} - {{- end }} - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} - annotations: - {{- if .Values.commonAnnotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} - {{- end }} - {{- if .Values.metrics.serviceMonitor.annotations }} - {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.serviceMonitor.annotations "context" $ ) | nindent 4 }} - {{- end }} + {{- $labels := merge .Values.metrics.serviceMonitor.labels .Values.commonLabels }} + labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }} + app.kubernetes.io/component: %%COMPONENT_NAME%% + {{- if or .Values.metrics.serviceMonitor.annotations .Values.commonAnnotations }} + {{- $annotations := merge .Values.metrics.serviceMonitor.annotations .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }} + {{- end }} spec: jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel | quote }} selector: - matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} + matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }} {{- if .Values.metrics.serviceMonitor.selector }} {{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.selector "context" $) | nindent 6 }} {{- end }} diff --git a/template/CHART_NAME/templates/statefulset.yaml b/template/CHART_NAME/templates/statefulset.yaml index 214755dbf44ca6..704852a4c22d3c 100644 --- a/template/CHART_NAME/templates/statefulset.yaml +++ b/template/CHART_NAME/templates/statefulset.yaml @@ -8,11 +8,8 @@ kind: StatefulSet metadata: name: {{ template "common.names.fullname" . }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} @@ -21,8 +18,9 @@ spec: replicas: {{ .Values.replicaCount }} {{- end }} podManagementPolicy: {{ .Values.podManagementPolicy | quote }} + {{- $podLabels := merge .Values.%%MAIN_OBJECT_BLOCK%%.podLabels .Values.commonLabels }} selector: - matchLabels: {{ include "common.labels.matchLabels" . | nindent 6 }} + matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }} app.kubernetes.io/component: %%COMPONENT_NAME%% serviceName: {{ template "common.names.fullname" . }} {{- if .Values.%%MAIN_OBJECT_BLOCK%%.updateStrategy }} @@ -33,14 +31,8 @@ spec: {{- if .Values.%%MAIN_OBJECT_BLOCK%%.podAnnotations }} annotations: {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.podAnnotations "context" $) | nindent 8 }} {{- end }} - labels: {{- include "common.labels.standard" . | nindent 8 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.%%MAIN_OBJECT_BLOCK%%.podLabels }} - {{- include "common.tplvalues.render" (dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.podLabels "context" $) | nindent 8 }} - {{- end }} - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} - {{- end }} spec: serviceAccountName: {{ template "%%TEMPLATE_NAME%%.serviceAccountName" . }} {{- include "%%TEMPLATE_NAME%%.imagePullSecrets" . | nindent 6 }} @@ -51,8 +43,8 @@ spec: affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.%%MAIN_OBJECT_BLOCK%%.affinity "context" $) | nindent 8 }} {{- else }} affinity: - podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" "%%COMPONENT_NAME%%" "context" $) | nindent 10 }} - podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" "%%COMPONENT_NAME%%" "context" $) | nindent 10 }} + podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAffinityPreset "component" "%%COMPONENT_NAME%%" "customLabels" $podLabels "context" $) | nindent 10 }} + podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.podAntiAffinityPreset "component" "%%COMPONENT_NAME%%" "customLabels" $podLabels "context" $) | nindent 10 }} nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.type "key" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.key "values" .Values.%%MAIN_OBJECT_BLOCK%%.nodeAffinityPreset.values) | nindent 10 }} {{- end }} {{- if .Values.%%MAIN_OBJECT_BLOCK%%.nodeSelector }} @@ -192,15 +184,12 @@ spec: volumeClaimTemplates: - metadata: name: data - annotations: - {{- if .Values.persistence.annotations }} - {{- include "common.tplvalues.render" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }} - {{- end }} - {{- if .Values.commonAnnotations }} - {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 10 }} - {{- end }} + {{- if or .Values.persistence.annotations .Values.commonAnnotations }} + {{- $claimAnnotations := merge .Values.persistence.annotations .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" $claimAnnotations "context" $ ) | nindent 10 }} + {{- end }} {{- if .Values.commonLabels }} - labels: {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 10 }} + labels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 10 }} {{- end }} spec: accessModes: diff --git a/template/CHART_NAME/templates/tls-secret.yaml b/template/CHART_NAME/templates/tls-secret.yaml index f11da860d2a131..a1d202f352e608 100644 --- a/template/CHART_NAME/templates/tls-secret.yaml +++ b/template/CHART_NAME/templates/tls-secret.yaml @@ -11,11 +11,8 @@ kind: Secret metadata: name: {{ .name }} namespace: {{ include "common.names.namespace" $ | quote }} - labels: {{- include "common.labels.standard" $ | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if $.Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" $.Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if $.Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} @@ -35,11 +32,8 @@ kind: Secret metadata: name: {{ $secretName }} namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "common.labels.standard" . | nindent 4 }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} app.kubernetes.io/component: %%COMPONENT_NAME%% - {{- if .Values.commonLabels }} - {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} From 34807595c2523c295aec6ef624c7c5bfe9405f47 Mon Sep 17 00:00:00 2001 From: juan131 Date: Tue, 22 Aug 2023 08:48:22 +0200 Subject: [PATCH 5/7] fix: support templates on custom labels Signed-off-by: juan131 --- bitnami/common/templates/_labels.tpl | 50 +++++++++++++++++----------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/bitnami/common/templates/_labels.tpl b/bitnami/common/templates/_labels.tpl index 6858920cefaf9e..761376d03bca0f 100644 --- a/bitnami/common/templates/_labels.tpl +++ b/bitnami/common/templates/_labels.tpl @@ -10,22 +10,23 @@ Kubernetes standard labels {{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}} */}} {{- define "common.labels.standard" -}} -{{- $customLabels := default (dict) .customLabels -}} -{{- if not (hasKey $customLabels "app.kubernetes.io/name") }} -app.kubernetes.io/name: {{ include "common.names.name" .context }} -{{- end }} -{{- if not (hasKey $customLabels "helm.sh/chart") }} -helm.sh/chart: {{ include "common.names.chart" .context }} -{{- end }} -{{- if not (hasKey $customLabels "app.kubernetes.io/instance") }} -app.kubernetes.io/instance: {{ .context.Release.Name }} -{{- end }} -{{- if not (hasKey $customLabels "app.kubernetes.io/managed-by") }} -app.kubernetes.io/managed-by: {{ .context.Release.Service }} -{{- end }} -{{- range $key, $value := $customLabels }} -{{ $key }}: {{ $value }} -{{- end }} +{{- if and (hasKey . "customLabels") (hasKey . "context") -}} +{{ merge + (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) + (dict + "app.kubernetes.io/name" (include "common.names.name" .context) + "helm.sh/chart" (include "common.names.chart" .context) + "app.kubernetes.io/instance" .context.Release.Name + "app.kubernetes.io/managed-by" .context.Release.Service + ) + | toYaml +}} +{{- else -}} +app.kubernetes.io/name: {{ include "common.names.name" . }} +helm.sh/chart: {{ include "common.names.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} {{- end -}} {{/* @@ -38,7 +39,18 @@ However, it's important to overwrite the standard labels if the user overwrote them on metadata.labels fields. */}} {{- define "common.labels.matchLabels" -}} -{{- $customLabels := default (dict) .customLabels -}} -app.kubernetes.io/name: {{ ternary (get $customLabels "app.kubernetes.io/name") (include "common.names.name" .context) (hasKey $customLabels "app.kubernetes.io/name") }} -app.kubernetes.io/instance: {{ ternary (get $customLabels "app.kubernetes.io/instance") .context.Release.Name (hasKey $customLabels "app.kubernetes.io/instance") }} +{{- if and (hasKey . "customLabels") (hasKey . "context") -}} +{{- $customLabels := pick .customLabels "app.kubernetes.io/name" "app.kubernetes.io/instance" -}} +{{ merge + (include "common.tplvalues.render" (dict "value" $customLabels "context" .context) | fromYaml) + (dict + "app.kubernetes.io/name" (include "common.names.name" .context) + "app.kubernetes.io/instance" .context.Release.Name + ) + | toYaml +}} +{{- else -}} +app.kubernetes.io/name: {{ include "common.names.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} {{- end -}} From 7f191b9a201b00a8c817d57f1f58ae6249b783f9 Mon Sep 17 00:00:00 2001 From: juan131 Date: Tue, 22 Aug 2023 08:49:56 +0200 Subject: [PATCH 6/7] fix: update README Signed-off-by: juan131 --- bitnami/common/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitnami/common/README.md b/bitnami/common/README.md index b48bb7a25746bd..fe6a0100039531 100644 --- a/bitnami/common/README.md +++ b/bitnami/common/README.md @@ -7,7 +7,7 @@ A [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm) for gro ```yaml dependencies: - name: common - version: 1.x.x + version: 2.x.x repository: oci://registry-1.docker.io/bitnamicharts ``` From 39894f99c3c6c31ba8c6b5e4411f61ce0ee6df87 Mon Sep 17 00:00:00 2001 From: juan131 Date: Tue, 22 Aug 2023 11:11:57 +0200 Subject: [PATCH 7/7] fix: pick after rendering Signed-off-by: juan131 --- bitnami/common/templates/_labels.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bitnami/common/templates/_labels.tpl b/bitnami/common/templates/_labels.tpl index 761376d03bca0f..fac46076a5d26c 100644 --- a/bitnami/common/templates/_labels.tpl +++ b/bitnami/common/templates/_labels.tpl @@ -40,9 +40,8 @@ overwrote them on metadata.labels fields. */}} {{- define "common.labels.matchLabels" -}} {{- if and (hasKey . "customLabels") (hasKey . "context") -}} -{{- $customLabels := pick .customLabels "app.kubernetes.io/name" "app.kubernetes.io/instance" -}} {{ merge - (include "common.tplvalues.render" (dict "value" $customLabels "context" .context) | fromYaml) + (pick (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) "app.kubernetes.io/name" "app.kubernetes.io/instance") (dict "app.kubernetes.io/name" (include "common.names.name" .context) "app.kubernetes.io/instance" .context.Release.Name