Immich: Add db-init job for database setup and update kustomization files

This commit is contained in:
2025-05-28 15:15:57 -07:00
parent 11fe563f18
commit 72cd0ecf56
5 changed files with 31 additions and 10 deletions

View File

@@ -1 +1,7 @@
# Immich App
## To Do
- We need a full uninstall script.
- We need full backup and restore scripts.
- When recreating the app (uninstall/reinstall), db-init needs to re-run (currently the previous one blocks).

View File

@@ -29,9 +29,24 @@ spec:
# Connect to the immich database and enable required extensions
PGPASSWORD=${POSTGRES_ADMIN_PASSWORD} psql -h ${DB_HOSTNAME} -U postgres -d ${DB_DATABASE_NAME} <<EOF
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS cube;
CREATE EXTENSION IF NOT EXISTS earthdistance;
DO \$\$
BEGIN
-- Create vector extension if it doesn't exist
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector') THEN
CREATE EXTENSION vector;
END IF;
-- Create cube extension if it doesn't exist
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'cube') THEN
CREATE EXTENSION cube;
END IF;
-- Create earthdistance extension if it doesn't exist (depends on cube)
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'earthdistance') THEN
CREATE EXTENSION earthdistance;
END IF;
END
\$\$;
EOF
env:
- name: POSTGRES_ADMIN_PASSWORD

View File

@@ -1,4 +0,0 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- db-init-job.yaml

View File

@@ -6,14 +6,14 @@ labels:
pairs:
app: immich
managedBy: kustomize
partOf: sovereign-cloud
partOf: wild-cloud
resources:
- deployment.yaml
- ingress.yaml
- namespace.yaml
- pvc.yaml
- service.yaml
- init/
- db-init-job.yaml
configMapGenerator:
- name: config
envs:

View File

@@ -13,6 +13,8 @@ spec:
selector:
app: immich
component: server
managedBy: kustomize
partOf: wild-cloud
---
apiVersion: v1
kind: Service
@@ -27,3 +29,5 @@ spec:
selector:
app: immich
component: machine-learning
managedBy: kustomize
partOf: wild-cloud