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

View File

@@ -6,6 +6,9 @@ metadata:
resources:
- immich-deployment.yaml
- immich-srv.yaml
- machine-learning-pvc.yaml
- machine-learning-srv.yaml
- machine-learning.yaml
- namespace.yaml
- redis-deployment.yaml
- redis-srv.yaml

View File

@@ -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: {}

View File

@@ -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: {}

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: {}

View File

@@ -29,6 +29,7 @@ var Secret = struct {
}
const RedisPort = 6379
const MachineLearningPort = 3003
var meta kube.Metadata
var Namespace = kube.Namespace(root.Immich.Name)
@@ -36,6 +37,9 @@ var srv core.Service
var uploads_pvc core.PersistentVolumeClaim
var redis_meta kube.Metadata
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() {
meta = kube.NewMetadata(root.Immich.Name, Namespace)
@@ -46,13 +50,17 @@ func init() {
uploads_pvc = meta.PVC()
uploads_pvc.Spec.StorageClassName = new(root.TrueNASSTorageClassNFS)
uploads_pvc.Spec.AccessModes = []core.PersistentVolumeAccessMode{core.ReadWriteMany}
req := kube.StorageRequest(resource.MustParse("200Gi"))
uploads_pvc.Spec.Resources = core.VolumeResourceRequirements{
Requests: req,
Requests: kube.StorageRequest(resource.MustParse("200Gi")),
}
redis_meta = kube.NewMetadata("redis", Namespace)
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 {
@@ -65,11 +73,32 @@ func Stack() stack.Stack {
"redis-deployment": Redis(),
"immich-deployment": Deployment(),
"immich-srv": srv,
"machine-learning-pvc": machine_learning_pvc,
"machine-learning-srv": machine_learning_srv,
"machine-learning": MachineLearning(),
},
)
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 {
uploadVol := kube.NewVolumeFrom(kube.VolumeSourcePVC, "upload", uploads_pvc.Name)
localtimeVol := core.Volume{

View File

@@ -16,6 +16,7 @@ const (
const (
KUBE_LOCAL_STORAGE_CLASS = "local-path"
LONGHORN_STORAGE_CLASS = "longhorn"
)
const (