Skip to content

Commit

Permalink
immich: add product
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorisFeddema committed Jul 1, 2024
1 parent 527ea13 commit a10917b
Show file tree
Hide file tree
Showing 19 changed files with 494 additions and 5 deletions.
23 changes: 23 additions & 0 deletions charts/immich/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/immich/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: immich
version: 1.0.0

dependencies:
- name: redis
version: 19.6.0
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
16 changes: 16 additions & 0 deletions charts/immich/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Immich

## How to use

Add repository by running:

```bash
helm repo add k8s-at-our-home https://k8s-at-our-homes.github.io/helm-charts/
helm install immich k8s-at-our-home/immich
```

Or get the chart from ghcr.io:

```bash
helm install generic-device-plugin oci://ghcr.io/k8s-at-our-homes/helm-charts/immich
```
21 changes: 21 additions & 0 deletions charts/immich/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "common.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "common.fullname" -}}
{{- if contains .Chart.Name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "chartName" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "common.labels" -}}
app.kubernetes.io/version: {{ .Chart.Version | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "chartName" . }}
{{- end -}}
47 changes: 47 additions & 0 deletions charts/immich/templates/database/database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: postgresql.cnpg.io/v1
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: "immich"
{{- include "common.labels" . | nindent 4 }}
spec:
instances: {{ .Values.database.replicas }}
imageName: {{ .Values.database.image.registry }}/{{ .Values.database.image.repository }}:{{ .Values.database.image.tag }}

postgresql:
shared_preload_libraries:
- "vectors.so"

logLevel: {{ .Values.database.logLevel }}

bootstrap:
initdb:
postInitApplicationSQL:
- CREATE EXTENSION IF NOT EXISTS "vectors";
- CREATE EXTENSION IF NOT EXISTS "cube";
- CREATE EXTENSION IF NOT EXISTS "earthdistance";
- ALTER SYSTEM SET search_path TO app, public, vectors;
- ALTER SCHEMA vectors OWNER TO app;
# run this via kubectl exec in database pod after the schema is created
#- \c app; GRANT SELECT ON TABLE pg_vector_index_stat TO app;

storage:
size: {{ .Values.database.size }}

{{ if .Values.database.backups.enabled }}
backup:
retentionPolicy: {{ .Values.database.backups.retention }}
barmanObjectStore:
destinationPath: {{ .Values.database.backups.path | quote }}
endpointURL: {{ .Values.database.backups.endpoint }}
s3Credentials:
accessKeyId:
name: {{ .Values.database.backups.secretName }}
key: ACCESS_KEY
secretAccessKey:
name: {{ .Values.database.backups.secretName }}
key: SECRET_KEY
{{ end }}
17 changes: 17 additions & 0 deletions charts/immich/templates/database/pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.database.monitoring.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ template "common.fullname" . }}-data
labels:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich"
{{- include "common.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
"cnpg.io/cluster": {{ .Values.database.clusterName }}
podMetricsEndpoints:
- port: metrics
{{- end }}
33 changes: 33 additions & 0 deletions charts/immich/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
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"
{{- include "common.labels" . | nindent 4 }}
spec:
{{- if .Values.ingress.class}}
ingressClassName: {{ .Values.ingress.class }}
{{- end }}
rules:
- host: {{ .Values.ingress.domain }}
http:
paths:
- backend:
service:
name: {{ template "common.fullname" . }}
port:
number: 3001
path: /
pathType: Prefix
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.domain }}
secretName: {{ .Values.ingress.tls.secretName}}
{{- end }}
{{ end }}
63 changes: 63 additions & 0 deletions charts/immich/templates/machine-learning/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
kind: Deployment
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"
{{- 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-machine-learning"
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 }}
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
livenessProbe:
initialDelaySeconds: 0
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
httpGet:
port: http
path: /ping
readinessProbe:
initialDelaySeconds: 0
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
httpGet:
port: http
path: /ping
volumeMounts:
- name: cache
mountPath: /cache
ports:
- name: http
containerPort: 3003
protocol: TCP
resources: {{ toYaml .Values.machineLearning.resources | nindent 12 }}
volumes:
- name: cache
emptyDir: {}
20 changes: 20 additions & 0 deletions charts/immich/templates/machine-learning/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
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"
{{- include "common.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 3003
targetPort: 3003
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-machine-learning"
18 changes: 18 additions & 0 deletions charts/immich/templates/pvc-library.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
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"
{{- include "common.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- with .Values.persistence.storageClass }}
storageClassName: {{ . }}
{{- end }}
93 changes: 93 additions & 0 deletions charts/immich/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
kind: Deployment
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"
{{- 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"
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 }}
spec:
containers:
- name: server
image: "{{ .Values.server.image.registry }}/{{ .Values.server.image.repository }}:{{ .Values.server.image.tag }}"
imagePullPolicy: {{ .Values.server.image.pullPolicy }}
env:
- name: IMMICH_METRICS
value: "true"
- name: IMMICH_METRICS_PORT
value: "8081"
- name: IMMICH_PORT
value: "3001"
- name: DB_HOSTNAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.clusterName }}-app
key: host
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.clusterName }}-app
key: username
- name: DB_DATABASE_NAME
valueFrom:
secretKeyRef:
name: {{ .Values.database.clusterName }}-app
key: dbname
- name: REDIS_HOSTNAME
value: {{ .Release.Name }}-redis-master
- name: IMMICH_MACHINE_LEARNING_URL
value: http://{{ template "common.fullname" . }}-machine-learning:3003
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.clusterName }}-app
key: password
livenessProbe:
initialDelaySeconds: 0
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
httpGet:
port: http
path: /api/server-info/ping
readinessProbe:
initialDelaySeconds: 0
timeoutSeconds: 1
periodSeconds: 10
failureThreshold: 3
httpGet:
port: http
path: /api/server-info/ping
volumeMounts:
- name: library
mountPath: /usr/src/app/upload
ports:
- name: http
containerPort: 3001
protocol: TCP
- name: metrics
containerPort: 8081
protocol: TCP
resources: {{ toYaml .Values.server.resources | nindent 12 }}
volumes:
- name: library
persistentVolumeClaim:
claimName: {{ template "common.fullname" . }}-library
20 changes: 20 additions & 0 deletions charts/immich/templates/server/service-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
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"
{{- include "common.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 8081
targetPort: 8081
protocol: TCP
name: metrics
selector:
app.kubernetes.io/name: {{ template "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: "immich-server"
Loading

0 comments on commit a10917b

Please sign in to comment.