From dc0ee8d343e9ec9d74f232b0e137b05a6befb3bc Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 27 Jul 2023 10:09:34 +0200 Subject: [PATCH] feat(db): Migrate to CloudNativePG --- manifests/grafana/database.yaml | 31 ++++++++++++++++++++++++++++ manifests/grafana/deployment.yaml | 14 +++++++++++++ manifests/grafana/kustomization.yaml | 1 + 3 files changed, 46 insertions(+) create mode 100644 manifests/grafana/database.yaml diff --git a/manifests/grafana/database.yaml b/manifests/grafana/database.yaml new file mode 100644 index 0000000..3a0f406 --- /dev/null +++ b/manifests/grafana/database.yaml @@ -0,0 +1,31 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: grafana-db + namespace: monitoring + +spec: + instances: 1 + + storage: + size: 2Gi + storageClass: flat-storage-class + + bootstrap: + initdb: + database: grafana + owner: grafana + secret: + name: grafana-db + + postgresql: + pg_hba: + - host all all all md5 + + resources: + requests: + cpu: 100m + memory: 100Mi + limits: + cpu: 500m + memory: 500Mi diff --git a/manifests/grafana/deployment.yaml b/manifests/grafana/deployment.yaml index 3e809db..8e18c46 100644 --- a/manifests/grafana/deployment.yaml +++ b/manifests/grafana/deployment.yaml @@ -61,6 +61,20 @@ spec: secretKeyRef: name: grafana-secrets key: admin-password + - name: GF_DATABASE_TYPE + value: postgres + - name: GF_DATABASE_USER + valueFrom: + secretKeyRef: + name: grafana-db + key: username + - name: GF_DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: grafana-db + key: password + - name: GF_DATABASE_URL + value: "postgres://$(GF_DATABASE_USER):$(GF_DATABASE_PASSWORD)@grafana-db-rw.monitoring.svc.cluster.local/grafana" volumes: - name: grafana-pv persistentVolumeClaim: diff --git a/manifests/grafana/kustomization.yaml b/manifests/grafana/kustomization.yaml index 4dec0c4..f9b471f 100644 --- a/manifests/grafana/kustomization.yaml +++ b/manifests/grafana/kustomization.yaml @@ -5,5 +5,6 @@ resources: - pvc.yaml - service.yaml - ingress.yaml + - database.yaml - datasources.yaml - deployment.yaml