From 2b772976f189327aba79eb67948cc64eb1a3206b Mon Sep 17 00:00:00 2001 From: Patrick Hermann Date: Sat, 29 Aug 2026 11:05:18 +0000 Subject: [PATCH] feat(postgres): add cnpg cluster helmfile and bump operator to 0.29.0 The CloudNativePG operator was deployed declaratively, but the Cluster CR itself was only documented as a manual `kubectl apply` heredoc in the database README. Add database/postgres-cluster.yaml.gotmpl, using the official cnpg/cluster chart (0.8.1) from the repository the operator already comes from, so no new `repositories` entry is needed and the existing Renovate customManager picks the version up. Defaults are lab-shaped and fully parameterized: single instance, no PDB, no superuser access, backups and monitoring off, PostgreSQL 17. Leaving appSecretName empty lets cnpg generate the -app secret. Also bump the operator chart 0.24.0 -> 0.29.0 (app 1.26.0 -> 1.30.0), which had drifted five minor versions behind upstream. Verified on a test cluster: the operator upgrade rolls in place with the existing cluster returning to a healthy state, and a fresh deploy of the cluster helmfile against 1.30.0 comes up healthy on PostgreSQL 17.11 with the app database and owner created. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_012yzd6TJqbsBuk95w3efGiL --- database/README.md | 23 +++++++++- database/postgres-cluster.yaml.gotmpl | 40 ++++++++++++++++++ database/postgres.yaml.gotmpl | 2 +- .../postgres-cluster.values.yaml.gotmpl | 42 +++++++++++++++++++ 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 database/postgres-cluster.yaml.gotmpl create mode 100644 database/values/postgres-cluster.values.yaml.gotmpl diff --git a/database/README.md b/database/README.md index e073f449a..08a4cff79 100644 --- a/database/README.md +++ b/database/README.md @@ -181,10 +181,31 @@ helmfiles: - path: git::https://github.com/stuttgart-things/helm.git@database/postgres.yaml.gotmpl values: - namespace: postgres - - version: 0.24.0 + - version: 0.29.0 EOF ``` +### DEPLOY CLUSTER + +```bash +cat < postgres-cluster.yaml +--- +helmfiles: + - path: git::https://github.com/stuttgart-things/helm.git@database/postgres-cluster.yaml.gotmpl + values: + - namespace: postgres + - clusterName: postgres-cluster + - instances: 1 + - database: app + - owner: app + - storageSize: 8Gi + - storageClass: openebs-hostpath +EOF +``` + +Connect through the `-rw` (primary), `-ro` (replicas) or `-r` (any) service; +the owner credentials land in the generated `-app` secret. + ### CONFIGURE INSTANCE (EXAMPLE) ```bash diff --git a/database/postgres-cluster.yaml.gotmpl b/database/postgres-cluster.yaml.gotmpl new file mode 100644 index 000000000..95012d499 --- /dev/null +++ b/database/postgres-cluster.yaml.gotmpl @@ -0,0 +1,40 @@ +--- +environments: + default: + values: + - namespace: postgres + # renovate: datasource=helm depName=cluster registryUrl=https://cloudnative-pg.github.io/charts + - version: 0.8.1 + - clusterName: postgres-cluster + - type: postgresql + - postgresqlVersion: "17" + - mode: standalone + - instances: 1 + - storageSize: 8Gi + - storageClass: "" + - walStorageEnabled: false + - walStorageSize: 1Gi + - database: app + - owner: app + # existing basic-auth secret holding the owner credentials; empty = let cnpg generate one + - appSecretName: "" + - enableSuperuserAccess: false + - enablePDB: false + - monitoringEnabled: false + - podMonitorEnabled: false + - prometheusRuleEnabled: false + - backupsEnabled: false +--- +repositories: + - name: cnpg + url: https://cloudnative-pg.github.io/charts + oci: false + +releases: + - name: {{ .Values.clusterName }} + installed: true + namespace: {{ .Values.namespace }} + chart: cnpg/cluster + version: {{ .Values.version }} + values: + - "values/postgres-cluster.values.yaml.gotmpl" diff --git a/database/postgres.yaml.gotmpl b/database/postgres.yaml.gotmpl index f7749ed8a..96749cc95 100644 --- a/database/postgres.yaml.gotmpl +++ b/database/postgres.yaml.gotmpl @@ -4,7 +4,7 @@ environments: values: - namespace: postgres # renovate: datasource=helm depName=cloudnative-pg registryUrl=https://cloudnative-pg.github.io/charts - - version: 0.24.0 + - version: 0.29.0 --- repositories: - name: cnpg diff --git a/database/values/postgres-cluster.values.yaml.gotmpl b/database/values/postgres-cluster.values.yaml.gotmpl new file mode 100644 index 000000000..0507d5f4a --- /dev/null +++ b/database/values/postgres-cluster.values.yaml.gotmpl @@ -0,0 +1,42 @@ +--- +nameOverride: {{ .Values.clusterName }} +fullnameOverride: {{ .Values.clusterName }} + +type: {{ .Values.type }} +mode: {{ .Values.mode }} + +version: + postgresql: "{{ .Values.postgresqlVersion }}" + +cluster: + instances: {{ .Values.instances }} + + storage: + size: {{ .Values.storageSize }} + storageClass: "{{ .Values.storageClass }}" + + walStorage: + enabled: {{ .Values.walStorageEnabled }} + size: {{ .Values.walStorageSize }} + storageClass: "{{ .Values.storageClass }}" + + enableSuperuserAccess: {{ .Values.enableSuperuserAccess }} + enablePDB: {{ .Values.enablePDB }} + + initdb: + database: {{ .Values.database }} + owner: {{ .Values.owner }} + {{- if .Values.appSecretName }} + secret: + name: {{ .Values.appSecretName }} + {{- end }} + + monitoring: + enabled: {{ .Values.monitoringEnabled }} + podMonitor: + enabled: {{ .Values.podMonitorEnabled }} + prometheusRule: + enabled: {{ .Values.prometheusRuleEnabled }} + +backups: + enabled: {{ .Values.backupsEnabled }}