use statefulSets and readinessProbes instead of initContainers
This commit is contained in:
@@ -1,30 +1,33 @@
|
|||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: StatefulSet
|
||||||
metadata:
|
metadata:
|
||||||
name: immich-db
|
name: immich-psql
|
||||||
namespace: media
|
namespace: media
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: immich-db
|
app: immich-psql
|
||||||
|
serviceName: immich-psql
|
||||||
|
replicas: 1
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: immich-db
|
app: immich-psql
|
||||||
spec:
|
spec:
|
||||||
|
initContainers:
|
||||||
|
- name: cleanup
|
||||||
|
image: busybox
|
||||||
|
command: ['sh', '-c', 'rm -rf /var/lib/postgresql/data/lost+found']
|
||||||
|
volumeMounts:
|
||||||
|
- name: immich-db
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
containers:
|
containers:
|
||||||
- name: redis
|
|
||||||
image: docker.io/valkey/valkey:8-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571
|
|
||||||
env:
|
|
||||||
- name: REDIS_HOSTNAME
|
|
||||||
value: "localhost"
|
|
||||||
ports:
|
|
||||||
- containerPort: 6379
|
|
||||||
- name: immich-psql
|
- name: immich-psql
|
||||||
image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0
|
image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5432
|
- containerPort: 5432
|
||||||
|
name: postgres
|
||||||
env:
|
env:
|
||||||
- name: POSTGRES_PASSWORD
|
- name: POSTGRES_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
@@ -39,9 +42,13 @@ spec:
|
|||||||
value: "--data-checksums"
|
value: "--data-checksums"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /var/lib/postgresql/data
|
- mountPath: /var/lib/postgresql/data
|
||||||
name: immich
|
name: immich-db
|
||||||
volumes:
|
volumeClaimTemplates:
|
||||||
- name: immich
|
- metadata:
|
||||||
nfs:
|
name: immich-db
|
||||||
server: 10.0.0.10
|
spec:
|
||||||
path: /home/akshun/immich-data
|
accessModes: ["ReadWriteOnce"]
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 5Gi
|
||||||
|
storageClassName: longhorn
|
||||||
|
|||||||
23
clusters/default/media/immich/immich-redis.yml
Normal file
23
clusters/default/media/immich/immich-redis.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: immich-redis
|
||||||
|
namespace: media
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: immich-redis
|
||||||
|
serviceName: immich-redis
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: immich-redis
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: redis
|
||||||
|
image: docker.io/valkey/valkey:8-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571
|
||||||
|
ports:
|
||||||
|
- containerPort: 6379
|
||||||
|
name: redis
|
||||||
@@ -36,26 +36,28 @@ spec:
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: immich-psql-service
|
name: immich-psql
|
||||||
namespace: media
|
namespace: media
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: immich-db
|
app: immich-psql
|
||||||
ports:
|
ports:
|
||||||
- protocol: TCP
|
- name: postgres
|
||||||
port: 5432
|
port: 5432
|
||||||
targetPort: 5432
|
targetPort: 5432
|
||||||
|
clusterIP: None
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: immich-redis-service
|
name: immich-redis
|
||||||
namespace: media
|
namespace: media
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: immich-db
|
app: immich-redis
|
||||||
ports:
|
ports:
|
||||||
- protocol: TCP
|
- name: redis
|
||||||
port: 6379
|
port: 6379
|
||||||
targetPort: 6379
|
targetPort: 6379
|
||||||
|
clusterIP: None
|
||||||
|
|||||||
@@ -16,48 +16,37 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: immich-app
|
app: immich-app
|
||||||
spec:
|
spec:
|
||||||
initContainers:
|
|
||||||
- name: wait-for-redis
|
|
||||||
image: busybox
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
until nc -z -v -w30 immich-redis-service 6379; do
|
|
||||||
echo "Waiting for redis database to be ready..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
- name: wait-for-psql
|
|
||||||
image: busybox
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
until nc -z -v -w30 immich-psql-service 5432; do
|
|
||||||
echo "Waiting for psql database to be ready"
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
containers:
|
containers:
|
||||||
- name: immich-server
|
- name: immich-server
|
||||||
image: ghcr.io/immich-app/immich-server:v2.3.1
|
image: ghcr.io/immich-app/immich-server:v2.3.1
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
pg_isready -h immich-psql.media.svc.cluster.local -U postgres -p 5432
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 5
|
||||||
|
failureThreshold: 5
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 2283
|
- containerPort: 2283
|
||||||
env:
|
env:
|
||||||
- name: TZ
|
- name: TZ
|
||||||
value: "Asia/Kolkata"
|
value: "Asia/Kolkata"
|
||||||
- name: REDIS_HOSTNAME
|
- name: REDIS_HOSTNAME
|
||||||
value: "immich-redis-service"
|
value: "immich-redis.media.svc.cluster.local"
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: immich-postgres-secret
|
|
||||||
key: password
|
|
||||||
- name: DB_USERNAME
|
- name: DB_USERNAME
|
||||||
value: "postgres"
|
value: "postgres"
|
||||||
- name: DB_DATABASE_NAME
|
- name: DB_DATABASE_NAME
|
||||||
value: "immich"
|
value: "immich"
|
||||||
- name: DB_HOSTNAME
|
- name: DB_HOSTNAME
|
||||||
value: "immich-psql-service"
|
value: "immich-psql.media.svc.cluster.local"
|
||||||
|
- name: DB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: immich-postgres-secret
|
||||||
|
key: password
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /usr/src/app/upload
|
- mountPath: /usr/src/app/upload
|
||||||
name: pictures
|
name: pictures
|
||||||
|
|||||||
Reference in New Issue
Block a user