ADD: implement migration scripts for PostgreSQL to Longhorn; update Immich configurations for namespace and persistent storage

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-25 18:51:42 +02:00
parent 1125b8b072
commit 9905abd9b4
19 changed files with 655 additions and 20 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ kind: ConfigMap
apiVersion: v1
metadata:
name: immich-env
namespace: photoprism
namespace: immich
labels:
app: immich
data:
@@ -2,9 +2,11 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: immich-database
namespace: photoprism
namespace: immich
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: immich-database
@@ -13,6 +15,8 @@ spec:
labels:
app: immich-database
spec:
securityContext:
fsGroup: 1000
containers:
- name: immich-postgres
image: "docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0"
-1
View File
@@ -2,7 +2,6 @@ kind: PersistentVolume
apiVersion: v1
metadata:
name: immich-db-pv
namespace: photoprism
labels:
app: immich-postgresql
spec:
+4 -5
View File
@@ -2,14 +2,13 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: immich-db-pvc
namespace: photoprism
namespace: immich
labels:
app: immich
spec:
accessModes:
- ReadWriteMany
- ReadWriteOnce
resources:
requests:
storage: 20Gi # Match or be less than the PV's capacity
volumeName: immich-db-pv # Bind explicitly to the PV created above
storageClassName: nfs
storage: 8Gi
storageClassName: longhorn
+1 -1
View File
@@ -2,7 +2,7 @@ kind: Service
apiVersion: v1
metadata:
name: immich-database
namespace: photoprism
namespace: immich
labels:
app: immich-database
spec:
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: immich-library-immich-pv
labels:
app: immich
spec:
capacity:
storage: 50Gi
storageClassName: nfs
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
path: /export/fastData/immichLibrary
server: 192.168.178.166
@@ -2,7 +2,6 @@ kind: PersistentVolume
apiVersion: v1
metadata:
name: immich-library-pv
namespace: immich
labels:
app: immich
spec:
@@ -2,7 +2,7 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: immich-library-pvc
namespace: photoprism
namespace: immich
labels:
app: immich
spec:
@@ -11,5 +11,5 @@ spec:
resources:
requests:
storage: 50Gi # Match or be less than the PV's capacity
volumeName: immich-library-pv # Bind explicitly to the PV created above
volumeName: immich-library-immich-pv
storageClassName: nfs
@@ -2,7 +2,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: immich-machine-learning
namespace: photoprism
namespace: immich
labels:
app: immich-machine-learning
spec:
+1 -1
View File
@@ -2,7 +2,7 @@ kind: Service
apiVersion: v1
metadata:
name: immich-machine-learning
namespace: photoprism
namespace: immich
labels:
app: immich-machine-learning
spec:
@@ -0,0 +1,19 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: immich-photos-pv
labels:
app: immich
spec:
capacity:
storage: 200Gi
storageClassName: nfs
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
server: 192.168.178.186
path: /volume1/Photos
mountOptions:
- hard
- nfsvers=4
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: immich-photos-pvc
namespace: immich
labels:
app: immich
spec:
storageClassName: nfs
volumeName: immich-photos-pv
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
@@ -2,7 +2,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: immich-server
namespace: photoprism
namespace: immich
labels:
app: immich-server
spec:
@@ -112,4 +112,4 @@ spec:
claimName: immich-library-pvc
- name: ext-library
persistentVolumeClaim:
claimName: photoprism-library-pvc
claimName: immich-photos-pvc
@@ -2,7 +2,7 @@ kind: Service
apiVersion: v1
metadata:
name: immich-server
namespace: photoprism
namespace: immich
labels:
app: immich-server
spec:
@@ -12,4 +12,5 @@ spec:
ports:
- port: 2283
targetPort: 2283
nodePort: 31139
protocol: TCP
@@ -0,0 +1,38 @@
apiVersion: batch/v1
kind: Job
metadata:
name: immich-db-nfs-to-longhorn
namespace: immich
spec:
backoffLimit: 2
template:
spec:
restartPolicy: Never
containers:
- name: migrate-db
image: alpine:3.20
command:
- sh
- -c
- |
set -e
apk add --no-cache rsync
test -d /source/postgres
mkdir -p /target/postgres
rsync -aHAX --numeric-ids /source/postgres/ /target/postgres/
test -f /target/postgres/PG_VERSION
test -d /target/postgres/base
volumeMounts:
- name: source-nfs
mountPath: /source
readOnly: true
- name: target-longhorn
mountPath: /target
volumes:
- name: source-nfs
nfs:
server: 192.168.178.166
path: /export/fastData/immichDB
- name: target-longhorn
persistentVolumeClaim:
claimName: immich-db-pvc
+4
View File
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: immich
+2 -2
View File
@@ -9,7 +9,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-server
namespace: photoprism
namespace: immich
labels:
app: redis-server
spec:
@@ -35,7 +35,7 @@ apiVersion: v1
kind: Service
metadata:
name: redis-server
namespace: photoprism
namespace: immich
labels:
app: redis-server
spec: