From 5796e0003fbe2642859baa792668b9017ea14ecc Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sat, 17 Dec 2022 13:16:28 +0200 Subject: [PATCH] chore(immich): cleanup immich (#5470) * chore(immich): cleanup immich * add another env * chmod again lol * start differenly * another migration * Update charts/stable/immich/templates/_proxy.tpl Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> * probes Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- charts/stable/immich/templates/_configmap.tpl | 117 ++---------------- .../immich/templates/_microservices.tpl | 61 +++++---- charts/stable/immich/templates/_ml.tpl | 61 +++++---- charts/stable/immich/templates/_proxy.tpl | 15 ++- charts/stable/immich/templates/_secret.tpl | 2 - charts/stable/immich/templates/_web.tpl | 3 +- charts/stable/immich/values.yaml | 25 +--- 7 files changed, 91 insertions(+), 193 deletions(-) diff --git a/charts/stable/immich/templates/_configmap.tpl b/charts/stable/immich/templates/_configmap.tpl index 4c831ecbff9..0bc42fede82 100644 --- a/charts/stable/immich/templates/_configmap.tpl +++ b/charts/stable/immich/templates/_configmap.tpl @@ -1,12 +1,10 @@ {{/* Define the configmap */}} {{- define "immich.config" -}} -{{- $serverConfigName := printf "%s-server-config" (include "tc.common.names.fullname" .) }} -{{- $commonConfigName := printf "%s-common-config" (include "tc.common.names.fullname" .) }} +{{- $serverConfigName := printf "%s-server-config" (include "tc.common.names.fullname" .) -}} +{{- $commonConfigName := printf "%s-common-config" (include "tc.common.names.fullname" .) -}} {{- $proxyConfigName := printf "%s-proxy-config" (include "tc.common.names.fullname" .) }} - --- - apiVersion: v1 kind: ConfigMap metadata: @@ -27,7 +25,6 @@ data: ENABLE_MAPBOX: {{ .Values.immich.mapbox_enable | quote }} --- - apiVersion: v1 kind: ConfigMap metadata: @@ -35,110 +32,20 @@ metadata: labels: {{- include "tc.common.labels" . | nindent 4 }} data: + IMMICH_WEB_URL: http://localhost:3000 + IMMICH_SERVER_URL: http://localhost:3001 + IMMICH_MACHINE_LEARNING_URL: http://localhost:3003 + {{/* + It's unclear where this URL is being used, but poking in their code, seems to be used internally? + It's set to the value of IMMICH_SERVER_URL on their compose. If something doesn't work remotely, + This is the place to start looking + https://github.com/immich-app/immich/blob/b5d75e20167b92de12cc50a816da214779cb0807/web/src/api/api.ts#L55 + */}} + PUBLIC_IMMICH_SERVER_URL: http://localhost:3001 NODE_ENV: production {{/* User Defined */}} {{- with .Values.immich.public_login_page_message }} PUBLIC_LOGIN_PAGE_MESSAGE: {{ . }} {{- end }} LOG_LEVEL: {{ .Values.immich.log_level }} ---- - -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ $proxyConfigName }} - labels: - {{- include "tc.common.labels" . | nindent 4 }} -data: - nginx.conf: | - worker_processes auto; - error_log /var/log/nginx/error.log; - pid /tmp/nginx.pid; - - # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. - include /usr/share/nginx/modules/*.conf; - - events { - worker_connections 1024; - } - - http { - map $http_upgrade $connection_upgrade { - default upgrade; - '' close; - } - - client_body_temp_path /tmp/client_temp; - proxy_temp_path /tmp/proxy_temp_path; - fastcgi_temp_path /tmp/fastcgi_temp; - uwsgi_temp_path /tmp/uwsgi_temp; - scgi_temp_path /tmp/scgi_temp; - - # events { - # worker_connections 1000; - # } - - server { - gzip on; - gzip_min_length 1000; - gunzip on; - - client_max_body_size 50000M; - - listen {{ .Values.service.main.ports.main.port }}; - access_log off; - - location /api { - # Compression - gzip_static on; - gzip_min_length 1000; - gzip_comp_level 2; - - proxy_buffering off; - proxy_buffer_size 16k; - proxy_busy_buffers_size 24k; - proxy_buffers 64 4k; - proxy_force_ranges on; - - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - - rewrite /api/(.*) /$1 break; - - # Server Container - proxy_pass http://immich-server:3001; - } - - location / { - # Compression - gzip_static on; - gzip_min_length 1000; - gzip_comp_level 2; - - proxy_buffering off; - proxy_buffer_size 16k; - proxy_busy_buffers_size 24k; - proxy_buffers 64 4k; - proxy_force_ranges on; - - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - - # Web Container - proxy_pass http://immich-web:3000; - } - } - } {{- end -}} diff --git a/charts/stable/immich/templates/_microservices.tpl b/charts/stable/immich/templates/_microservices.tpl index 1b24e9947b6..ee6c2282898 100644 --- a/charts/stable/immich/templates/_microservices.tpl +++ b/charts/stable/immich/templates/_microservices.tpl @@ -9,8 +9,7 @@ securityContext: runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }} command: - /bin/sh - - -c - - chmod +x ./start-microservices.sh && ./start-microservices.sh + - ./start-microservices.sh volumeMounts: - name: uploads mountPath: {{ .Values.persistence.uploads.mountPath }} @@ -21,29 +20,37 @@ envFrom: name: '{{ include "tc.common.names.fullname" . }}-common-config' - configMapRef: name: '{{ include "tc.common.names.fullname" . }}-server-config' -#TODO: Add probes, probably checking if process is running? -# readinessProbe: -# httpGet: -# path: / -# port: {{ .Values.service.main.ports.main.port }} -# initialDelaySeconds: {{ .Values.probes.readiness.spec.initialDelaySeconds }} -# timeoutSeconds: {{ .Values.probes.readiness.spec.timeoutSeconds }} -# periodSeconds: {{ .Values.probes.readiness.spec.periodSeconds }} -# failureThreshold: {{ .Values.probes.readiness.spec.failureThreshold }} -# livenessProbe: -# httpGet: -# path: / -# port: {{ .Values.service.main.ports.main.port }} -# initialDelaySeconds: {{ .Values.probes.liveness.spec.initialDelaySeconds }} -# timeoutSeconds: {{ .Values.probes.liveness.spec.timeoutSeconds }} -# periodSeconds: {{ .Values.probes.liveness.spec.periodSeconds }} -# failureThreshold: {{ .Values.probes.liveness.spec.failureThreshold }} -# startupProbe: -# httpGet: -# path: / -# port: {{ .Values.service.main.ports.main.port }} -# initialDelaySeconds: {{ .Values.probes.startup.spec.initialDelaySeconds }} -# timeoutSeconds: {{ .Values.probes.startup.spec.timeoutSeconds }} -# periodSeconds: {{ .Values.probes.startup.spec.periodSeconds }} -# failureThreshold: {{ .Values.probes.startup.spec.failureThreshold }} +readinessProbe: + exec: + command: + - /bin/sh + - -c + - | + ps -a | grep -v grep | grep -q microservices || exit 1 + initialDelaySeconds: {{ .Values.probes.readiness.spec.initialDelaySeconds }} + timeoutSeconds: {{ .Values.probes.readiness.spec.timeoutSeconds }} + periodSeconds: {{ .Values.probes.readiness.spec.periodSeconds }} + failureThreshold: {{ .Values.probes.readiness.spec.failureThreshold }} +livenessProbe: + exec: + command: + - /bin/sh + - -c + - | + ps -a | grep -v grep | grep -q microservices || exit 1 + initialDelaySeconds: {{ .Values.probes.liveness.spec.initialDelaySeconds }} + timeoutSeconds: {{ .Values.probes.liveness.spec.timeoutSeconds }} + periodSeconds: {{ .Values.probes.liveness.spec.periodSeconds }} + failureThreshold: {{ .Values.probes.liveness.spec.failureThreshold }} +startupProbe: + exec: + command: + - /bin/sh + - -c + - | + ps -a | grep -v grep | grep -q microservices || exit 1 + initialDelaySeconds: {{ .Values.probes.startup.spec.initialDelaySeconds }} + timeoutSeconds: {{ .Values.probes.startup.spec.timeoutSeconds }} + periodSeconds: {{ .Values.probes.startup.spec.periodSeconds }} + failureThreshold: {{ .Values.probes.startup.spec.failureThreshold }} {{- end -}} diff --git a/charts/stable/immich/templates/_ml.tpl b/charts/stable/immich/templates/_ml.tpl index b18416353a4..b3ed461c34d 100644 --- a/charts/stable/immich/templates/_ml.tpl +++ b/charts/stable/immich/templates/_ml.tpl @@ -13,8 +13,7 @@ securityContext: runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }} command: - /bin/sh - - -c - - chmod +x ./entrypoint.sh && ./entrypoint.sh + - ./entrypoint.sh volumeMounts: - name: uploads mountPath: {{ .Values.persistence.uploads.mountPath }} @@ -25,29 +24,37 @@ envFrom: name: '{{ include "tc.common.names.fullname" . }}-server-config' - secretRef: name: '{{ include "tc.common.names.fullname" . }}-immich-secret' -#TODO: Add probes, probably checking if process is running? -# readinessProbe: -# httpGet: -# path: / -# port: {{ .Values.service.main.ports.main.port }} -# initialDelaySeconds: {{ .Values.probes.readiness.spec.initialDelaySeconds }} -# timeoutSeconds: {{ .Values.probes.readiness.spec.timeoutSeconds }} -# periodSeconds: {{ .Values.probes.readiness.spec.periodSeconds }} -# failureThreshold: {{ .Values.probes.readiness.spec.failureThreshold }} -# livenessProbe: -# httpGet: -# path: / -# port: {{ .Values.service.main.ports.main.port }} -# initialDelaySeconds: {{ .Values.probes.liveness.spec.initialDelaySeconds }} -# timeoutSeconds: {{ .Values.probes.liveness.spec.timeoutSeconds }} -# periodSeconds: {{ .Values.probes.liveness.spec.periodSeconds }} -# failureThreshold: {{ .Values.probes.liveness.spec.failureThreshold }} -# startupProbe: -# httpGet: -# path: / -# port: {{ .Values.service.main.ports.main.port }} -# initialDelaySeconds: {{ .Values.probes.startup.spec.initialDelaySeconds }} -# timeoutSeconds: {{ .Values.probes.startup.spec.timeoutSeconds }} -# periodSeconds: {{ .Values.probes.startup.spec.periodSeconds }} -# failureThreshold: {{ .Values.probes.startup.spec.failureThreshold }} +readinessProbe: + exec: + command: + - /bin/sh + - -c + - | + grep -q entrypoint /proc/1/cmdline || exit 1 + initialDelaySeconds: {{ .Values.probes.readiness.spec.initialDelaySeconds }} + timeoutSeconds: {{ .Values.probes.readiness.spec.timeoutSeconds }} + periodSeconds: {{ .Values.probes.readiness.spec.periodSeconds }} + failureThreshold: {{ .Values.probes.readiness.spec.failureThreshold }} +livenessProbe: + exec: + command: + - /bin/sh + - -c + - | + grep -q entrypoint /proc/1/cmdline || exit 1 + initialDelaySeconds: {{ .Values.probes.liveness.spec.initialDelaySeconds }} + timeoutSeconds: {{ .Values.probes.liveness.spec.timeoutSeconds }} + periodSeconds: {{ .Values.probes.liveness.spec.periodSeconds }} + failureThreshold: {{ .Values.probes.liveness.spec.failureThreshold }} +startupProbe: + exec: + command: + - /bin/sh + - -c + - | + grep -q entrypoint /proc/1/cmdline || exit 1 + initialDelaySeconds: {{ .Values.probes.startup.spec.initialDelaySeconds }} + timeoutSeconds: {{ .Values.probes.startup.spec.timeoutSeconds }} + periodSeconds: {{ .Values.probes.startup.spec.periodSeconds }} + failureThreshold: {{ .Values.probes.startup.spec.failureThreshold }} {{- end -}} diff --git a/charts/stable/immich/templates/_proxy.tpl b/charts/stable/immich/templates/_proxy.tpl index 5bda1f49690..103939741dd 100644 --- a/charts/stable/immich/templates/_proxy.tpl +++ b/charts/stable/immich/templates/_proxy.tpl @@ -3,6 +3,9 @@ {{- if hasKey .Values "imageProxy" -}} {{/* For smooth upgrade, Remove later */}} {{- $img := .Values.imageProxy -}} {{- $_ := set .Values "proxyImage" (dict "repository" $img.repository "tag" $img.tag "pullPolicy" $img.pullPolicy) -}} + {{- end -}} + {{- if not .Values.service.main.ports.main.targetPort -}} {{/* For smooth upgrade, Remove later */}} + {{- $_ := set .Values.service.main.ports.main "targetPort" 8080 -}} {{- end }} image: {{ .Values.proxyImage.repository }}:{{ .Values.proxyImage.tag }} imagePullPolicy: {{ .Values.proxyImage.pullPolicy }} @@ -14,17 +17,13 @@ securityContext: envFrom: - configMapRef: name: '{{ include "tc.common.names.fullname" . }}-common-config' -volumeMounts: - - name: proxy-conf - mountPath: /etc/nginx - readOnly: true ports: - - containerPort: {{ .Values.service.main.ports.main.port }} + - containerPort: {{ .Values.service.main.ports.main.targetPort }} name: main readinessProbe: httpGet: path: /api/server-info/ping - port: {{ .Values.service.main.ports.main.port }} + port: {{ .Values.service.main.ports.main.targetPort }} initialDelaySeconds: {{ .Values.probes.readiness.spec.initialDelaySeconds }} timeoutSeconds: {{ .Values.probes.readiness.spec.timeoutSeconds }} periodSeconds: {{ .Values.probes.readiness.spec.periodSeconds }} @@ -32,7 +31,7 @@ readinessProbe: livenessProbe: httpGet: path: /api/server-info/ping - port: {{ .Values.service.main.ports.main.port }} + port: {{ .Values.service.main.ports.main.targetPort }} initialDelaySeconds: {{ .Values.probes.liveness.spec.initialDelaySeconds }} timeoutSeconds: {{ .Values.probes.liveness.spec.timeoutSeconds }} periodSeconds: {{ .Values.probes.liveness.spec.periodSeconds }} @@ -40,7 +39,7 @@ livenessProbe: startupProbe: httpGet: path: /api/server-info/ping - port: {{ .Values.service.main.ports.main.port }} + port: {{ .Values.service.main.ports.main.targetPort }} initialDelaySeconds: {{ .Values.probes.startup.spec.initialDelaySeconds }} timeoutSeconds: {{ .Values.probes.startup.spec.timeoutSeconds }} periodSeconds: {{ .Values.probes.startup.spec.periodSeconds }} diff --git a/charts/stable/immich/templates/_secret.tpl b/charts/stable/immich/templates/_secret.tpl index 0e5752d22af..93e3cbfbdef 100644 --- a/charts/stable/immich/templates/_secret.tpl +++ b/charts/stable/immich/templates/_secret.tpl @@ -2,9 +2,7 @@ {{- define "immich.secret" -}} {{- $secretName := printf "%s-immich-secret" (include "tc.common.names.fullname" .) }} - --- - apiVersion: v1 kind: Secret type: Opaque diff --git a/charts/stable/immich/templates/_web.tpl b/charts/stable/immich/templates/_web.tpl index ca421761f73..9c0107ead21 100644 --- a/charts/stable/immich/templates/_web.tpl +++ b/charts/stable/immich/templates/_web.tpl @@ -13,8 +13,7 @@ securityContext: runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }} command: - /bin/sh - - -c - - chmod +x ./entrypoint.sh && ./entrypoint.sh + - ./entrypoint.sh envFrom: - configMapRef: name: '{{ include "tc.common.names.fullname" . }}-common-config' diff --git a/charts/stable/immich/values.yaml b/charts/stable/immich/values.yaml index 19df8e676ba..818c19c1f2a 100644 --- a/charts/stable/immich/values.yaml +++ b/charts/stable/immich/values.yaml @@ -15,13 +15,12 @@ webImage: proxyImage: repository: tccr.io/truecharts/immich-proxy - tag: 1.29.5_44@sha256:a4c24a70cc1e1bbbdecc3df371af08528430846709ef22ca16e2a923aa8da509 + tag: 1.38.2_60@sha256:c788886ce9510541e4031b664d5d3cafbaf14e3bea25792484e1485704dd7231 pullPolicy: IfNotPresent command: - /bin/sh - - -c - - chmod +x ./start-server.sh && ./start-server.sh + - ./start-server.sh securityContext: readOnlyRootFilesystem: false @@ -63,36 +62,18 @@ probes: type: HTTP port: 3001 -# Due to https://github.com/immich-app/immich/issues/726 -hostAliases: - - ip: 127.0.0.1 - hostnames: - - immich-web - - immich-server - - immich-machine-learning - service: main: ports: main: port: 10323 protocol: HTTP + targetPort: 8080 persistence: uploads: enabled: true mountPath: /usr/src/app/upload - proxy-conf: - enabled: true - noMount: true - type: custom - mountPath: /etc/nginx/ - volumeSpec: - configMap: - name: '{{ include "tc.common.names.fullname" . }}-proxy-config' - items: - - key: nginx.conf - path: nginx.conf postgresql: enabled: true