feat(db): Migrate to CloudNativePG

This commit is contained in:
Tanguy Herbron 2023-07-27 10:09:34 +02:00
parent 54affa920e
commit dc0ee8d343
3 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -61,6 +61,20 @@ spec:
secretKeyRef: secretKeyRef:
name: grafana-secrets name: grafana-secrets
key: admin-password 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: volumes:
- name: grafana-pv - name: grafana-pv
persistentVolumeClaim: persistentVolumeClaim:

View File

@ -5,5 +5,6 @@ resources:
- pvc.yaml - pvc.yaml
- service.yaml - service.yaml
- ingress.yaml - ingress.yaml
- database.yaml
- datasources.yaml - datasources.yaml
- deployment.yaml - deployment.yaml