From 2491d486944509e815dd22778497f1a31c9ad2d6 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sat, 25 Oct 2025 21:39:26 +0300 Subject: [PATCH] feat(immich): **BREAKING** Migrating to VectorChord and remove templating **CHECK MIGRATION DOCS** (#41016) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [x] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] 🔃 Refactor of current code - [x] 📜 Documentation Changes **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [x] 📄 I have made changes to the documentation - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [x] ⬆️ I increased versions for any altered app according to semantic versioning - [x] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or `fix(docs):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Signed-off-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com> Co-authored-by: Boemeltrein Co-authored-by: Boemeltrein <130394941+Boemeltrein@users.noreply.github.com> Co-authored-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com> Co-authored-by: Kjeld Schouten --- charts/stable/immich/Chart.yaml | 7 +- .../ci/machinelearning_false-values.yaml | 2 + .../ci/machinelearning_true-values.yaml | 2 + .../immich/docs/Migrate to VectorChord.md | 285 ++++++++++++++++++ charts/stable/immich/templates/_config.tpl | 53 ---- .../immich/templates/_machinelearning.tpl | 43 --- .../immich/templates/_microservices.tpl | 39 --- charts/stable/immich/templates/_server.tpl | 30 -- charts/stable/immich/templates/_wait.tpl | 18 -- charts/stable/immich/templates/common.yaml | 45 +-- charts/stable/immich/values.yaml | 174 ++++++++++- 11 files changed, 457 insertions(+), 241 deletions(-) create mode 100644 charts/stable/immich/ci/machinelearning_false-values.yaml create mode 100644 charts/stable/immich/ci/machinelearning_true-values.yaml create mode 100644 charts/stable/immich/docs/Migrate to VectorChord.md delete mode 100644 charts/stable/immich/templates/_config.tpl delete mode 100644 charts/stable/immich/templates/_machinelearning.tpl delete mode 100644 charts/stable/immich/templates/_microservices.tpl delete mode 100644 charts/stable/immich/templates/_server.tpl delete mode 100644 charts/stable/immich/templates/_wait.tpl diff --git a/charts/stable/immich/Chart.yaml b/charts/stable/immich/Chart.yaml index 160952ddc7d..01e114c4eb9 100644 --- a/charts/stable/immich/Chart.yaml +++ b/charts/stable/immich/Chart.yaml @@ -2,8 +2,6 @@ annotations: artifacthub.io/links: |- - name: support url: https://discord.com/invite/tVsPTHWTtr - max_scale_version: 24.04.1 - min_scale_version: 24.04.0 truecharts.org/category: media truecharts.org/max_helm_version: "3.17" truecharts.org/max_kubernetes_version: 1.32.0 @@ -33,7 +31,7 @@ home: https://truecharts.org/charts/stable/immich icon: https://truecharts.org/img/hotlink-ok/chart-icons/immich.webp keywords: - photos -kubeVersion: '>=1.24.0-0' +kubeVersion: ">=1.24.0-0" maintainers: - name: TrueCharts email: info@truecharts.org @@ -46,5 +44,4 @@ sources: - https://github.com/truecharts/charts/tree/master/charts/stable/immich - https://github.com/trueforge-org/truecharts/tree/master/charts/stable/immich type: application -version: 24.13.2 - +version: 25.0.0 diff --git a/charts/stable/immich/ci/machinelearning_false-values.yaml b/charts/stable/immich/ci/machinelearning_false-values.yaml new file mode 100644 index 00000000000..5e68dabe30a --- /dev/null +++ b/charts/stable/immich/ci/machinelearning_false-values.yaml @@ -0,0 +1,2 @@ +immich: + enable_ml: false diff --git a/charts/stable/immich/ci/machinelearning_true-values.yaml b/charts/stable/immich/ci/machinelearning_true-values.yaml new file mode 100644 index 00000000000..111cb12fc60 --- /dev/null +++ b/charts/stable/immich/ci/machinelearning_true-values.yaml @@ -0,0 +1,2 @@ +immich: + enable_ml: true diff --git a/charts/stable/immich/docs/Migrate to VectorChord.md b/charts/stable/immich/docs/Migrate to VectorChord.md new file mode 100644 index 00000000000..fb4b7619ac2 --- /dev/null +++ b/charts/stable/immich/docs/Migrate to VectorChord.md @@ -0,0 +1,285 @@ +--- +title: Migrate DB from pgvecto.rs to VectorChord +--- + +:::caution + +- This guide is not covered by support. However you can make a thread on Discord if you have any questions. +- Following this guide is at your own risk and any data loss is not the responsibility of TrueCharts and or their team. +- Make backups of your existing database before continue. + +::: + +Since chart version 25 the PostgreSQL extension is changed from pgvecto.rs to VectorChord. Therefore before upgrading to chart version 25, you need to migrate your database. + +## Prerequisite + +In this guide we are using the shell of the CNPG pods. How to exec in a pod, is something we assume you're familiar with. +Also you need to be familiar with running 'kubectl' commands. +We assume Immich is in the namespace `Immich`, when different adapt accordingly. + +## Change database user rights + +Typically Immich expects superuser permission in the database. This is needed for this upgrade, but also practical for future. With this permission automated database dumps can also be used inside Immich itself. Also with a new version of VectorChord reindex the database will be automaticly. + +- Exec into pod `immich-cnpg-main-1` +- run: `psql immich` +- run: `ALTER USER immich WITH SUPERUSER;` + +When all went OK it looks like this: + +```bash +postgres@immich-cnpg-main-1:/$ psql immich +psql (16.3 (Debian 16.3-1.pgdg110+1)) +Type "help" for help. + +immich=# ALTER USER immich WITH SUPERUSER; +ALTER ROLE +immich=# +``` + + +## Only running CNPG pods are allowed + +:::danger + +From this moment on, it is not allowed to have any Immich pods spin up during the entire migration process. If this happen for whatever reason, your Database is broken and can only be restored from a backup. And you need to start over with this tutorial. + +Only the CNPG pods needs to be available. + +When driftDetection is set to "enabled", make sure this is removed. + +::: + +:::caution + +Reminder: Make sure backups are available. + +::: + +1. Scale all deployments down to "0" + +- Add to your .Values + +```yaml + workload: + main: + replicas: 0 +``` +- Check if immich deployment is 0/0 with `kubectl get deployments -n immich` +- run: `kubectl scale --replicas=0 deployment/immich-machinelearning -n immich` +- run: `kubectl scale --replicas=0 deployment/immich-microservices -n immich` + +2. Check if all deployments are now scaled down and only cnpg and redis pods are their. + +- run: `kubectl get deployments,pods -n immich` + +```bash +kubectl get deployments,pods -n immich +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/immich 0/0 0 0 34m +deployment.apps/immich-machinelearning 0/0 0 0 34m +deployment.apps/immich-microservices 0/0 0 0 34m + +NAME READY STATUS RESTARTS AGE +pod/immich-cnpg-main-1 1/1 Running 0 28m +pod/immich-cnpg-main-2 1/1 Running 0 27m +pod/immich-redis-0 1/1 Running 0 3m39s +``` + +## Migration Step 1, while pgvecto.rs is installed. + +- Exec into pod "immich-cnpg-main-1" +- run: `psql immich` +- run: + +```bash +SELECT atttypmod as dimsize + FROM pg_attribute f + JOIN pg_class c ON c.oid = f.attrelid + WHERE c.relkind = 'r'::char + AND f.attnum > 0 + AND c.relname = 'smart_search'::text + AND f.attname = 'embedding'::text; +``` + +- **Write down** the dimsize NUMBER, given as output + +- run: +```bash +DROP INDEX IF EXISTS clip_index; +DROP INDEX IF EXISTS face_index; +ALTER TABLE smart_search ALTER COLUMN embedding SET DATA TYPE real[]; +ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE real[]; +``` + +When all went OK it looks like this (NUMBER can be different): + +```bash +postgres@immich-cnpg-main-1:/$ psql immich +psql (16.3 (Debian 16.3-1.pgdg110+1)) +Type "help" for help. + +immich=# SELECT atttypmod as dimsize + FROM pg_attribute f + JOIN pg_class c ON c.oid = f.attrelid + WHERE c.relkind = 'r'::char + AND f.attnum > 0 + AND c.relname = 'smart_search'::text + AND f.attname = 'embedding'::text; + dimsize +--------- + 512 +(1 row) + +immich=# DROP INDEX IF EXISTS clip_index; +DROP INDEX IF EXISTS face_index; +ALTER TABLE smart_search ALTER COLUMN embedding SET DATA TYPE real[]; +ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE real[]; +DROP INDEX +DROP INDEX +ALTER TABLE +ALTER TABLE +immich=# +``` + +## Migration Step 2, change deployment to VectorChord + +- Add to your .Values +```yaml + cnpg: + main: + type: vectorchord +``` +Check: +- run: `kubectl get deployments,pods -n immich` + +After deployment, most likely `immich-cnpg-main-2` is upgraded and `immich-cnpg-main-1` in a CrashLoopBackOff state, when that is the case: +- run: `kubectl delete pod immich-cnpg-main-1 -n immich` + +Make sure the machinelearning and microservices will be scaled down again: +- run: `kubectl scale --replicas=0 deployment/immich-machinelearning -n immich` +- run: `kubectl scale --replicas=0 deployment/immich-microservices -n immich` + +Check if all is in the desired state: +- run: `kubectl get deployments,pods -n immich` + +```bash +kubectl get deployments,pods -n immich +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/immich 0/0 0 0 58m +deployment.apps/immich-machinelearning 0/0 0 0 58m +deployment.apps/immich-microservices 0/0 0 0 58m + +NAME READY STATUS RESTARTS AGE +pod/immich-cnpg-main-1 1/1 Running 0 2m57s +pod/immich-cnpg-main-2 1/1 Running 0 7m26s +pod/immich-redis-0 1/1 Running 0 7m27s +``` + +Check if image vectorchord is used: +- run: `kubectl get pods -n immich -o yaml| grep "image:"` +```bash +kubectl get pods -n immich -o yaml| grep "image:" + image: ghcr.io/tensorchord/cloudnative-vectorchord:16.10-0.5.3 + image: ghcr.io/cloudnative-pg/cloudnative-pg:1.27.1 + image: ghcr.io/tensorchord/cloudnative-vectorchord:16.10-0.5.3 + image: ghcr.io/cloudnative-pg/cloudnative-pg:1.27.1 + image: ghcr.io/tensorchord/cloudnative-vectorchord:16.10-0.5.3 + image: ghcr.io/cloudnative-pg/cloudnative-pg:1.27.1 + image: ghcr.io/tensorchord/cloudnative-vectorchord:16.10-0.5.3 + image: ghcr.io/cloudnative-pg/cloudnative-pg:1.27.1 + image: docker.io/bitnamisecure/redis:latest@sha256:142ab4d0c251bcf5466fffd33766350af718a6725cb926710be19fad00b2b035 + image: sha256:63a40000acab0440264e4176e2345571beb8f1097e0355f8d216768bdf4be7f0 +``` + +## Migration Step 3, while VectorChord is installed. + +- Exec into pod "immich-cnpg-main-2" (most lickely main-1 is now a read-only, so therefore we use main-2) +- run: `psql immich` +- run, with **Replacing with the number from step 1**: +```bash +CREATE EXTENSION IF NOT EXISTS vchord CASCADE; +ALTER TABLE smart_search ALTER COLUMN embedding SET DATA TYPE vector(); +ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE vector(512); +``` + +When all is OK it looks like this: + +```bash +postgres@immich-cnpg-main-2:/$ psql immich +psql (16.10 (Debian 16.10-1.pgdg12+1)) +Type "help" for help. + +immich=# CREATE EXTENSION IF NOT EXISTS vchord CASCADE; +ALTER TABLE smart_search ALTER COLUMN embedding SET DATA TYPE vector(512); +ALTER TABLE face_search ALTER COLUMN embedding SET DATA TYPE vector(512); +NOTICE: installing required extension "vector" +CREATE EXTENSION +ALTER TABLE +ALTER TABLE +immich=# +``` + +If you get this as output: +```bash +ERROR: cannot execute CREATE EXTENSION in a read-only transaction +ERROR: cannot execute ALTER TABLE in a read-only transaction +ERROR: cannot execute ALTER TABLE in a read-only transaction +``` +Exec into the other CNPG pod and try again. + +## Testing + +- Remove: +```yaml + workload: + main: + replicas: 0 +``` + +- Now let it all deploy, all pods will be go up include machinelearning and microservices + +- Check the logs: Immich will now create new indices using VectorChord, will looks like this: + +```json +Postgres notice: { + severity_local: 'INFO', + severity: 'INFO', + code: '00000', + message: 'maintain: number_of_formerly_allocated_pages = 0', + file: 'algo.rs', + line: '100', + routine: 'vchord::index::vchordrq::algo::maintain' +} +``` + +- When the logs indicate: + +``` +[Nest] 22 - 10/23/2025, 9:09:26 PM LOG [Api:NestApplication] Nest application successfully started +[Nest] 22 - 10/23/2025, 9:09:26 PM LOG [Api:Bootstrap] Immich Server is listening on http://[::1]:10323 [v2.1.0] [production] +[Nest] 22 - 10/23/2025, 9:10:26 PM LOG [Api:MachineLearningRepository] Machine learning server became healthy (http://immich-machinelearning:10003). +``` + +- All went OK + +## Change chart version + +- Change your `chart version` to `25.0.0` +- Remove: +```yaml + cnpg: + main: + type: vectorchord +``` + +- You are ready to use Immich again! Have fun! + +## References + +The origin material for this guide is available on the [Immich site](https://docs.immich.app/administration/postgres-standalone#migrating-to-vectorchord) -> Migration steps (manual). + +## Support + +If you have any issues with following this guide, we can be reached using [Discord](https://discord.gg/tVsPTHWTtr) for real-time feedback and support. diff --git a/charts/stable/immich/templates/_config.tpl b/charts/stable/immich/templates/_config.tpl deleted file mode 100644 index b1a4e2f6bfd..00000000000 --- a/charts/stable/immich/templates/_config.tpl +++ /dev/null @@ -1,53 +0,0 @@ -{{- define "immich.config" -}} - {{- $fname := (include "tc.v1.common.lib.chart.names.fullname" .) -}} - -configmap: - server-config: - enabled: true - data: - IMMICH_PORT: {{ .Values.service.main.ports.main.port | quote }} - IMMICH_WORKERS_INCLUDE: api - - micro-config: - enabled: true - data: - IMMICH_PORT: {{ .Values.service.microservices.ports.microservices.port | quote }} - REVERSE_GEOCODING_DUMP_DIRECTORY: {{ .Values.persistence.microcache.targetSelector.microservices.microservices.mountPath }} - IMMICH_WORKERS_EXCLUDE: api - - {{- if .Values.immich.enable_ml }} - ml-config: - enabled: true - data: - NODE_ENV: production - IMMICH_PORT: {{ .Values.service.machinelearning.ports.machinelearning.port | quote }} - MACHINE_LEARNING_CACHE_FOLDER: {{ .Values.persistence.mlcache.targetSelector.machinelearning.machinelearning.mountPath }} - TRANSFORMERS_CACHE: {{ .Values.persistence.mlcache.targetSelector.machinelearning.machinelearning.mountPath }} - {{- end }} - - {{/* Server and Microservices */}} - common-config: - enabled: true - data: - NODE_ENV: production - IMMICH_LOG_LEVEL: {{ .Values.immich.log_level }} - IMMICH_MACHINE_LEARNING_ENABLED: {{ .Values.immich.enable_ml | quote }} - {{- if .Values.immich.enable_ml }} - IMMICH_MACHINE_LEARNING_URL: {{ printf "http://%v-machinelearning:%v" $fname .Values.service.machinelearning.ports.machinelearning.port }} - {{- end }} - -secret: - {{/* Server and Microservices */}} - deps-secret: - enabled: true - data: - DB_USERNAME: {{ .Values.cnpg.main.user }} - DB_DATABASE_NAME: {{ .Values.cnpg.main.database }} - DB_HOSTNAME: {{ .Values.cnpg.main.creds.host }} - DB_PASSWORD: {{ .Values.cnpg.main.creds.password }} - DB_PORT: "5432" - REDIS_HOSTNAME: {{ .Values.redis.creds.plainhost }} - REDIS_PASSWORD: {{ .Values.redis.creds.redisPassword }} - REDIS_PORT: "6379" - REDIS_DBINDEX: "0" -{{- end -}} diff --git a/charts/stable/immich/templates/_machinelearning.tpl b/charts/stable/immich/templates/_machinelearning.tpl deleted file mode 100644 index 875c2a6f1f6..00000000000 --- a/charts/stable/immich/templates/_machinelearning.tpl +++ /dev/null @@ -1,43 +0,0 @@ -{{/* Define the machinelearning container */}} -{{- define "immich.machinelearning" -}} -{{- $fname := (include "tc.v1.common.lib.chart.names.fullname" .) -}} -{{- $serverUrl := printf "http://%v:%v/api/server/ping" $fname .Values.service.main.ports.main.port }} -{{- $img := "mlImage" -}} -{{- with .Values.immich.mlImageType -}} - {{- $img = . -}} -{{- end }} -enabled: true -type: Deployment -podSpec: - initContainers: - wait-server: - {{/* Wait for server */}} - {{- include "immich.wait" (dict "url" $serverUrl) | nindent 6 }} - containers: - machinelearning: - enabled: true - primary: true - imageSelector: {{ $img }} - securityContext: - capabilities: - disableS6Caps: true - envFrom: - - configMapRef: - name: ml-config - probes: - readiness: - enabled: true - type: http - path: /ping - port: {{ .Values.service.machinelearning.ports.machinelearning.port }} - liveness: - enabled: true - type: http - path: /ping - port: {{ .Values.service.machinelearning.ports.machinelearning.port }} - startup: - enabled: true - type: http - path: /ping - port: {{ .Values.service.machinelearning.ports.machinelearning.port }} -{{- end -}} diff --git a/charts/stable/immich/templates/_microservices.tpl b/charts/stable/immich/templates/_microservices.tpl deleted file mode 100644 index 4d955b39aa7..00000000000 --- a/charts/stable/immich/templates/_microservices.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{{- define "immich.microservices" -}} -{{- $fname := (include "tc.v1.common.lib.chart.names.fullname" .) -}} -{{- $serverUrl := printf "http://%v:%v/api/server/ping" $fname .Values.service.main.ports.main.port }} -enabled: true -type: Deployment -podSpec: - initContainers: - wait-server: - {{/* Wait for server */}} - {{- include "immich.wait" (dict "url" $serverUrl) | nindent 6 }} - containers: - microservices: - enabled: true - primary: true - imageSelector: image - securityContext: - capabilities: - disableS6Caps: true - envFrom: - - secretRef: - name: deps-secret - - configMapRef: - name: common-config - - configMapRef: - name: micro-config - probes: - readiness: - enabled: true - type: exec - command: /usr/src/app/server/bin/immich-healthcheck - liveness: - enabled: true - type: exec - command: /usr/src/app/server/bin/immich-healthcheck - startup: - enabled: true - type: exec - command: /usr/src/app/server/bin/immich-healthcheck -{{- end -}} diff --git a/charts/stable/immich/templates/_server.tpl b/charts/stable/immich/templates/_server.tpl deleted file mode 100644 index b3b9c54c2fc..00000000000 --- a/charts/stable/immich/templates/_server.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{{- define "immich.server" -}} -enabled: true -primary: true -imageSelector: image -resources: - excludeExtra: true -securityContext: - capabilities: - disableS6Caps: true -envFrom: - - configMapRef: - name: server-config - - configMapRef: - name: common-config - - secretRef: - name: deps-secret -probes: - liveness: - enabled: true - type: exec - command: /usr/src/app/server/bin/immich-healthcheck - readiness: - enabled: true - type: exec - command: /usr/src/app/server/bin/immich-healthcheck - startup: - enabled: true - type: exec - command: /usr/src/app/server/bin/immich-healthcheck -{{- end -}} diff --git a/charts/stable/immich/templates/_wait.tpl b/charts/stable/immich/templates/_wait.tpl deleted file mode 100644 index 4704bed3d3f..00000000000 --- a/charts/stable/immich/templates/_wait.tpl +++ /dev/null @@ -1,18 +0,0 @@ -{{- define "immich.wait" -}} -{{- $url := .url }} -enabled: true -type: init -imageSelector: alpineImage -resources: - excludeExtra: true -command: - - /bin/ash - - -c - - | - echo "Pinging [{{ $url }}] until it is ready..." - until wget --spider --quiet --timeout=3 --tries 1 "{{ $url }}"; do - echo "Waiting for [{{ $url }}] to be ready..." - sleep 2 - done - echo "URL [{{ $url }}] is ready!" -{{- end -}} diff --git a/charts/stable/immich/templates/common.yaml b/charts/stable/immich/templates/common.yaml index 54a7c6c98ba..9d95f161711 100644 --- a/charts/stable/immich/templates/common.yaml +++ b/charts/stable/immich/templates/common.yaml @@ -1,44 +1 @@ -{{/* Make sure all variables are set properly */}} -{{- include "tc.v1.common.loader.init" . }} - -{{- $fname := (include "tc.v1.common.lib.chart.names.fullname" .) -}} - -{{- $main := .Values.workload.main.podSpec.containers.main -}} -{{- $main = mustMergeOverwrite $main (include "immich.server" . | fromYaml) -}} -{{- $_ := set .Values.workload.main.podSpec.containers "main" $main -}} - -{{/* Render Microservices Workload */}} -{{- $_ := set .Values.workload "microservices" (include "immich.microservices" . | fromYaml) -}} - -{{- if .Values.immich.enable_ml -}} - {{/* Enable Machine Learning Service */}} - {{- $_ := set .Values.service.machinelearning "enabled" true -}} - {{/* Render Machine Learning Workload */}} - {{- $_ := set .Values.workload "machinelearning" (include "immich.machinelearning" . | fromYaml) -}} -{{- else -}} - {{/* Disable Machine Learning Service */}} - {{- $_ := set .Values.service.machinelearning "enabled" false -}} -{{- end -}} - -{{/* Render configuration for immich - after services, as it has references -*/}} -{{- $config := include "immich.config" . | fromYaml -}} -{{- if $config -}} - {{- $_ := mustMergeOverwrite .Values $config -}} -{{- end -}} - -{{- range $idx, $persistence := .Values.persistenceList -}} - {{- $_ := set $persistence "targetSelector" (dict - "main" (dict "main" dict) - "microservices" (dict "microservices" dict) - ) -}} -{{- end -}} - -{{- $envList := .Values.workload.main.podSpec.containers.main.envList -}} -{{- if $envList -}} - {{- $_ := set .Values.workload.microservices.podSpec.containers.microservices "envList" $envList -}} -{{- end -}} - -{{/* Render the templates */}} -{{ include "tc.v1.common.loader.apply" . }} +{{ include "tc.v1.common.loader.all" . }} diff --git a/charts/stable/immich/values.yaml b/charts/stable/immich/values.yaml index d45b3e92ae0..2311f493a05 100644 --- a/charts/stable/immich/values.yaml +++ b/charts/stable/immich/values.yaml @@ -33,8 +33,159 @@ securityContext: immich: enable_ml: true mlImageType: mlImage - log_level: log +workload: + main: + podSpec: + containers: + main: + imageSelector: image + resources: + excludeExtra: true + securityContext: + capabilities: + disableS6Caps: true + env: + IMMICH_MACHINE_LEARNING_ENABLED: "{{ .Values.immich.enable_ml }}" + IMMICH_MACHINE_LEARNING_URL: >- + {{- if .Values.immich.enable_ml -}} + {{- printf "http://%s-machinelearning:%v" (include "tc.v1.common.lib.chart.names.fullname" .) .Values.service.machinelearning.ports.machinelearning.port -}} + {{- else -}} + false + {{- end -}} + IMMICH_PORT: "{{ .Values.service.main.ports.main.port }}" + IMMICH_WORKERS_INCLUDE: api + NODE_ENV: production + DB_USERNAME: "{{ .Values.cnpg.main.user }}" + DB_DATABASE_NAME: "{{ .Values.cnpg.main.database }}" + DB_HOSTNAME: "{{ .Values.cnpg.main.creds.host }}" + DB_PASSWORD: "{{ .Values.cnpg.main.creds.password }}" + DB_PORT: "5432" + REDIS_HOSTNAME: '{{ .Values.redis.creds.plainhost | trimAll "\"" }}' + REDIS_PASSWORD: '{{ .Values.redis.creds.redisPassword | trimAll "\"" }}' + REDIS_PORT: "6379" + REDIS_DBINDEX: "0" + probes: + readiness: + enabled: true + type: http + path: /api/server/ping + port: "{{ .Values.service.main.ports.main.port }}" + liveness: + enabled: true + type: http + path: /api/server/ping + port: "{{ .Values.service.main.ports.main.port }}" + startup: + enabled: true + type: http + path: /api/server/ping + port: "{{ .Values.service.main.ports.main.port }}" + machinelearning: + enabled: "{{ .Values.immich.enable_ml }}" + type: Deployment + podSpec: + initContainers: + wait-server: + enabled: true + type: init + imageSelector: alpineImage + resources: + excludeExtra: true + command: + - /bin/ash + - -c + - | + {{- tpl .Values.waitServerScript $ -}} + containers: + machinelearning: + enabled: true + primary: true + imageSelector: "{{ .Values.immich.mlImageType }}" + resources: + excludeExtra: true + securityContext: + capabilities: + disableS6Caps: true + env: + NODE_ENV: production + IMMICH_PORT: "{{ .Values.service.machinelearning.ports.machinelearning.port }}" + MACHINE_LEARNING_CACHE_FOLDER: "{{ .Values.persistence.mlcache.targetSelector.machinelearning.machinelearning.mountPath }}" + TRANSFORMERS_CACHE: "{{ .Values.persistence.mlcache.targetSelector.machinelearning.machinelearning.mountPath }}" + probes: + readiness: + enabled: true + type: http + path: /ping + port: "{{ .Values.service.machinelearning.ports.machinelearning.port }}" + liveness: + enabled: true + type: http + path: /ping + port: "{{ .Values.service.machinelearning.ports.machinelearning.port }}" + startup: + enabled: true + type: http + path: /ping + port: "{{ .Values.service.machinelearning.ports.machinelearning.port }}" + microservices: + enabled: true + type: Deployment + podSpec: + initContainers: + wait-server: + enabled: true + type: init + imageSelector: alpineImage + resources: + excludeExtra: true + command: + - /bin/ash + - -c + - |- + {{ tpl .Values.waitServerScript $ | trim }} + containers: + microservices: + enabled: true + primary: true + imageSelector: image + securityContext: + capabilities: + disableS6Caps: true + env: + IMMICH_MACHINE_LEARNING_ENABLED: "{{ .Values.immich.enable_ml }}" + IMMICH_MACHINE_LEARNING_URL: >- + {{- if .Values.immich.enable_ml -}} + {{- printf "http://%s-machinelearning:%v" (include "tc.v1.common.lib.chart.names.fullname" .) .Values.service.machinelearning.ports.machinelearning.port -}} + {{- else -}} + false + {{- end -}} + NODE_ENV: production + IMMICH_PORT: "{{ .Values.service.microservices.ports.microservices.port }}" + REVERSE_GEOCODING_DUMP_DIRECTORY: "{{ .Values.persistence.microcache.targetSelector.microservices.microservices.mountPath }}" + IMMICH_WORKERS_EXCLUDE: api + DB_USERNAME: "{{ .Values.cnpg.main.user }}" + DB_DATABASE_NAME: "{{ .Values.cnpg.main.database }}" + DB_HOSTNAME: "{{ .Values.cnpg.main.creds.host }}" + DB_PASSWORD: "{{ .Values.cnpg.main.creds.password }}" + DB_PORT: "5432" + REDIS_HOSTNAME: '{{ .Values.redis.creds.plainhost | trimAll "\"" }}' + REDIS_PASSWORD: '{{ .Values.redis.creds.redisPassword | trimAll "\"" }}' + REDIS_PORT: "6379" + REDIS_DBINDEX: "0" + probes: + readiness: + enabled: true + type: exec + command: immich-healthcheck + liveness: + enabled: true + type: exec + command: immich-healthcheck + startup: + enabled: true + type: exec + command: immich-healthcheck service: main: # Main service targets the server @@ -56,7 +207,7 @@ service: protocol: http targetSelector: microservices machinelearning: - enabled: true + enabled: "{{ .Values.immich.enable_ml }}" type: ClusterIP targetSelector: machinelearning ports: @@ -69,7 +220,7 @@ service: persistence: mlcache: - enabled: true + enabled: "{{ .Values.immich.enable_ml }}" type: emptyDir targetSelector: machinelearning: @@ -142,17 +293,13 @@ cnpg: enabled: true user: immich database: immich - type: vectors + type: vectorchord cluster: initdb: postInitApplicationSQL: + - ALTER USER immich WITH SUPERUSER; - CREATE EXTENSION IF NOT EXISTS cube; - CREATE EXTENSION IF NOT EXISTS earthdistance; - - CREATE SCHEMA IF NOT EXISTS vectors; - - ALTER DATABASE immich SET search_path TO "immich", public, vectors; - - SET search_path TO "immich", public, vectors; - - GRANT SELECT ON TABLE pg_vector_index_stat TO PUBLIC; - - ALTER SCHEMA vectors OWNER TO immich; redis: enabled: true @@ -164,3 +311,12 @@ ingress: homepage: widget: version: 2 + +waitServerScript: | + {{- $url := printf "http://%v:%v/api/server/ping" (include "tc.v1.common.lib.chart.names.fullname" .) .Values.service.main.ports.main.port -}} + echo "Pinging [{{ $url }}] until it is ready..." + until wget --spider --quiet --timeout=3 --tries 1 "{{ $url }}"; do + echo "Waiting for [{{ $url }}] to be ready..." + sleep 2 + done + echo "URL [{{ $url }}] is ready!"