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