From 808bfb8b2f77e6dd66a0e5cf8def14c8a20bda45 Mon Sep 17 00:00:00 2001 From: aggarwalakshun Date: Wed, 10 Dec 2025 03:39:44 +0530 Subject: [PATCH] split db and app into two deployments --- .../monitoring/jellystat/jellystat-db.yml | 42 +++++++++++++++++++ .../monitoring/jellystat/jellystat-svc.yml | 13 ++++++ .../monitoring/jellystat/jellystat.yml | 42 +++++-------------- 3 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 clusters/default/monitoring/jellystat/jellystat-db.yml diff --git a/clusters/default/monitoring/jellystat/jellystat-db.yml b/clusters/default/monitoring/jellystat/jellystat-db.yml new file mode 100644 index 0000000..54ace15 --- /dev/null +++ b/clusters/default/monitoring/jellystat/jellystat-db.yml @@ -0,0 +1,42 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jellystat-db + namespace: monitoring +spec: + strategy: + type: Recreate + replicas: 1 + selector: + matchLabels: + app: jellystat-db + template: + metadata: + labels: + app: jellystat-db + spec: + containers: + - name: jellystat-db + image: postgres:alpine + ports: + - containerPort: 5432 + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: jellystat-secret + key: password + - name: POSTGRES_DB + value: "jfstat" + - name: POSTGRES_USER + value: "postgres" + - name: PGDATA + value: /mnt/postgres/data + volumeMounts: + - name: postgres-data + mountPath: /mnt/postgres + volumes: + - name: postgres-data + persistentVolumeClaim: + claimName: jellystat-longhorn diff --git a/clusters/default/monitoring/jellystat/jellystat-svc.yml b/clusters/default/monitoring/jellystat/jellystat-svc.yml index 4addd04..1ca524e 100644 --- a/clusters/default/monitoring/jellystat/jellystat-svc.yml +++ b/clusters/default/monitoring/jellystat/jellystat-svc.yml @@ -15,3 +15,16 @@ spec: - port: 3001 targetPort: 3000 protocol: TCP + +--- +apiVersion: v1 +kind: Service +metadata: + name: jellystat-db-service + namespace: monitoring +spec: + selector: + app: jellystat-db + ports: + - port: 5432 + targetPort: 5432 diff --git a/clusters/default/monitoring/jellystat/jellystat.yml b/clusters/default/monitoring/jellystat/jellystat.yml index 5394ae1..c4a773a 100644 --- a/clusters/default/monitoring/jellystat/jellystat.yml +++ b/clusters/default/monitoring/jellystat/jellystat.yml @@ -17,55 +17,35 @@ spec: app: jellystat spec: initContainers: - - name: jellystat-db - image: postgres:alpine - restartPolicy: Always - ports: - - containerPort: 5432 - env: - - name: POSTGRES_DB - value: "jfstat" - - name: POSTGRES_USER - value: "postgres" - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: jellystat-secret - key: password - - name: PGDATA - value: /mnt/postgres/data - volumeMounts: - - name: postgres-data - mountPath: /mnt/postgres + - name: wait-for-db + image: busybox + command: ['sh', '-c', 'until nc -z -v -w30 jellystat-db-service 5432; do echo "Waiting for database..."; sleep 5; done;'] containers: - name: jellystat image: cyfershepard/jellystat:1.1.6 ports: - containerPort: 3000 env: - - name: POSTGRES_USER - value: "postgres" + - name: JWT_SECRET + valueFrom: + secretKeyRef: + name: jellystat-secret + key: jwt - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: jellystat-secret key: password - name: POSTGRES_IP - value: "localhost" + value: "jellystat-db-service" - name: POSTGRES_PORT value: "5432" - - name: JWT_SECRET - valueFrom: - secretKeyRef: - name: jellystat-secret - key: jwt + - name: POSTGRES_USER + value: "postgres" volumeMounts: - name: backups mountPath: /app/backend/backup-data volumes: - - name: postgres-data - persistentVolumeClaim: - claimName: jellystat-longhorn - name: backups persistentVolumeClaim: claimName: jellystat-backups-longhorn