diff --git a/charts/redis-ha/Chart.yaml b/charts/redis-ha/Chart.yaml index d4e21a86..5c4e920a 100644 --- a/charts/redis-ha/Chart.yaml +++ b/charts/redis-ha/Chart.yaml @@ -5,7 +5,7 @@ keywords: - redis - keyvalue - database -version: 4.39.0 +version: 4.40.0 appVersion: 8.8.0 description: This Helm chart provides a highly available Redis implementation with a master/slave configuration and uses Sentinel sidecars for failover management icon: https://img.icons8.com/external-tal-revivo-shadow-tal-revivo/24/external-redis-an-in-memory-data-structure-project-implementing-a-distributed-logo-shadow-tal-revivo.png diff --git a/charts/redis-ha/templates/_helpers.tpl b/charts/redis-ha/templates/_helpers.tpl index 1c518b90..fbfd8cbb 100644 --- a/charts/redis-ha/templates/_helpers.tpl +++ b/charts/redis-ha/templates/_helpers.tpl @@ -46,6 +46,29 @@ app: {{ template "redis-ha.name" . }} heritage: {{ .Release.Service | quote }} release: {{ .Release.Name | quote }} chart: {{ template "chartref" . }} +app.kubernetes.io/name: {{ template "redis-ha.name" . }} +app.kubernetes.io/managed-by: {{ .Release.Service | quote }} +app.kubernetes.io/instance: {{ .Release.Name | quote }} +helm.sh/chart: {{ template "chartref" . }} +{{- end -}} + +{{/* +Merge legacy and standard label defaults with custom label maps in order. +Custom values override defaults, except legacy labels used by selectors and +explicit required labels. Render each key once and keep all values strings. +Arguments: context, defaults (optional), customLabels (optional list), +required (optional map of labels that must retain their chart values). +*/}} +{{- define "redis-ha.labels" -}} +{{- $labels := mergeOverwrite (include "labels.standard" .context | fromYaml) (default (dict) .defaults) -}} +{{- $required := mergeOverwrite (pick $labels "app" "release" "component" "exporter") (default (dict) .required) -}} +{{- range .customLabels -}} + {{- $labels = mergeOverwrite $labels (deepCopy (default (dict) .)) -}} +{{- end -}} +{{- $labels = mergeOverwrite $labels $required -}} +{{- range $key, $value := $labels }} +{{ $key }}: {{ $value | toString | quote }} +{{- end -}} {{- end -}} {{- /* @@ -151,4 +174,4 @@ Usage: - port: {{ .Values.sentinel.tlsPort }} protocol: TCP {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/redis-ha/templates/redis-auth-secret.yaml b/charts/redis-ha/templates/redis-auth-secret.yaml index 0d9fd892..d19510f2 100644 --- a/charts/redis-ha/templates/redis-auth-secret.yaml +++ b/charts/redis-ha/templates/redis-auth-secret.yaml @@ -9,10 +9,7 @@ metadata: annotations: {{ . | toYaml | nindent 4 }} {{- end }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} type: Opaque data: {{ .Values.authKey }}: {{ .Values.redisPassword | b64enc | quote }} diff --git a/charts/redis-ha/templates/redis-ha-announce-service.yaml b/charts/redis-ha/templates/redis-ha-announce-service.yaml index bfc2449d..3d226f66 100644 --- a/charts/redis-ha/templates/redis-ha-announce-service.yaml +++ b/charts/redis-ha/templates/redis-ha-announce-service.yaml @@ -10,10 +10,7 @@ metadata: name: {{ $fullName }}-announce-{{ $i }} namespace: {{ $namespace | quote }} labels: -{{ include "labels.standard" $root | indent 4 }} - {{- range $key, $value := $root.Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" $root "customLabels" (list $root.Values.extraLabels)) | indent 4 }} annotations: {{- if (semverCompare "<=1.10-0" $.Capabilities.KubeVersion.Version) }} service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" diff --git a/charts/redis-ha/templates/redis-ha-configmap.yaml b/charts/redis-ha/templates/redis-ha-configmap.yaml index 48f2b03a..59f37e39 100644 --- a/charts/redis-ha/templates/redis-ha-configmap.yaml +++ b/charts/redis-ha/templates/redis-ha-configmap.yaml @@ -4,16 +4,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-configmap namespace: {{ .Release.Namespace | quote }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "redis-ha.fullname" . }} - {{- range $key, $value := .Values.configmap.labels }} - {{ $key }}: {{ $value | toString }} - {{- end }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "app" (include "redis-ha.fullname" .) "app.kubernetes.io/name" (include "redis-ha.fullname" .)) "customLabels" (list .Values.configmap.labels .Values.extraLabels)) | indent 4 }} data: redis.conf: | {{- include "config-redis.conf" . }} diff --git a/charts/redis-ha/templates/redis-ha-exporter-script-configmap.yaml b/charts/redis-ha/templates/redis-ha-exporter-script-configmap.yaml index a649df48..fb3d01b9 100644 --- a/charts/redis-ha/templates/redis-ha-exporter-script-configmap.yaml +++ b/charts/redis-ha/templates/redis-ha-exporter-script-configmap.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-exporter-script-configmap namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} data: script: {{ toYaml .Values.exporter.script | indent 2 }} {{- end }} \ No newline at end of file diff --git a/charts/redis-ha/templates/redis-ha-health-configmap.yaml b/charts/redis-ha/templates/redis-ha-health-configmap.yaml index 7aa70022..1bb19750 100644 --- a/charts/redis-ha/templates/redis-ha-health-configmap.yaml +++ b/charts/redis-ha/templates/redis-ha-health-configmap.yaml @@ -4,13 +4,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-health-configmap namespace: {{ .Release.Namespace | quote }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "redis-ha.fullname" . }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "app" (include "redis-ha.fullname" .) "app.kubernetes.io/name" (include "redis-ha.fullname" .)) "customLabels" (list .Values.extraLabels)) | indent 4 }} data: redis_liveness.sh: | {{- include "redis_liveness.sh" . }} diff --git a/charts/redis-ha/templates/redis-ha-network-policy.yaml b/charts/redis-ha/templates/redis-ha-network-policy.yaml index 6199a00c..e7ba7a81 100644 --- a/charts/redis-ha/templates/redis-ha-network-policy.yaml +++ b/charts/redis-ha/templates/redis-ha-network-policy.yaml @@ -12,10 +12,7 @@ metadata: {{- end }} {{- end }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.networkPolicy.labels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.networkPolicy.labels)) | indent 4 }} spec: podSelector: matchLabels: diff --git a/charts/redis-ha/templates/redis-ha-pdb.yaml b/charts/redis-ha/templates/redis-ha-pdb.yaml index fbcb5062..77fdd939 100644 --- a/charts/redis-ha/templates/redis-ha-pdb.yaml +++ b/charts/redis-ha/templates/redis-ha-pdb.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-pdb namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} spec: selector: matchLabels: diff --git a/charts/redis-ha/templates/redis-ha-role.yaml b/charts/redis-ha/templates/redis-ha-role.yaml index 8e895dc1..a5eb5ffb 100644 --- a/charts/redis-ha/templates/redis-ha-role.yaml +++ b/charts/redis-ha/templates/redis-ha-role.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }} namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} rules: - apiGroups: - "" diff --git a/charts/redis-ha/templates/redis-ha-rolebinding.yaml b/charts/redis-ha/templates/redis-ha-rolebinding.yaml index 402ba0d1..6bf3345c 100644 --- a/charts/redis-ha/templates/redis-ha-rolebinding.yaml +++ b/charts/redis-ha/templates/redis-ha-rolebinding.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }} namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} subjects: - kind: ServiceAccount name: {{ template "redis-ha.serviceAccountName" . }} diff --git a/charts/redis-ha/templates/redis-ha-secret.yaml b/charts/redis-ha/templates/redis-ha-secret.yaml index 91cc7f26..99b47c8a 100644 --- a/charts/redis-ha/templates/redis-ha-secret.yaml +++ b/charts/redis-ha/templates/redis-ha-secret.yaml @@ -11,13 +11,7 @@ metadata: name: {{ include "redis-ha.fullname" . }}-secret namespace: {{ .Release.Namespace | quote }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "redis-ha.fullname" . }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "app" (include "redis-ha.fullname" .) "app.kubernetes.io/name" (include "redis-ha.fullname" .)) "customLabels" (list .Values.extraLabels)) | indent 4 }} type: Opaque data: {{- if regexFind $regexRestoreSSH (toString .Values.restore.ssh.source) }} diff --git a/charts/redis-ha/templates/redis-ha-service.yaml b/charts/redis-ha/templates/redis-ha-service.yaml index 5fe077ea..5352589f 100644 --- a/charts/redis-ha/templates/redis-ha-service.yaml +++ b/charts/redis-ha/templates/redis-ha-service.yaml @@ -4,16 +4,7 @@ metadata: name: {{ template "redis-ha.fullname" . }} namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} -{{- if .Values.exporter.enabled }} - exporter: enabled -{{- end }} -{{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} -{{- end }} -{{- range $key, $value := .Values.serviceLabels }} - {{ $key }}: {{ $value | quote }} -{{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (ternary (dict "exporter" "enabled") (dict) .Values.exporter.enabled) "customLabels" (list .Values.extraLabels .Values.serviceLabels)) | indent 4 }} annotations: {{- if .Values.serviceAnnotations }} {{ toYaml .Values.serviceAnnotations | indent 4 }} diff --git a/charts/redis-ha/templates/redis-ha-serviceaccount.yaml b/charts/redis-ha/templates/redis-ha-serviceaccount.yaml index d28a9d08..24a70f11 100644 --- a/charts/redis-ha/templates/redis-ha-serviceaccount.yaml +++ b/charts/redis-ha/templates/redis-ha-serviceaccount.yaml @@ -5,13 +5,7 @@ metadata: name: {{ template "redis-ha.serviceAccountName" . }} namespace: {{ .Release.Namespace | quote }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "redis-ha.fullname" . }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "app" (include "redis-ha.fullname" .) "app.kubernetes.io/name" (include "redis-ha.fullname" .)) "customLabels" (list .Values.extraLabels)) | indent 4 }} {{- if .Values.serviceAccount.annotations }} annotations: {{ toYaml .Values.serviceAccount.annotations | indent 4 }} diff --git a/charts/redis-ha/templates/redis-ha-servicemonitor.yaml b/charts/redis-ha/templates/redis-ha-servicemonitor.yaml index f6293bf5..3ab2ff12 100644 --- a/charts/redis-ha/templates/redis-ha-servicemonitor.yaml +++ b/charts/redis-ha/templates/redis-ha-servicemonitor.yaml @@ -5,13 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }} namespace: {{ .Values.exporter.serviceMonitor.namespace | default .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- range $key, $value := .Values.exporter.serviceMonitor.labels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels .Values.exporter.serviceMonitor.labels)) | indent 4 }} spec: endpoints: - targetPort: {{ .Values.exporter.port }} diff --git a/charts/redis-ha/templates/redis-ha-statefulset.yaml b/charts/redis-ha/templates/redis-ha-statefulset.yaml index bab5ea73..e9b338f2 100644 --- a/charts/redis-ha/templates/redis-ha-statefulset.yaml +++ b/charts/redis-ha/templates/redis-ha-statefulset.yaml @@ -8,11 +8,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-server namespace: {{ .Release.Namespace | quote }} labels: - {{ template "redis-ha.fullname" . }}: replica - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} -{{ include "labels.standard" . | indent 4 }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels) "required" (dict (include "redis-ha.fullname" .) "replica")) | indent 4 }} annotations: {{ toYaml .Values.redis.annotations | indent 4 }} spec: @@ -41,15 +37,7 @@ spec: prometheus.io/path: {{ .Values.exporter.scrapePath }} {{- end }} labels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} - {{ template "redis-ha.fullname" . }}: replica - {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value | toString }} - {{- end }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.labels .Values.extraLabels) "required" (dict (include "redis-ha.fullname" .) "replica")) | indent 8 }} spec: {{- if .Values.redis.terminationGracePeriodSeconds }} terminationGracePeriodSeconds: {{ .Values.redis.terminationGracePeriodSeconds }} diff --git a/charts/redis-ha/templates/redis-haproxy-deployment.yaml b/charts/redis-ha/templates/redis-haproxy-deployment.yaml index 64a8bc03..db08081a 100644 --- a/charts/redis-ha/templates/redis-haproxy-deployment.yaml +++ b/charts/redis-ha/templates/redis-haproxy-deployment.yaml @@ -5,11 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-haproxy namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - component: haproxy - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "component" "haproxy" "app.kubernetes.io/component" "haproxy") "customLabels" (list .Values.extraLabels)) | indent 4 }} {{- if .Values.haproxy.deploymentAnnotations }} annotations: {{- range $key, $value := .Values.haproxy.deploymentAnnotations }} @@ -32,15 +28,7 @@ spec: metadata: name: {{ template "redis-ha.fullname" . }}-haproxy labels: - app: {{ template "redis-ha.name" . }}-haproxy - release: {{ .Release.Name }} - component: haproxy - {{- range $key, $value := .Values.haproxy.labels }} - {{ $key }}: {{ $value | toString }} - {{- end }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "app" (printf "%s-haproxy" (include "redis-ha.name" .)) "app.kubernetes.io/name" (printf "%s-haproxy" (include "redis-ha.name" .)) "component" "haproxy" "app.kubernetes.io/component" "haproxy") "customLabels" (list .Values.haproxy.labels .Values.extraLabels)) | indent 8 }} annotations: {{- if and (.Values.haproxy.metrics.enabled) (not .Values.haproxy.metrics.serviceMonitor.enabled) }} prometheus.io/port: "{{ .Values.haproxy.metrics.port }}" diff --git a/charts/redis-ha/templates/redis-haproxy-network-policy.yaml b/charts/redis-ha/templates/redis-haproxy-network-policy.yaml index a00a74ac..eb8cf823 100644 --- a/charts/redis-ha/templates/redis-haproxy-network-policy.yaml +++ b/charts/redis-ha/templates/redis-haproxy-network-policy.yaml @@ -12,10 +12,7 @@ metadata: {{- end }} {{- end }} labels: - {{- include "labels.standard" . | nindent 4 }} - {{- range $key, $value := .Values.haproxy.networkPolicy.labels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.haproxy.networkPolicy.labels)) | indent 4 }} spec: podSelector: matchLabels: diff --git a/charts/redis-ha/templates/redis-haproxy-pdb.yaml b/charts/redis-ha/templates/redis-haproxy-pdb.yaml index c4ca44e6..8b7ee59e 100644 --- a/charts/redis-ha/templates/redis-haproxy-pdb.yaml +++ b/charts/redis-ha/templates/redis-haproxy-pdb.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-haproxy-pdb namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} spec: selector: matchLabels: diff --git a/charts/redis-ha/templates/redis-haproxy-role.yaml b/charts/redis-ha/templates/redis-haproxy-role.yaml index 0cff65fa..426ef6eb 100644 --- a/charts/redis-ha/templates/redis-haproxy-role.yaml +++ b/charts/redis-ha/templates/redis-haproxy-role.yaml @@ -6,11 +6,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-haproxy namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - component: haproxy - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "component" "haproxy" "app.kubernetes.io/component" "haproxy") "customLabels" (list .Values.extraLabels)) | indent 4 }} rules: - apiGroups: - "" diff --git a/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml b/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml index 2391a464..bca98c0d 100644 --- a/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml +++ b/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml @@ -6,11 +6,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-haproxy namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - component: haproxy - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "component" "haproxy" "app.kubernetes.io/component" "haproxy") "customLabels" (list .Values.extraLabels)) | indent 4 }} subjects: - kind: ServiceAccount name: {{ template "redis-ha.serviceAccountName" . }}-haproxy diff --git a/charts/redis-ha/templates/redis-haproxy-service.yaml b/charts/redis-ha/templates/redis-haproxy-service.yaml index 2ca71424..1558be6d 100644 --- a/charts/redis-ha/templates/redis-haproxy-service.yaml +++ b/charts/redis-ha/templates/redis-haproxy-service.yaml @@ -5,14 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-haproxy namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - component: haproxy -{{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} -{{- end }} -{{- range $key, $value := .Values.haproxy.service.labels }} - {{ $key }}: {{ $value | quote }} -{{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "component" "haproxy" "app.kubernetes.io/component" "haproxy") "customLabels" (list .Values.extraLabels .Values.haproxy.service.labels)) | indent 4 }} annotations: {{- if .Values.haproxy.service.annotations }} {{ toYaml .Values.haproxy.service.annotations | indent 4 }} diff --git a/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml b/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml index f016855f..22166d33 100644 --- a/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml +++ b/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml @@ -5,11 +5,5 @@ metadata: name: {{ template "redis-ha.serviceAccountName" . }}-haproxy namespace: {{ .Release.Namespace | quote }} labels: - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} - chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app: {{ template "redis-ha.fullname" . }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "defaults" (dict "app" (include "redis-ha.fullname" .) "app.kubernetes.io/name" (include "redis-ha.fullname" .)) "customLabels" (list .Values.extraLabels)) | indent 4 }} {{- end }} diff --git a/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml b/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml index ff5a1db9..9aa85044 100644 --- a/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml +++ b/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml @@ -5,13 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-haproxy namespace: {{ .Values.haproxy.metrics.serviceMonitor.namespace | default .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- range $key, $value := .Values.haproxy.metrics.serviceMonitor.labels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels .Values.haproxy.metrics.serviceMonitor.labels)) | indent 4 }} spec: endpoints: - targetPort: {{ .Values.haproxy.metrics.port }} diff --git a/charts/redis-ha/templates/redis-tls-secret.yaml b/charts/redis-ha/templates/redis-tls-secret.yaml index e430f3a4..89cb2ab2 100644 --- a/charts/redis-ha/templates/redis-tls-secret.yaml +++ b/charts/redis-ha/templates/redis-tls-secret.yaml @@ -6,10 +6,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-tls-secret namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} type: Opaque data: {{- if .Values.tls.caCertFile }} diff --git a/charts/redis-ha/templates/sentinel-auth-secret.yaml b/charts/redis-ha/templates/sentinel-auth-secret.yaml index ced9aac8..24da7866 100644 --- a/charts/redis-ha/templates/sentinel-auth-secret.yaml +++ b/charts/redis-ha/templates/sentinel-auth-secret.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-sentinel namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} - {{- range $key, $value := .Values.extraLabels }} - {{ $key }}: {{ $value | quote }} - {{- end }} +{{ include "redis-ha.labels" (dict "context" . "customLabels" (list .Values.extraLabels)) | indent 4 }} type: Opaque data: {{ .Values.sentinel.authKey }}: {{ .Values.sentinel.password | b64enc | quote }} diff --git a/charts/redis-ha/templates/tests/test-redis-ha-configmap.yaml b/charts/redis-ha/templates/tests/test-redis-ha-configmap.yaml index fbf31ad4..dc623ca3 100644 --- a/charts/redis-ha/templates/tests/test-redis-ha-configmap.yaml +++ b/charts/redis-ha/templates/tests/test-redis-ha-configmap.yaml @@ -4,7 +4,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-configmap-test namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} +{{ include "redis-ha.labels" (dict "context" .) | indent 4 }} annotations: "helm.sh/hook": test-success spec: diff --git a/charts/redis-ha/templates/tests/test-redis-ha-pod.yaml b/charts/redis-ha/templates/tests/test-redis-ha-pod.yaml index ee8ba1b9..221420c3 100644 --- a/charts/redis-ha/templates/tests/test-redis-ha-pod.yaml +++ b/charts/redis-ha/templates/tests/test-redis-ha-pod.yaml @@ -5,7 +5,7 @@ metadata: name: {{ template "redis-ha.fullname" . }}-service-test namespace: {{ .Release.Namespace | quote }} labels: -{{ include "labels.standard" . | indent 4 }} +{{ include "redis-ha.labels" (dict "context" .) | indent 4 }} annotations: {{- if .Values.podAnnotations }} {{ toYaml .Values.podAnnotations | indent 4 }}