From 8898c75f054710b87362a4d20784a2d5c49f2a1b Mon Sep 17 00:00:00 2001
From: Thomas Menard <tmenard@pastreur.fr>
Date: Thu, 11 Apr 2024 15:38:05 +0200
Subject: [PATCH] update postgres resource

---
 chart/templates/cronjob-django-command.yaml   | 2 +-
 chart/templates/deployment-celery-worker.yaml | 2 +-
 chart/templates/deployment-django.yaml        | 2 +-
 chart/templates/deployment-postgres.yaml      | 9 ++++++---
 chart/values.yaml                             | 4 ++--
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/chart/templates/cronjob-django-command.yaml b/chart/templates/cronjob-django-command.yaml
index 3470d041..0dabc3b6 100644
--- a/chart/templates/cronjob-django-command.yaml
+++ b/chart/templates/cronjob-django-command.yaml
@@ -28,7 +28,7 @@ spec:
                 - name: DJANGO_DEBUG
                   value: "true"
                 - name: POSTGRES_USER
-                  value: "postgres"
+                  value: "{{ .Values.postgresql.dbUser }}"
                 - name: SECRET_KEY
                   value: {{ $root.Values.django.secretKey }}
                 - name: ALLOWED_HOSTS
diff --git a/chart/templates/deployment-celery-worker.yaml b/chart/templates/deployment-celery-worker.yaml
index a42959cf..f4d444bc 100644
--- a/chart/templates/deployment-celery-worker.yaml
+++ b/chart/templates/deployment-celery-worker.yaml
@@ -66,7 +66,7 @@ spec:
                 key: password
           {{end}}
           - name: POSTGRES_USER
-            value: "postgres"
+            value: "{{ .Values.postgresql.dbUser }}"
           - name: REDIS_PASSWORD
             valueFrom:
               secretKeyRef:
diff --git a/chart/templates/deployment-django.yaml b/chart/templates/deployment-django.yaml
index 8ba38487..aa3d3588 100644
--- a/chart/templates/deployment-django.yaml
+++ b/chart/templates/deployment-django.yaml
@@ -65,7 +65,7 @@ spec:
                 key: password
           {{end}}
           - name: POSTGRES_USER
-            value: "postgres"
+            value: "{{ .Values.postgresql.dbUser }}"
           - name: REDIS_PASSWORD
             valueFrom:
               secretKeyRef:
diff --git a/chart/templates/deployment-postgres.yaml b/chart/templates/deployment-postgres.yaml
index 43541f55..6994bc71 100644
--- a/chart/templates/deployment-postgres.yaml
+++ b/chart/templates/deployment-postgres.yaml
@@ -10,19 +10,22 @@ spec:
   dockerImage: {{ .Values.postgresql.image }}:{{ .Values.postgresql.tag }}
   teamId: {{ .Release.Name }}
   numberOfInstances: 1
-  users:  # Application/Robot users
+  users:
     {{ .Values.postgresql.dbUser }}: []
   databases:
     {{ .Values.postgresql.dbName }}: {{ .Values.postgresql.dbUser }}
   {{- if .Values.postgresql.preparedDatabases }}
   preparedDatabases:
     {{ .Values.postgresql.dbName }}:
-      defaultUsers: false
+    defaultUsers: false
+    schemas:
+      public:
+        defaultRoles: true
+        defaultUsers: {{ .Values.postgresql.defaultUsers }}
     {{- with .Values.postgresql.preparedDatabases.extensions }}
     extensions:
     {{- toYaml . | nindent 8 }}
     {{- end }}
-    schemas: {}
   {{ end }}
   postgresql:
     version: {{ .Values.postgresql.version | quote }}
diff --git a/chart/values.yaml b/chart/values.yaml
index 14d61b3d..aab86be1 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -112,8 +112,8 @@ postgresql:
   image: registry.opensource.zalan.do/acid/spilo-14
   tag: 2.1-p3
   teamId: ippidb
-  dbUser: postgres
-  dbName: postgres
+  dbUser: ippidp_user
+  dbName: ippidp_user
   version: 14
 #  preparedDatabases:
 #    extensions: {}
-- 
GitLab