Add Immich Machine Learning

This commit is contained in:
Daniel Cosme
2026-05-06 18:30:57 -04:00
parent 6ac72ad069
commit f2703951ce
6 changed files with 98 additions and 8 deletions
+3
View File
@@ -6,6 +6,9 @@ metadata:
resources: resources:
- immich-deployment.yaml - immich-deployment.yaml
- immich-srv.yaml - immich-srv.yaml
- machine-learning-pvc.yaml
- machine-learning-srv.yaml
- machine-learning.yaml
- namespace.yaml - namespace.yaml
- redis-deployment.yaml - redis-deployment.yaml
- redis-srv.yaml - redis-srv.yaml
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: immich-machine-learning-pvc
namespace: immich
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: longhorn
status: {}
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: immich-machine-learning
name: immich-machine-learning
namespace: immich
spec:
ports:
- port: 3003
targetPort: 0
selector:
app: immich-machine-learning
status:
loadBalancer: {}
+29
View File
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: immich-machine-learning
name: immich-machine-learning
namespace: immich
spec:
selector:
matchLabels:
app: immich-machine-learning
strategy: {}
template:
metadata:
labels:
app: immich-machine-learning
spec:
containers:
- image: ghcr.io/immich-app/immich-machine-learning:v2.7.5
name: immich-machine-learning
resources: {}
volumeMounts:
- mountPath: /cache
name: cache
volumes:
- name: cache
persistentVolumeClaim:
claimName: immich-machine-learning-pvc
status: {}
+37 -8
View File
@@ -29,6 +29,7 @@ var Secret = struct {
} }
const RedisPort = 6379 const RedisPort = 6379
const MachineLearningPort = 3003
var meta kube.Metadata var meta kube.Metadata
var Namespace = kube.Namespace(root.Immich.Name) var Namespace = kube.Namespace(root.Immich.Name)
@@ -36,6 +37,9 @@ var srv core.Service
var uploads_pvc core.PersistentVolumeClaim var uploads_pvc core.PersistentVolumeClaim
var redis_meta kube.Metadata var redis_meta kube.Metadata
var redis_srv core.Service var redis_srv core.Service
var machine_learning_meta kube.Metadata
var machine_learning_srv core.Service
var machine_learning_pvc core.PersistentVolumeClaim
func init() { func init() {
meta = kube.NewMetadata(root.Immich.Name, Namespace) meta = kube.NewMetadata(root.Immich.Name, Namespace)
@@ -46,30 +50,55 @@ func init() {
uploads_pvc = meta.PVC() uploads_pvc = meta.PVC()
uploads_pvc.Spec.StorageClassName = new(root.TrueNASSTorageClassNFS) uploads_pvc.Spec.StorageClassName = new(root.TrueNASSTorageClassNFS)
uploads_pvc.Spec.AccessModes = []core.PersistentVolumeAccessMode{core.ReadWriteMany} uploads_pvc.Spec.AccessModes = []core.PersistentVolumeAccessMode{core.ReadWriteMany}
req := kube.StorageRequest(resource.MustParse("200Gi"))
uploads_pvc.Spec.Resources = core.VolumeResourceRequirements{ uploads_pvc.Spec.Resources = core.VolumeResourceRequirements{
Requests: req, Requests: kube.StorageRequest(resource.MustParse("200Gi")),
} }
redis_meta = kube.NewMetadata("redis", Namespace) redis_meta = kube.NewMetadata("redis", Namespace)
redis_srv = redis_meta.Service(RedisPort) redis_srv = redis_meta.Service(RedisPort)
machine_learning_meta = kube.NewMetadata(root.Immich.Name+"-machine-learning", Namespace)
machine_learning_srv = machine_learning_meta.Service(MachineLearningPort)
machine_learning_pvc = machine_learning_meta.PVC()
machine_learning_pvc.Spec.StorageClassName = new(root.LONGHORN_STORAGE_CLASS)
} }
func Stack() stack.Stack { func Stack() stack.Stack {
kz := kube.NewKuztomizedStack( kz := kube.NewKuztomizedStack(
meta, meta,
map[string]any{ map[string]any{
"namespace": Namespace, "namespace": Namespace,
"uploads-pvc": uploads_pvc, "uploads-pvc": uploads_pvc,
"redis-srv": redis_srv, "redis-srv": redis_srv,
"redis-deployment": Redis(), "redis-deployment": Redis(),
"immich-deployment": Deployment(), "immich-deployment": Deployment(),
"immich-srv": srv, "immich-srv": srv,
"machine-learning-pvc": machine_learning_pvc,
"machine-learning-srv": machine_learning_srv,
"machine-learning": MachineLearning(),
}, },
) )
return kz.Stack("immich") return kz.Stack("immich")
} }
func MachineLearning() apps.Deployment {
cacheVol := kube.NewVolumeFrom(kube.VolumeSourcePVC, "cache", machine_learning_pvc.Name)
podSpec := core.PodSpec{
Containers: []core.Container{
{
Name: machine_learning_meta.Meta().Name,
Image: "ghcr.io/immich-app/immich-machine-learning:v2.7.5",
VolumeMounts: []core.VolumeMount{{
Name: cacheVol.Name,
MountPath: "/cache",
}},
},
},
Volumes: []core.Volume{cacheVol},
}
return kube.NewDeployment(machine_learning_meta, podSpec)
}
func Deployment() apps.Deployment { func Deployment() apps.Deployment {
uploadVol := kube.NewVolumeFrom(kube.VolumeSourcePVC, "upload", uploads_pvc.Name) uploadVol := kube.NewVolumeFrom(kube.VolumeSourcePVC, "upload", uploads_pvc.Name)
localtimeVol := core.Volume{ localtimeVol := core.Volume{
+1
View File
@@ -16,6 +16,7 @@ const (
const ( const (
KUBE_LOCAL_STORAGE_CLASS = "local-path" KUBE_LOCAL_STORAGE_CLASS = "local-path"
LONGHORN_STORAGE_CLASS = "longhorn"
) )
const ( const (