diff --git a/apps/hydra/immich/kustomization.yaml b/apps/hydra/immich/kustomization.yaml index 1e58bd9..f965132 100644 --- a/apps/hydra/immich/kustomization.yaml +++ b/apps/hydra/immich/kustomization.yaml @@ -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 diff --git a/apps/hydra/immich/machine-learning-pvc.yaml b/apps/hydra/immich/machine-learning-pvc.yaml new file mode 100644 index 0000000..eb77133 --- /dev/null +++ b/apps/hydra/immich/machine-learning-pvc.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: {} diff --git a/apps/hydra/immich/machine-learning-srv.yaml b/apps/hydra/immich/machine-learning-srv.yaml new file mode 100644 index 0000000..9ae41bf --- /dev/null +++ b/apps/hydra/immich/machine-learning-srv.yaml @@ -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: {} diff --git a/apps/hydra/immich/machine-learning.yaml b/apps/hydra/immich/machine-learning.yaml new file mode 100644 index 0000000..2f78aa8 --- /dev/null +++ b/apps/hydra/immich/machine-learning.yaml @@ -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: {} diff --git a/pkg/immich/immich.go b/pkg/immich/immich.go index d60cb89..8fa458d 100644 --- a/pkg/immich/immich.go +++ b/pkg/immich/immich.go @@ -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,30 +50,55 @@ 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 { kz := kube.NewKuztomizedStack( meta, map[string]any{ - "namespace": Namespace, - "uploads-pvc": uploads_pvc, - "redis-srv": redis_srv, - "redis-deployment": Redis(), - "immich-deployment": Deployment(), - "immich-srv": srv, + "namespace": Namespace, + "uploads-pvc": uploads_pvc, + "redis-srv": redis_srv, + "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{ diff --git a/pkg/root/root.go b/pkg/root/root.go index d037b12..696f59a 100644 --- a/pkg/root/root.go +++ b/pkg/root/root.go @@ -16,6 +16,7 @@ const ( const ( KUBE_LOCAL_STORAGE_CLASS = "local-path" + LONGHORN_STORAGE_CLASS = "longhorn" ) const (