From cad9ac8653019e11362e54e551a450bbdac7f417 Mon Sep 17 00:00:00 2001 From: Paul-Henry PERRIN Date: Wed, 28 Jan 2026 10:35:42 +0100 Subject: [PATCH] Add postgres database for reports --- postgres/app/kustomization.yaml | 4 ++ postgres/app/namespace.yaml | 8 ++++ postgres/base/database.yaml | 64 +++++++++++++++++++++++++++++++ postgres/base/kustomization.yaml | 2 + postgres/local/kustomization.yaml | 2 + 5 files changed, 80 insertions(+) create mode 100644 postgres/app/kustomization.yaml create mode 100644 postgres/app/namespace.yaml create mode 100644 postgres/base/database.yaml create mode 100644 postgres/base/kustomization.yaml create mode 100644 postgres/local/kustomization.yaml diff --git a/postgres/app/kustomization.yaml b/postgres/app/kustomization.yaml new file mode 100644 index 0000000..d1c09ff --- /dev/null +++ b/postgres/app/kustomization.yaml @@ -0,0 +1,4 @@ +namespace: reports-postgres +resources: +- ../base +- namespace.yaml diff --git a/postgres/app/namespace.yaml b/postgres/app/namespace.yaml new file mode 100644 index 0000000..cbc0152 --- /dev/null +++ b/postgres/app/namespace.yaml @@ -0,0 +1,8 @@ + +apiVersion: v1 +kind: Namespace +metadata: + labels: + kubernetes.io/metadata.name: reports-postgres + name: reports-postgres + diff --git a/postgres/base/database.yaml b/postgres/base/database.yaml new file mode 100644 index 0000000..eaf96dc --- /dev/null +++ b/postgres/base/database.yaml @@ -0,0 +1,64 @@ +apiVersion: kubegres.reactive-tech.io/v1 +kind: Kubegres +metadata: + name: report-db +spec: + + replicas: 2 + image: postgres:18 + + database: + size: "30Gi" + storageClassName: "standard" + + backup: + schedule: "0 */1 * * *" + pvcName: report-db-backup + volumeMount: /var/lib/backup + + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: report-db-credentials + key: superUserPassword + + - name: POSTGRES_REPLICATION_PASSWORD + valueFrom: + secretKeyRef: + name: report-db-credentials + key: replicationUserPassword + scheduler: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - report-db + topologyKey: kubernetes.io/hostname + weight: 100 +--- +apiVersion: v1 +kind: Secret +metadata: + name: report-db-credentials +type: Opaque +stringData: + superUserPassword: report-admin + replicationUserPassword: report-replication +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: report-db-backup +spec: + storageClassName: "standard" + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "200Mi" diff --git a/postgres/base/kustomization.yaml b/postgres/base/kustomization.yaml new file mode 100644 index 0000000..ca2ede8 --- /dev/null +++ b/postgres/base/kustomization.yaml @@ -0,0 +1,2 @@ +resources: +- database.yaml diff --git a/postgres/local/kustomization.yaml b/postgres/local/kustomization.yaml new file mode 100644 index 0000000..1f5c3aa --- /dev/null +++ b/postgres/local/kustomization.yaml @@ -0,0 +1,2 @@ +resources: +- ../app