From ad4f738abb7d385d3625d35241adb821624d89e7 Mon Sep 17 00:00:00 2001 From: Volodymyr Chernetskyi <19735328+chernetskyi@users.noreply.github.com> Date: Mon, 4 May 2026 17:20:57 +0200 Subject: [PATCH 1/2] [stable/redis-ha] Switch to standard labels Signed-off-by: Volodymyr Chernetskyi <19735328+chernetskyi@users.noreply.github.com> --- charts/redis-ha/Chart.yaml | 2 +- charts/redis-ha/templates/_helpers.tpl | 10 +++--- .../templates/redis-ha-announce-service.yaml | 4 +-- .../templates/redis-ha-configmap.yaml | 8 ++--- .../templates/redis-ha-health-configmap.yaml | 8 ++--- .../templates/redis-ha-network-policy.yaml | 16 +++++----- charts/redis-ha/templates/redis-ha-pdb.yaml | 4 +-- .../redis-ha/templates/redis-ha-secret.yaml | 10 +++--- .../redis-ha/templates/redis-ha-service.yaml | 4 +-- .../templates/redis-ha-serviceaccount.yaml | 8 ++--- .../templates/redis-ha-servicemonitor.yaml | 4 +-- .../templates/redis-ha-statefulset.yaml | 20 ++++++------ .../templates/redis-haproxy-deployment.yaml | 32 +++++++++---------- .../redis-haproxy-network-policy.yaml | 14 ++++---- .../redis-ha/templates/redis-haproxy-pdb.yaml | 6 ++-- .../templates/redis-haproxy-role.yaml | 2 +- .../templates/redis-haproxy-rolebinding.yaml | 2 +- .../templates/redis-haproxy-service.yaml | 6 ++-- .../redis-haproxy-serviceaccount.yaml | 8 ++--- .../redis-haproxy-servicemonitor.yaml | 6 ++-- 20 files changed, 87 insertions(+), 87 deletions(-) diff --git a/charts/redis-ha/Chart.yaml b/charts/redis-ha/Chart.yaml index d92cdcb5..8fa984e3 100644 --- a/charts/redis-ha/Chart.yaml +++ b/charts/redis-ha/Chart.yaml @@ -5,7 +5,7 @@ keywords: - redis - keyvalue - database -version: 4.35.10 +version: 5.0.0 appVersion: 8.2.4 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..2e75f90f 100644 --- a/charts/redis-ha/templates/_helpers.tpl +++ b/charts/redis-ha/templates/_helpers.tpl @@ -42,10 +42,10 @@ labels.standard prints the standard Helm labels. The standard labels are frequently used in metadata. */ -}} {{- define "labels.standard" -}} -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 -}} {{- /* @@ -151,4 +151,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-ha-announce-service.yaml b/charts/redis-ha/templates/redis-ha-announce-service.yaml index bfc2449d..71db685f 100644 --- a/charts/redis-ha/templates/redis-ha-announce-service.yaml +++ b/charts/redis-ha/templates/redis-ha-announce-service.yaml @@ -58,7 +58,7 @@ spec: targetPort: {{ $root.Values.exporter.portName }} {{- end }} selector: - release: {{ $root.Release.Name }} - app: {{ include "redis-ha.name" $root }} + app.kubernetes.io/instance: {{ $root.Release.Name }} + app.kubernetes.io/name: {{ include "redis-ha.name" $root }} "statefulset.kubernetes.io/pod-name": {{ $fullName }}-server-{{ $i }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-configmap.yaml b/charts/redis-ha/templates/redis-ha-configmap.yaml index 48f2b03a..c666a003 100644 --- a/charts/redis-ha/templates/redis-ha-configmap.yaml +++ b/charts/redis-ha/templates/redis-ha-configmap.yaml @@ -4,10 +4,10 @@ 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" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "redis-ha.fullname" . }} {{- range $key, $value := .Values.configmap.labels }} {{ $key }}: {{ $value | toString }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-health-configmap.yaml b/charts/redis-ha/templates/redis-ha-health-configmap.yaml index 7aa70022..edc95a08 100644 --- a/charts/redis-ha/templates/redis-ha-health-configmap.yaml +++ b/charts/redis-ha/templates/redis-ha-health-configmap.yaml @@ -4,10 +4,10 @@ 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" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "redis-ha.fullname" . }} {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-network-policy.yaml b/charts/redis-ha/templates/redis-ha-network-policy.yaml index 6199a00c..b3d42356 100644 --- a/charts/redis-ha/templates/redis-ha-network-policy.yaml +++ b/charts/redis-ha/templates/redis-ha-network-policy.yaml @@ -19,8 +19,8 @@ metadata: spec: podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} policyTypes: - Ingress - Egress @@ -28,8 +28,8 @@ spec: - to: - podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 6 }} {{- range $rule := .Values.networkPolicy.egressRules }} @@ -42,16 +42,16 @@ spec: - from: - podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 6 }} {{- if .Values.haproxy.enabled }} - from: - podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy ports: {{- include "redis-ports" . | nindent 6 }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-pdb.yaml b/charts/redis-ha/templates/redis-ha-pdb.yaml index fbcb5062..90d4b4f2 100644 --- a/charts/redis-ha/templates/redis-ha-pdb.yaml +++ b/charts/redis-ha/templates/redis-ha-pdb.yaml @@ -12,7 +12,7 @@ metadata: spec: selector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} {{ toYaml .Values.podDisruptionBudget | indent 2 }} {{- end -}} diff --git a/charts/redis-ha/templates/redis-ha-secret.yaml b/charts/redis-ha/templates/redis-ha-secret.yaml index 91cc7f26..13b2c5dc 100644 --- a/charts/redis-ha/templates/redis-ha-secret.yaml +++ b/charts/redis-ha/templates/redis-ha-secret.yaml @@ -11,10 +11,10 @@ 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" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "redis-ha.fullname" . }} {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} @@ -29,4 +29,4 @@ data: {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/redis-ha/templates/redis-ha-service.yaml b/charts/redis-ha/templates/redis-ha-service.yaml index 5fe077ea..f88ae0d5 100644 --- a/charts/redis-ha/templates/redis-ha-service.yaml +++ b/charts/redis-ha/templates/redis-ha-service.yaml @@ -53,5 +53,5 @@ spec: targetPort: {{ .Values.exporter.portName }} {{- end }} selector: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} diff --git a/charts/redis-ha/templates/redis-ha-serviceaccount.yaml b/charts/redis-ha/templates/redis-ha-serviceaccount.yaml index d28a9d08..9126bb89 100644 --- a/charts/redis-ha/templates/redis-ha-serviceaccount.yaml +++ b/charts/redis-ha/templates/redis-ha-serviceaccount.yaml @@ -5,10 +5,10 @@ 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" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "redis-ha.fullname" . }} {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-servicemonitor.yaml b/charts/redis-ha/templates/redis-ha-servicemonitor.yaml index f6293bf5..e95854b9 100644 --- a/charts/redis-ha/templates/redis-ha-servicemonitor.yaml +++ b/charts/redis-ha/templates/redis-ha-servicemonitor.yaml @@ -41,7 +41,7 @@ spec: - {{ .Release.Namespace | quote }} selector: matchLabels: - app: {{ template "redis-ha.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} exporter: enabled {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-statefulset.yaml b/charts/redis-ha/templates/redis-ha-statefulset.yaml index eeb54c23..2ef0569a 100644 --- a/charts/redis-ha/templates/redis-ha-statefulset.yaml +++ b/charts/redis-ha/templates/redis-ha-statefulset.yaml @@ -18,8 +18,8 @@ metadata: spec: selector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} serviceName: {{ template "redis-ha.fullname" . }} replicas: {{ .Values.replicas }} podManagementPolicy: {{ .Values.podManagementPolicy }} @@ -41,8 +41,8 @@ spec: prometheus.io/path: {{ .Values.exporter.scrapePath }} {{- end }} labels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} {{ template "redis-ha.fullname" . }}: replica {{- range $key, $value := .Values.labels }} {{ $key }}: {{ $value | toString }} @@ -79,8 +79,8 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: - app: {{ template "redis-ha.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} {{ template "redis-ha.fullname" . }}: replica topologyKey: kubernetes.io/hostname {{- else }} @@ -89,8 +89,8 @@ spec: podAffinityTerm: labelSelector: matchLabels: - app: {{ template "redis-ha.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} {{ template "redis-ha.fullname" . }}: replica topologyKey: kubernetes.io/hostname {{- end }} @@ -102,8 +102,8 @@ spec: whenUnsatisfiable: {{ .Values.topologySpreadConstraints.whenUnsatisfiable | default "ScheduleAnyway" }} labelSelector: matchLabels: - app: {{ template "redis-ha.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} {{ template "redis-ha.fullname" . }}: replica {{- end }} {{- if .Values.imagePullSecrets }} diff --git a/charts/redis-ha/templates/redis-haproxy-deployment.yaml b/charts/redis-ha/templates/redis-haproxy-deployment.yaml index 64a8bc03..cc257603 100644 --- a/charts/redis-ha/templates/redis-haproxy-deployment.yaml +++ b/charts/redis-ha/templates/redis-haproxy-deployment.yaml @@ -6,7 +6,7 @@ metadata: namespace: {{ .Release.Namespace | quote }} labels: {{ include "labels.standard" . | indent 4 }} - component: haproxy + app.kubernetes.io/component: haproxy {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} @@ -25,16 +25,16 @@ spec: replicas: {{ .Values.haproxy.replicas }} selector: matchLabels: - app: {{ template "redis-ha.name" . }}-haproxy - release: {{ .Release.Name }} - component: haproxy + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: haproxy template: metadata: name: {{ template "redis-ha.fullname" . }}-haproxy labels: - app: {{ template "redis-ha.name" . }}-haproxy - release: {{ .Release.Name }} - component: haproxy + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: haproxy {{- range $key, $value := .Values.haproxy.labels }} {{ $key }}: {{ $value | toString }} {{- end }} @@ -78,9 +78,9 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: - app: {{ template "redis-ha.name" . }}-haproxy - release: {{ .Release.Name }} - component: haproxy + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: haproxy topologyKey: kubernetes.io/hostname {{- else }} preferredDuringSchedulingIgnoredDuringExecution: @@ -88,9 +88,9 @@ spec: podAffinityTerm: labelSelector: matchLabels: - app: {{ template "redis-ha.name" . }}-haproxy - release: {{ .Release.Name }} - component: haproxy + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: haproxy topologyKey: kubernetes.io/hostname {{- end }} {{- end }} @@ -101,9 +101,9 @@ spec: whenUnsatisfiable: {{ .Values.topologySpreadConstraints.whenUnsatisfiable | default "ScheduleAnyway" }} labelSelector: matchLabels: - app: {{ template "redis-ha.name" . }}-haproxy - release: {{ .Release.Name }} - component: haproxy + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: haproxy {{- end }} initContainers: - name: config-init diff --git a/charts/redis-ha/templates/redis-haproxy-network-policy.yaml b/charts/redis-ha/templates/redis-haproxy-network-policy.yaml index a00a74ac..5c5214a2 100644 --- a/charts/redis-ha/templates/redis-haproxy-network-policy.yaml +++ b/charts/redis-ha/templates/redis-haproxy-network-policy.yaml @@ -19,9 +19,9 @@ metadata: spec: podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }}-haproxy - component: haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/component: haproxy policyTypes: - Ingress - Egress @@ -29,8 +29,8 @@ spec: - to: - podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 6 }} - to: @@ -50,8 +50,8 @@ spec: - from: - podSelector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 8 }} {{- range $rule := .Values.haproxy.networkPolicy.ingressRules }} diff --git a/charts/redis-ha/templates/redis-haproxy-pdb.yaml b/charts/redis-ha/templates/redis-haproxy-pdb.yaml index c4ca44e6..b4e23b5c 100644 --- a/charts/redis-ha/templates/redis-haproxy-pdb.yaml +++ b/charts/redis-ha/templates/redis-haproxy-pdb.yaml @@ -12,8 +12,8 @@ metadata: spec: selector: matchLabels: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }}-haproxy - component: haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/component: haproxy {{ toYaml .Values.haproxy.podDisruptionBudget | indent 2 }} {{- end -}} diff --git a/charts/redis-ha/templates/redis-haproxy-role.yaml b/charts/redis-ha/templates/redis-haproxy-role.yaml index 4d4425e0..81422a34 100644 --- a/charts/redis-ha/templates/redis-haproxy-role.yaml +++ b/charts/redis-ha/templates/redis-haproxy-role.yaml @@ -7,7 +7,7 @@ metadata: namespace: {{ .Release.Namespace | quote }} labels: {{ include "labels.standard" . | indent 4 }} - component: haproxy + app.kubernetes.io/component: haproxy {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml b/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml index 2391a464..ba84b314 100644 --- a/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml +++ b/charts/redis-ha/templates/redis-haproxy-rolebinding.yaml @@ -7,7 +7,7 @@ metadata: namespace: {{ .Release.Namespace | quote }} labels: {{ include "labels.standard" . | indent 4 }} - component: haproxy + app.kubernetes.io/component: haproxy {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/redis-ha/templates/redis-haproxy-service.yaml b/charts/redis-ha/templates/redis-haproxy-service.yaml index a54e2530..1946df25 100644 --- a/charts/redis-ha/templates/redis-haproxy-service.yaml +++ b/charts/redis-ha/templates/redis-haproxy-service.yaml @@ -6,7 +6,7 @@ metadata: namespace: {{ .Release.Namespace | quote }} labels: {{ include "labels.standard" . | indent 4 }} - component: haproxy + app.kubernetes.io/component: haproxy {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} @@ -61,6 +61,6 @@ spec: targetPort: {{ .name }} {{- end }} selector: - release: {{ .Release.Name }} - app: {{ template "redis-ha.name" . }}-haproxy + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy {{- end }} diff --git a/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml b/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml index f016855f..b5720fe6 100644 --- a/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml +++ b/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml @@ -5,10 +5,10 @@ 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" . }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app.kubernetes.io/name: {{ template "redis-ha.fullname" . }} {{- range $key, $value := .Values.extraLabels }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml b/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml index ff5a1db9..296e7991 100644 --- a/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml +++ b/charts/redis-ha/templates/redis-haproxy-servicemonitor.yaml @@ -33,7 +33,7 @@ spec: - {{ .Release.Namespace | quote }} selector: matchLabels: - app: {{ template "redis-ha.name" . }} - release: {{ .Release.Name }} - component: haproxy + app.kubernetes.io/name: {{ template "redis-ha.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: haproxy {{- end }} From 5b917343bacb7e91aa668c419b863f2bb09b9dad Mon Sep 17 00:00:00 2001 From: Volodymyr Chernetskyi <19735328+chernetskyi@users.noreply.github.com> Date: Sat, 17 Oct 2026 11:59:57 +0200 Subject: [PATCH 2/2] [stable/redis-ha] Preserve selectors and add standard labels Signed-off-by: Volodymyr Chernetskyi <19735328+chernetskyi@users.noreply.github.com> --- charts/redis-ha/Chart.yaml | 2 +- charts/redis-ha/templates/_helpers.tpl | 23 +++++++++++ .../redis-ha/templates/redis-auth-secret.yaml | 5 +-- .../templates/redis-ha-announce-service.yaml | 9 ++--- .../templates/redis-ha-configmap.yaml | 11 +---- .../redis-ha-exporter-script-configmap.yaml | 5 +-- .../templates/redis-ha-health-configmap.yaml | 8 +--- .../templates/redis-ha-network-policy.yaml | 21 +++++----- charts/redis-ha/templates/redis-ha-pdb.yaml | 9 ++--- charts/redis-ha/templates/redis-ha-role.yaml | 5 +-- .../templates/redis-ha-rolebinding.yaml | 5 +-- .../redis-ha/templates/redis-ha-secret.yaml | 10 +---- .../redis-ha/templates/redis-ha-service.yaml | 15 ++----- .../templates/redis-ha-serviceaccount.yaml | 8 +--- .../templates/redis-ha-servicemonitor.yaml | 12 ++---- .../templates/redis-ha-statefulset.yaml | 32 +++++---------- .../templates/redis-haproxy-deployment.yaml | 40 +++++++------------ .../redis-haproxy-network-policy.yaml | 19 ++++----- .../redis-ha/templates/redis-haproxy-pdb.yaml | 11 ++--- .../templates/redis-haproxy-role.yaml | 6 +-- .../templates/redis-haproxy-rolebinding.yaml | 6 +-- .../templates/redis-haproxy-service.yaml | 13 ++---- .../redis-haproxy-serviceaccount.yaml | 8 +--- .../redis-haproxy-servicemonitor.yaml | 14 ++----- .../redis-ha/templates/redis-tls-secret.yaml | 5 +-- .../templates/sentinel-auth-secret.yaml | 5 +-- .../tests/test-redis-ha-configmap.yaml | 2 +- .../templates/tests/test-redis-ha-pod.yaml | 2 +- 28 files changed, 104 insertions(+), 207 deletions(-) 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 2e75f90f..fbfd8cbb 100644 --- a/charts/redis-ha/templates/_helpers.tpl +++ b/charts/redis-ha/templates/_helpers.tpl @@ -42,12 +42,35 @@ labels.standard prints the standard Helm labels. The standard labels are frequently used in metadata. */ -}} {{- define "labels.standard" -}} +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 -}} + {{- /* Credit: @technosophos https://github.com/technosophos/common-chart/ 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 71db685f..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" @@ -58,7 +55,7 @@ spec: targetPort: {{ $root.Values.exporter.portName }} {{- end }} selector: - app.kubernetes.io/instance: {{ $root.Release.Name }} - app.kubernetes.io/name: {{ include "redis-ha.name" $root }} + release: {{ $root.Release.Name }} + app: {{ include "redis-ha.name" $root }} "statefulset.kubernetes.io/pod-name": {{ $fullName }}-server-{{ $i }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-configmap.yaml b/charts/redis-ha/templates/redis-ha-configmap.yaml index c666a003..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: - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app.kubernetes.io/name: {{ 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 edc95a08..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: - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app.kubernetes.io/name: {{ 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 b3d42356..e7ba7a81 100644 --- a/charts/redis-ha/templates/redis-ha-network-policy.yaml +++ b/charts/redis-ha/templates/redis-ha-network-policy.yaml @@ -12,15 +12,12 @@ 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: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} policyTypes: - Ingress - Egress @@ -28,8 +25,8 @@ spec: - to: - podSelector: matchLabels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 6 }} {{- range $rule := .Values.networkPolicy.egressRules }} @@ -42,16 +39,16 @@ spec: - from: - podSelector: matchLabels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 6 }} {{- if .Values.haproxy.enabled }} - from: - podSelector: matchLabels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }}-haproxy ports: {{- include "redis-ports" . | nindent 6 }} {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-pdb.yaml b/charts/redis-ha/templates/redis-ha-pdb.yaml index 90d4b4f2..77fdd939 100644 --- a/charts/redis-ha/templates/redis-ha-pdb.yaml +++ b/charts/redis-ha/templates/redis-ha-pdb.yaml @@ -5,14 +5,11 @@ 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: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} {{ toYaml .Values.podDisruptionBudget | indent 2 }} {{- end -}} 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 13b2c5dc..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: - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app.kubernetes.io/name: {{ 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) }} @@ -29,4 +23,4 @@ data: {{- end }} {{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/redis-ha/templates/redis-ha-service.yaml b/charts/redis-ha/templates/redis-ha-service.yaml index f88ae0d5..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 }} @@ -53,5 +44,5 @@ spec: targetPort: {{ .Values.exporter.portName }} {{- end }} selector: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} diff --git a/charts/redis-ha/templates/redis-ha-serviceaccount.yaml b/charts/redis-ha/templates/redis-ha-serviceaccount.yaml index 9126bb89..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: - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app.kubernetes.io/name: {{ 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 e95854b9..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 }} @@ -41,7 +35,7 @@ spec: - {{ .Release.Namespace | quote }} selector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} exporter: enabled {{- end }} diff --git a/charts/redis-ha/templates/redis-ha-statefulset.yaml b/charts/redis-ha/templates/redis-ha-statefulset.yaml index 6596bdaa..e9b338f2 100644 --- a/charts/redis-ha/templates/redis-ha-statefulset.yaml +++ b/charts/redis-ha/templates/redis-ha-statefulset.yaml @@ -8,18 +8,14 @@ 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: selector: matchLabels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} serviceName: {{ template "redis-ha.fullname" . }} replicas: {{ .Values.replicas }} podManagementPolicy: {{ .Values.podManagementPolicy }} @@ -41,15 +37,7 @@ spec: prometheus.io/path: {{ .Values.exporter.scrapePath }} {{- end }} labels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ 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 }} @@ -79,8 +67,8 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} {{ template "redis-ha.fullname" . }}: replica topologyKey: kubernetes.io/hostname {{- else }} @@ -89,8 +77,8 @@ spec: podAffinityTerm: labelSelector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} {{ template "redis-ha.fullname" . }}: replica topologyKey: kubernetes.io/hostname {{- end }} @@ -102,8 +90,8 @@ spec: whenUnsatisfiable: {{ .Values.topologySpreadConstraints.whenUnsatisfiable | default "ScheduleAnyway" }} labelSelector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} {{ template "redis-ha.fullname" . }}: replica {{- end }} {{- if .Values.imagePullSecrets }} diff --git a/charts/redis-ha/templates/redis-haproxy-deployment.yaml b/charts/redis-ha/templates/redis-haproxy-deployment.yaml index cc257603..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 }} - app.kubernetes.io/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 }} @@ -25,22 +21,14 @@ spec: replicas: {{ .Values.haproxy.replicas }} selector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: haproxy + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + component: haproxy template: metadata: name: {{ template "redis-ha.fullname" . }}-haproxy labels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/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 }}" @@ -78,9 +66,9 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: haproxy + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + component: haproxy topologyKey: kubernetes.io/hostname {{- else }} preferredDuringSchedulingIgnoredDuringExecution: @@ -88,9 +76,9 @@ spec: podAffinityTerm: labelSelector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: haproxy + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + component: haproxy topologyKey: kubernetes.io/hostname {{- end }} {{- end }} @@ -101,9 +89,9 @@ spec: whenUnsatisfiable: {{ .Values.topologySpreadConstraints.whenUnsatisfiable | default "ScheduleAnyway" }} labelSelector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: haproxy + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + component: haproxy {{- end }} initContainers: - name: config-init diff --git a/charts/redis-ha/templates/redis-haproxy-network-policy.yaml b/charts/redis-ha/templates/redis-haproxy-network-policy.yaml index 5c5214a2..eb8cf823 100644 --- a/charts/redis-ha/templates/redis-haproxy-network-policy.yaml +++ b/charts/redis-ha/templates/redis-haproxy-network-policy.yaml @@ -12,16 +12,13 @@ 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: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/component: haproxy + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }}-haproxy + component: haproxy policyTypes: - Ingress - Egress @@ -29,8 +26,8 @@ spec: - to: - podSelector: matchLabels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 6 }} - to: @@ -50,8 +47,8 @@ spec: - from: - podSelector: matchLabels: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }} ports: {{- include "redis-ports" . | nindent 8 }} {{- range $rule := .Values.haproxy.networkPolicy.ingressRules }} diff --git a/charts/redis-ha/templates/redis-haproxy-pdb.yaml b/charts/redis-ha/templates/redis-haproxy-pdb.yaml index b4e23b5c..8b7ee59e 100644 --- a/charts/redis-ha/templates/redis-haproxy-pdb.yaml +++ b/charts/redis-ha/templates/redis-haproxy-pdb.yaml @@ -5,15 +5,12 @@ 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: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy - app.kubernetes.io/component: haproxy + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }}-haproxy + component: haproxy {{ toYaml .Values.haproxy.podDisruptionBudget | indent 2 }} {{- end -}} diff --git a/charts/redis-ha/templates/redis-haproxy-role.yaml b/charts/redis-ha/templates/redis-haproxy-role.yaml index 36278257..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 }} - app.kubernetes.io/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 ba84b314..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 }} - app.kubernetes.io/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 5ee24702..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 }} - app.kubernetes.io/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 }} @@ -70,6 +63,6 @@ spec: targetPort: {{ .name }} {{- end }} selector: - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/name: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + app: {{ template "redis-ha.name" . }}-haproxy {{- end }} diff --git a/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml b/charts/redis-ha/templates/redis-haproxy-serviceaccount.yaml index b5720fe6..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: - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} - app.kubernetes.io/name: {{ 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 296e7991..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 }} @@ -33,7 +27,7 @@ spec: - {{ .Release.Namespace | quote }} selector: matchLabels: - app.kubernetes.io/name: {{ template "redis-ha.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: haproxy + app: {{ template "redis-ha.name" . }} + release: {{ .Release.Name }} + component: haproxy {{- end }} 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 }}