use statefulSets and readinessProbes instead of initContainers
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: StatefulSet
|
||||||
metadata:
|
metadata:
|
||||||
name: jellystat-db
|
name: jellystat-db
|
||||||
namespace: monitoring
|
namespace: monitoring
|
||||||
spec:
|
spec:
|
||||||
strategy:
|
|
||||||
type: Recreate
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: jellystat-db
|
app: jellystat-db
|
||||||
|
serviceName: jellystat-db
|
||||||
|
replicas: 1
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
@@ -18,7 +17,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: jellystat-db
|
- name: jellystat-db
|
||||||
image: postgres:alpine
|
image: postgres:18-alpine
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5432
|
- containerPort: 5432
|
||||||
env:
|
env:
|
||||||
@@ -36,7 +35,12 @@ spec:
|
|||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: postgres-data
|
- name: postgres-data
|
||||||
mountPath: /mnt/postgres
|
mountPath: /mnt/postgres
|
||||||
volumes:
|
volumeClaimTemplates:
|
||||||
- name: postgres-data
|
- metadata:
|
||||||
persistentVolumeClaim:
|
name: postgres-data
|
||||||
claimName: jellystat-longhorn
|
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
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ spec:
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: jellystat-db-service
|
name: jellystat-db
|
||||||
namespace: monitoring
|
namespace: monitoring
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
@@ -28,3 +28,4 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- port: 5432
|
- port: 5432
|
||||||
targetPort: 5432
|
targetPort: 5432
|
||||||
|
clusterIP: None
|
||||||
|
|||||||
@@ -16,15 +16,19 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: jellystat
|
app: jellystat
|
||||||
spec:
|
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:
|
containers:
|
||||||
- name: jellystat
|
- name: jellystat
|
||||||
image: cyfershepard/jellystat:1.1.6
|
image: cyfershepard/jellystat:1.1.6
|
||||||
ports:
|
readinessProbe:
|
||||||
- containerPort: 3000
|
exec:
|
||||||
|
command:
|
||||||
|
- bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
(echo >/dev/tcp/jellystat-db.monitoring.svc.cluster.local/5432)
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
failureThreshold: 3
|
||||||
env:
|
env:
|
||||||
- name: JWT_SECRET
|
- name: JWT_SECRET
|
||||||
valueFrom:
|
valueFrom:
|
||||||
@@ -37,7 +41,7 @@ spec:
|
|||||||
name: jellystat-secret
|
name: jellystat-secret
|
||||||
key: password
|
key: password
|
||||||
- name: POSTGRES_IP
|
- name: POSTGRES_IP
|
||||||
value: "jellystat-db-service"
|
value: "jellystat-db.monitoring.svc.cluster.local"
|
||||||
- name: POSTGRES_PORT
|
- name: POSTGRES_PORT
|
||||||
value: "5432"
|
value: "5432"
|
||||||
- name: POSTGRES_USER
|
- name: POSTGRES_USER
|
||||||
|
|||||||
Reference in New Issue
Block a user