use statefulSets and readinessProbes instead of initContainers
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user