Skip to content

Commit

Permalink
immich: Add timezone, model preloading environment variables (#136)
Browse files Browse the repository at this point in the history
* immich: Add timezone, model preloading environment variables

* Rename ports due to max length

* breaking change because of pod selector change

* Re-add IMMICH_PORT env variable

* env vars as strings

* fix machine learning replica count

* Add example for model preloading
  • Loading branch information
rouke-broersma authored Dec 13, 2024
1 parent 020caf8 commit b92e8f7
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 90 deletions.
2 changes: 1 addition & 1 deletion charts/immich/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: immich
version: 2.13.0
version: 3.0.0

home: https://immich.app
sources:
Expand Down
13 changes: 12 additions & 1 deletion charts/immich/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "common.labels" -}}
{{- define "common.selectorLabels" -}}
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/part-of: "immich"
{{- end -}}

{{- define "common.labels" -}}
app.kubernetes.io/name: {{ template "common.name" . }}
helm.sh/chart: {{ include "chartName" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Values.server.image.tag | quote }}
app.kubernetes.io/part-of: "immich"
{{- end -}}
4 changes: 0 additions & 4 deletions charts/immich/templates/database/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ kind: Cluster
metadata:
name: {{ .Values.database.clusterName }}
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "db"
{{- include "common.labels" . | nindent 4 }}
spec:
Expand Down Expand Up @@ -54,8 +52,6 @@ spec:
whenUnsatisfiable: {{ .whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ template "common.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/component: "db"
{{- include "common.labels" $ | nindent 8 }}
{{- end }}
Expand Down
2 changes: 0 additions & 2 deletions charts/immich/templates/database/pod-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ kind: PodMonitor
metadata:
name: {{ .Values.database.clusterName }}-monitor
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "db"
{{- include "common.labels" . | nindent 4 }}
spec:
Expand Down
41 changes: 24 additions & 17 deletions charts/immich/templates/machine-learning/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,45 @@ apiVersion: apps/v1
metadata:
name: {{ template "common.fullname" . }}-machine-learning
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-machine-learning"
app.kubernetes.io/component: "machine-learning"
{{- include "common.labels" . | nindent 4 }}
spec:
revisionHistoryLimit: 0
replicas: {{ .Values.server.replicas }}
strategy:
type: Recreate
replicas: {{ .Values.machineLearning.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-machine-learning"
app.kubernetes.io/component: "machine-learning"
{{- include "common.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-machine-learning"
{{- include "common.labels" . | nindent 8 }}
app.kubernetes.io/component: "machine-learning"
{{- include "common.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: server
image: "{{ .Values.machineLearning.image.registry }}/{{ .Values.machineLearning.image.repository }}:{{ .Values.machineLearning.image.tag }}"
imagePullPolicy: {{ .Values.machineLearning.image.pullPolicy }}
env:
- name: IMMICH_PORT
value: "3003"
- name: TRANSFORMERS_CACHE
value: /cache
value: '3003'
- name: TZ
value: {{ .Values.timezone }}
{{- with .Values.machineLearning.modelPreload.objectRecognition }}
# Keeps image recognition and search model in memory for faster response times
- name: MACHINE_LEARNING_PRELOAD__CLIP
value: {{ . }}
{{- end }}
{{- with .Values.machineLearning.modelPreload.faceRecognition }}
# Keeps face recognition model in memory for faster response times
- name: MACHINE_LEARNING_PRELOAD__FACIAL_RECOGNITION
value: {{ . }}
{{- end }}
{{ if .Values.machineLearning.replicas | int | gt 1 }}
# If multiple replicas, disable http keepalive for proper loadbalancing
- name: MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S
value: 0
{{- end }}
livenessProbe:
httpGet:
port: http
Expand All @@ -48,7 +56,6 @@ spec:
ports:
- name: http
containerPort: 3003
protocol: TCP
resources: {{ toYaml .Values.machineLearning.resources | nindent 12 }}
volumes:
- name: cache
Expand Down
16 changes: 6 additions & 10 deletions charts/immich/templates/machine-learning/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ kind: Service
metadata:
name: {{ template "common.fullname" . }}-machine-learning
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-machine-learning"
app.kubernetes.io/component: "machine-learning"
{{- include "common.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 3003
targetPort: 3003
protocol: TCP
name: http
- name: http
port: 3003
targetPort: http
selector:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-machine-learning"
app.kubernetes.io/component: "machine-learning"
{{- include "common.selectorLabels" . | nindent 4 }}
4 changes: 1 addition & 3 deletions charts/immich/templates/pvc-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ kind: PersistentVolumeClaim
metadata:
name: {{ template "common.fullname" . }}-library
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich"
app.kubernetes.io/component: "library"
{{- include "common.labels" . | nindent 4 }}
spec:
accessModes:
Expand Down
35 changes: 14 additions & 21 deletions charts/immich/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,33 @@ apiVersion: apps/v1
metadata:
name: {{ template "common.fullname" . }}-server
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.labels" . | nindent 4 }}
spec:
revisionHistoryLimit: 0
replicas: {{ .Values.server.replicas }}
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
{{- include "common.labels" . | nindent 8 }}
app.kubernetes.io/component: "server"
{{- include "common.selectorLabels" . | nindent 8 }}
spec:
securityContext: {{ toYaml .Values.server.podSecurityContext | nindent 8 }}
containers:
- name: server
image: "{{ .Values.server.image.registry }}/{{ .Values.server.image.repository }}:{{ .Values.server.image.tag }}"
imagePullPolicy: {{ .Values.server.image.pullPolicy }}
env:
- name: IMMICH_TELEMETRY_INCLUDE
value: "all"
- name: IMMICH_METRICS_PORT
value: "8081"
- name: IMMICH_PORT
value: "3001"
value: '2283'
- name: TZ
value: {{ .Values.timezone }}
- name: IMMICH_TELEMETRY_INCLUDE
value: all
- name: DB_HOSTNAME
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -80,11 +73,11 @@ spec:
mountPath: /usr/src/app/upload
ports:
- name: http
containerPort: 3001
protocol: TCP
- name: metrics
containerPort: 2283
- name: server-metrics
containerPort: 8081
protocol: TCP
- name: jobs-metrics
containerPort: 8082
resources: {{ toYaml .Values.server.resources | nindent 12 }}
volumes:
- name: library
Expand Down
6 changes: 2 additions & 4 deletions charts/immich/templates/server/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ metadata:
name: {{ template "common.fullname" . }}
annotations: {{ toYaml .Values.ingress.annotations | nindent 4 }}
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.labels" . | nindent 4 }}
spec:
{{- if .Values.ingress.class}}
Expand All @@ -21,7 +19,7 @@ spec:
service:
name: {{ template "common.fullname" . }}
port:
number: 3001
name: http
path: /
pathType: Prefix
{{- if .Values.ingress.tls.enabled }}
Expand Down
19 changes: 9 additions & 10 deletions charts/immich/templates/server/service-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ kind: Service
metadata:
name: {{ template "common.fullname" . }}-server-metrics
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 8081
targetPort: 8081
protocol: TCP
name: metrics
- name: server-metrics
port: 8081
targetPort: server-metrics
- name: jobs-metrics
port: 8082
targetPort: jobs-metrics
selector:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.selectorLabels" . | nindent 6 }}
13 changes: 6 additions & 7 deletions charts/immich/templates/server/service-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ kind: ServiceMonitor
metadata:
name: {{ template "common.fullname" . }}-server
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
- port: server-metrics
scheme: http
- port: jobs-metrics
scheme: http
16 changes: 6 additions & 10 deletions charts/immich/templates/server/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ kind: Service
metadata:
name: {{ template "common.fullname" . }}
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich"
app.kubernetes.io/component: "server"
{{- include "common.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 3001
targetPort: 3001
protocol: TCP
name: http
- name: http
port: 2283
targetPort: http
selector:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
app.kubernetes.io/component: "server"
{{- include "common.selectorLabels" . | nindent 4 }}
6 changes: 6 additions & 0 deletions charts/immich/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
timezone: Europe/Amsterdam

persistence:
size: 200Gi
storageClass: ''
Expand Down Expand Up @@ -47,6 +49,10 @@ machineLearning:
repository: immich-app/immich-machine-learning
tag: v1.122.2
pullPolicy: IfNotPresent

modelPreload:
objectRecognition: # 'immich-app/ViT-L-16-SigLIP-384__webli'
faceRecognition: # 'immich-app/buffalo_l'

# resources:
# requests:
Expand Down

0 comments on commit b92e8f7

Please sign in to comment.