From 63b1efae486ab50b5f7181eec43880c2ef28653b Mon Sep 17 00:00:00 2001 From: apriebeAVSystem Date: Thu, 19 Sep 2024 18:34:24 +0200 Subject: [PATCH 1/2] feat(cluster): Allowing a templated (tpl) cluster.initdb.owner value. (#346) Utilized the tpl function to evaluate the owner string as a template inside the Helm template. --------- Signed-off-by: apriebeAVSystem Co-authored-by: Itay Grudev Signed-off-by: Zack Stevens --- charts/cluster/templates/_bootstrap.tpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/cluster/templates/_bootstrap.tpl b/charts/cluster/templates/_bootstrap.tpl index 81665d2e2..aea7d9429 100644 --- a/charts/cluster/templates/_bootstrap.tpl +++ b/charts/cluster/templates/_bootstrap.tpl @@ -3,10 +3,13 @@ bootstrap: initdb: {{- with .Values.cluster.initdb }} - {{- with (omit . "postInitApplicationSQL") }} + {{- with (omit . "postInitApplicationSQL" "owner") }} {{- . | toYaml | nindent 4 }} {{- end }} {{- end }} + {{- if .Values.cluster.initdb.owner }} + owner: {{ tpl .Values.cluster.initdb.owner . }} + {{- end }} postInitApplicationSQL: {{- if eq .Values.type "postgis" }} - CREATE EXTENSION IF NOT EXISTS postgis; From 6ccba2e117a7ac58e8266d6265da0e6b4491600d Mon Sep 17 00:00:00 2001 From: Zack Stevens Date: Tue, 24 Sep 2024 10:54:20 -0600 Subject: [PATCH 2/2] Added support for cluster spec inheritedMetadata property Added inheritedMetadata to cluster.yaml Added inheritedMetadata to values.yaml with default value with commented example and references Added inheritedMetadata to values.schema.json Signed-off-by: Zack Stevens --- charts/cluster/templates/cluster.yaml | 4 ++++ charts/cluster/values.schema.json | 17 +++++++++++++++++ charts/cluster/values.yaml | 11 +++++++++++ 3 files changed, 32 insertions(+) diff --git a/charts/cluster/templates/cluster.yaml b/charts/cluster/templates/cluster.yaml index c1879cfef..0fad0502b 100644 --- a/charts/cluster/templates/cluster.yaml +++ b/charts/cluster/templates/cluster.yaml @@ -83,3 +83,7 @@ spec: {{- end }} {{ include "cluster.bootstrap" . | nindent 2 }} {{ include "cluster.backup" . | nindent 2 }} + {{- with .Values.cluster.inheritedMetadata }} + inheritedMetadata: + {{- toYaml . | nindent 4 }} + {{ end }} diff --git a/charts/cluster/values.schema.json b/charts/cluster/values.schema.json index 9e35d7a90..57e0a3198 100644 --- a/charts/cluster/values.schema.json +++ b/charts/cluster/values.schema.json @@ -199,6 +199,23 @@ "imagePullSecrets": { "type": "array" }, + "inheritedMetadata": { + "type": "object", + "properties": { + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, "initdb": { "type": "object" }, diff --git a/charts/cluster/values.yaml b/charts/cluster/values.yaml index 8398c74d1..b5d89318f 100644 --- a/charts/cluster/values.yaml +++ b/charts/cluster/values.yaml @@ -267,6 +267,17 @@ cluster: additionalLabels: {} annotations: {} + # -- metadata to be inherited by all resources related to a Cluster, annotations and labels defined here will be + # added to all cluster resources if they match the operator's INHERITED_ANNOTATIONS or INHERITED_LABELS + # See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-EmbeddedObjectMetadata + # See: https://cloudnative-pg.io/documentation/current/operator_conf/#defining-an-operator-config-map + inheritedMetadata: {} + # annotations: + # my.custom: annotation + # another.custom: annotation + # labels: + # my.custom: label + # another.custom: label backups: