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 }}