From a536fa009c1bfdcbb160e8aab56c3658be4ff81c Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Mon, 3 Nov 2025 15:08:16 +0100 Subject: [PATCH] chore: replace bitnami/postgresql with custom template --- helm/api-platform/Chart.lock | 7 ++-- helm/api-platform/Chart.yaml | 8 ++--- helm/api-platform/templates/postgresql.yaml | 37 +++++++++++++++++++++ helm/api-platform/templates/secrets.yaml | 2 +- helm/api-platform/values.yaml | 3 +- 5 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 helm/api-platform/templates/postgresql.yaml diff --git a/helm/api-platform/Chart.lock b/helm/api-platform/Chart.lock index e0c373afd..f536efdae 100644 --- a/helm/api-platform/Chart.lock +++ b/helm/api-platform/Chart.lock @@ -1,12 +1,9 @@ dependencies: -- name: postgresql - repository: https://charts.bitnami.com/bitnami/ - version: 15.5.6 - name: external-dns repository: https://charts.bitnami.com/bitnami/ version: 7.5.6 - name: keycloak repository: https://charts.bitnami.com/bitnami/ version: 21.4.2 -digest: sha256:fa058d1558ec980b14354478fed4725d46b1f2a9b274af9ee7bee419944e926a -generated: "2024-06-18T13:57:36.134642207+02:00" +digest: sha256:2eeb31600fc84010057a78979e8f015a3dc5ac27cd6f17e615e6e500668ecebe +generated: "2025-11-03T15:07:19.08338873+01:00" diff --git a/helm/api-platform/Chart.yaml b/helm/api-platform/Chart.yaml index 38af6c268..9a0354e89 100644 --- a/helm/api-platform/Chart.yaml +++ b/helm/api-platform/Chart.yaml @@ -25,15 +25,11 @@ version: 4.2.3 appVersion: 4.2.3 dependencies: - - name: postgresql - version: ~15.5.6 - repository: https://charts.bitnami.com/bitnami/ - condition: postgresql.enabled - name: external-dns - version: ~7.5.6 + version: 7.5.6 repository: https://charts.bitnami.com/bitnami/ condition: external-dns.enabled - name: keycloak - version: ~21.4.2 + version: 21.4.2 repository: https://charts.bitnami.com/bitnami/ condition: keycloak.enabled diff --git a/helm/api-platform/templates/postgresql.yaml b/helm/api-platform/templates/postgresql.yaml new file mode 100644 index 000000000..bf4bd5b17 --- /dev/null +++ b/helm/api-platform/templates/postgresql.yaml @@ -0,0 +1,37 @@ +{{- if .Values.postgresql.enabled -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "api-platform.fullname" . }}-initdb + labels: + {{- include "api-platform.labels" . | nindent 4 }} +type: kubernetes.io/basic-auth +data: + username: {{ .Values.postgresql.global.postgresql.auth.username | b64enc }} + password: {{ .Values.postgresql.global.postgresql.auth.password | b64enc }} +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: {{ .Release.Name }}-postgresql +spec: + instances: 1 + imageName: {{ .Values.postgresql.image.registry | default "ghcr.io" }}/{{ .Values.postgresql.image.repository | default "cloudnative-pg/postgresql" }}:{{ .Values.postgresql.image.tag | default "17" }} + superuserSecret: + name: {{ include "api-platform.fullname" . }}-initdb + bootstrap: + initdb: + database: {{ .Values.postgresql.global.postgresql.auth.database }} + owner: {{ .Values.postgresql.global.postgresql.auth.username }} + postInitSQL: + - {{ printf "ALTER USER %s CREATEDB;" .Values.postgresql.global.postgresql.auth.username | quote }} + secret: + name: {{ include "api-platform.fullname" . }}-initdb + managed: + services: + disabledDefaultServices: ["ro", "r"] + storage: + size: {{ .Values.postgresql.primary.persistence.size }} + resources: + {{- toYaml .Values.postgresql.primary.resources | nindent 4 }} +{{- end -}} diff --git a/helm/api-platform/templates/secrets.yaml b/helm/api-platform/templates/secrets.yaml index f28556305..dd109961e 100644 --- a/helm/api-platform/templates/secrets.yaml +++ b/helm/api-platform/templates/secrets.yaml @@ -7,7 +7,7 @@ metadata: type: Opaque data: {{- if .Values.postgresql.enabled }} - database-url: {{ printf "pgsql://%s:%s@%s-postgresql/%s?serverVersion=14&charset=utf8" .Values.postgresql.global.postgresql.auth.username .Values.postgresql.global.postgresql.auth.password .Release.Name .Values.postgresql.global.postgresql.auth.database | b64enc | quote }} + database-url: {{ printf "pgsql://%s:%s@%s-postgresql-rw/%s?serverVersion=13&charset=utf8" .Values.postgresql.global.postgresql.auth.username .Values.postgresql.global.postgresql.auth.password .Release.Name .Values.postgresql.global.postgresql.auth.database | b64enc | quote }} {{- else }} database-url: {{ .Values.postgresql.url | b64enc | quote }} {{- end }} diff --git a/helm/api-platform/values.yaml b/helm/api-platform/values.yaml index 80c668a97..569897cde 100644 --- a/helm/api-platform/values.yaml +++ b/helm/api-platform/values.yaml @@ -62,7 +62,6 @@ mercure: demo cors_origins http://chart-example.local https://chart-example.local -# Full configuration: https://github.com/bitnami/charts/tree/master/bitnami/postgresql postgresql: enabled: true # If bringing your own PostgreSQL, the full uri to use @@ -75,7 +74,7 @@ postgresql: password: "!ChangeMe!" database: "api" image: - repository: bitnamilegacy/postgresql + repository: "ghcr.io/cloudnative-pg/postgresql" tag: 16 # Persistent Volume Storage configuration. # ref: https://kubernetes.io/docs/user-guide/persistent-volumes