From 976d8b4dca00d7edb145f5cc3fc146aaada40577 Mon Sep 17 00:00:00 2001 From: Konstantin Renner Date: Thu, 14 May 2026 20:36:22 +0200 Subject: [PATCH] immich: HPA for machine-learning Bursty CPU profile (library scans, facial recognition, smart search queries) that idles between. Cache PVC is RWX, so multi-replica is safe. Cap at 2 to limit aggregate model RAM. Slow scale rates and long scaleDown stabilization (10m) avoid churning the model cache, which takes ~30s of cold-start to rebuild. Co-Authored-By: Claude Opus 4.7 (1M context) --- kubernetes/apps/immich/machine-learning.yaml | 33 ++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kubernetes/apps/immich/machine-learning.yaml b/kubernetes/apps/immich/machine-learning.yaml index bcfc9972..fcca0ae1 100644 --- a/kubernetes/apps/immich/machine-learning.yaml +++ b/kubernetes/apps/immich/machine-learning.yaml @@ -70,3 +70,36 @@ spec: ports: - port: 3003 targetPort: http +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: immich-machine-learning + namespace: immich +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: immich-machine-learning + minReplicas: 1 + maxReplicas: 2 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 70 + behavior: + scaleUp: + stabilizationWindowSeconds: 0 + policies: + - type: Pods + value: 1 + periodSeconds: 120 + scaleDown: + stabilizationWindowSeconds: 600 + policies: + - type: Pods + value: 1 + periodSeconds: 300