From ff4b7711b6b47fd5c666826828db90c105de9d61 Mon Sep 17 00:00:00 2001 From: florianspk Date: Sat, 4 Jan 2025 13:47:25 +0100 Subject: [PATCH] #84 Add labels for cluster --- charts/cnpg-cluster/Chart.yaml | 2 +- charts/cnpg-cluster/templates/_helpers.tpl | 4 ++++ charts/cnpg-cluster/values.yaml | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/charts/cnpg-cluster/Chart.yaml b/charts/cnpg-cluster/Chart.yaml index f68f2db..9ab96d2 100644 --- a/charts/cnpg-cluster/Chart.yaml +++ b/charts/cnpg-cluster/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: cnpg-cluster description: A Helm chart to create cloudnative-pg.io clusters type: application -version: 2.0.1 +version: 2.0.2 appVersion: "14.5-6" diff --git a/charts/cnpg-cluster/templates/_helpers.tpl b/charts/cnpg-cluster/templates/_helpers.tpl index 868ba1c..018253e 100644 --- a/charts/cnpg-cluster/templates/_helpers.tpl +++ b/charts/cnpg-cluster/templates/_helpers.tpl @@ -35,11 +35,15 @@ Common labels */}} {{- define "cnpg-cluster.labels" -}} helm.sh/chart: {{ include "cnpg-cluster.chart" . }} +{{- if and (hasKey .Values "labels") (.Values.labels) }} +{{ toYaml .Values.labels }} +{{- else }} {{ include "cnpg-cluster.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} {{- end }} {{/* diff --git a/charts/cnpg-cluster/values.yaml b/charts/cnpg-cluster/values.yaml index 8c9ecd4..9f28391 100644 --- a/charts/cnpg-cluster/values.yaml +++ b/charts/cnpg-cluster/values.yaml @@ -28,6 +28,16 @@ nameOverride: "" # -- String to fully override cnpg-cluster.fullname template with a string fullnameOverride: "" +# -- Labels for the cluster +# This field allows adding extra labels to cluster. +# Note: The following labels cannot be set through this field, as they are reserved: +# - helm.sh/chart +# Attempting to use these labels will be cause a conflict. +labels: + # app.kubernetes.io/name: monkey-cluster + # app.kubernetes.io/instance: monkey-moon + # env: production + # -- CPU/Memory resource requests/limits resources: {} # We usually recommend not to specify default resources and to leave this as a conscious