use statefulSets and readinessProbes instead of initContainers

This commit is contained in:
2025-12-17 20:44:53 +05:30
parent 5f63f58099
commit 66f824d41d
4 changed files with 26 additions and 32 deletions

View File

@@ -1,16 +1,15 @@
---
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: jellystat-db
namespace: monitoring
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
app: jellystat-db
serviceName: jellystat-db
replicas: 1
template:
metadata:
labels:
@@ -18,7 +17,7 @@ spec:
spec:
containers:
- name: jellystat-db
image: postgres:alpine
image: postgres:18-alpine
ports:
- containerPort: 5432
env:
@@ -36,7 +35,12 @@ spec:
volumeMounts:
- name: postgres-data
mountPath: /mnt/postgres
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: jellystat-longhorn
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
storageClassName: longhorn

View File

@@ -1,18 +1,3 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: jellystat-longhorn
namespace: monitoring
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 1Gi
storageClassName: longhorn
---
apiVersion: v1
kind: PersistentVolumeClaim

View File

@@ -20,7 +20,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: jellystat-db-service
name: jellystat-db
namespace: monitoring
spec:
selector:
@@ -28,3 +28,4 @@ spec:
ports:
- port: 5432
targetPort: 5432
clusterIP: None

View File

@@ -16,15 +16,19 @@ spec:
labels:
app: jellystat
spec:
initContainers:
- 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
readinessProbe:
exec:
command:
- bash
- -c
- |
(echo >/dev/tcp/jellystat-db.monitoring.svc.cluster.local/5432)
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
env:
- name: JWT_SECRET
valueFrom:
@@ -37,7 +41,7 @@ spec:
name: jellystat-secret
key: password
- name: POSTGRES_IP
value: "jellystat-db-service"
value: "jellystat-db.monitoring.svc.cluster.local"
- name: POSTGRES_PORT
value: "5432"
- name: POSTGRES_USER