diff --git a/helm/litellm/templates/backend/deployment.yaml b/helm/litellm/templates/backend/deployment.yaml index 6370f581d71..3eb64e5528c 100644 --- a/helm/litellm/templates/backend/deployment.yaml +++ b/helm/litellm/templates/backend/deployment.yaml @@ -7,7 +7,7 @@ metadata: {{- include "litellm.commonLabels" . | nindent 4 }} app.kubernetes.io/component: backend spec: - {{- if not .Values.backend.hpa.enabled }} + {{- if and (not .Values.backend.hpa.enabled) (not (kindIs "invalid" .Values.backend.replicaCount)) }} replicas: {{ .Values.backend.replicaCount }} {{- end }} {{- with .Values.backend.strategy }} diff --git a/helm/litellm/templates/gateway/deployment.yaml b/helm/litellm/templates/gateway/deployment.yaml index 0c537b1bdeb..49b452b3053 100644 --- a/helm/litellm/templates/gateway/deployment.yaml +++ b/helm/litellm/templates/gateway/deployment.yaml @@ -7,7 +7,7 @@ metadata: {{- include "litellm.commonLabels" . | nindent 4 }} app.kubernetes.io/component: gateway spec: - {{- if not .Values.gateway.hpa.enabled }} + {{- if and (not .Values.gateway.hpa.enabled) (not (kindIs "invalid" .Values.gateway.replicaCount)) }} replicas: {{ .Values.gateway.replicaCount }} {{- end }} {{- with .Values.gateway.strategy }} diff --git a/helm/litellm/templates/ui/deployment.yaml b/helm/litellm/templates/ui/deployment.yaml index b794418b7e9..efee2d5fc34 100644 --- a/helm/litellm/templates/ui/deployment.yaml +++ b/helm/litellm/templates/ui/deployment.yaml @@ -7,7 +7,7 @@ metadata: {{- include "litellm.commonLabels" . | nindent 4 }} app.kubernetes.io/component: ui spec: - {{- if not .Values.ui.hpa.enabled }} + {{- if and (not .Values.ui.hpa.enabled) (not (kindIs "invalid" .Values.ui.replicaCount)) }} replicas: {{ .Values.ui.replicaCount }} {{- end }} {{- with .Values.ui.strategy }} diff --git a/helm/litellm/tests/replica_count_tests.yaml b/helm/litellm/tests/replica_count_tests.yaml index e6a28689ff5..791e47ff798 100644 --- a/helm/litellm/tests/replica_count_tests.yaml +++ b/helm/litellm/tests/replica_count_tests.yaml @@ -49,6 +49,22 @@ tests: path: spec.replicas value: 0 + - it: a component with HPA disabled but no replicaCount set keeps omitting spec.replicas, so upgrades do not reset a hand-scaled Deployment + set: + gateway.hpa.enabled: false + backend.hpa.enabled: false + ui.hpa.enabled: false + asserts: + - notExists: + path: spec.replicas + template: gateway/deployment.yaml + - notExists: + path: spec.replicas + template: backend/deployment.yaml + - notExists: + path: spec.replicas + template: ui/deployment.yaml + - it: every component omits spec.replicas when its HPA is enabled, so the autoscaler owns the count set: gateway.hpa.enabled: true diff --git a/helm/litellm/values.yaml b/helm/litellm/values.yaml index d7836b03a34..2c0c7151a32 100644 --- a/helm/litellm/values.yaml +++ b/helm/litellm/values.yaml @@ -397,10 +397,11 @@ gateway: # failureThreshold: 30 # periodSeconds: 10 startupProbe: {} - # Fixed pod count, rendered into the Deployment's spec.replicas only when - # hpa.enabled is false. With the HPA on, the autoscaler owns the count and - # this value is ignored. - replicaCount: 1 + # Optional fixed pod count, rendered into the Deployment's spec.replicas only + # when hpa.enabled is false. Unset by default so an existing Deployment keeps + # its current count; with the HPA on, the autoscaler owns the count, e.g.: + # replicaCount: 3 + replicaCount: hpa: enabled: true minReplicas: 1 @@ -529,7 +530,7 @@ backend: # Optional startupProbe; same shape as gateway.startupProbe. Empty by default. startupProbe: {} # Same semantics as gateway.replicaCount. - replicaCount: 1 + replicaCount: hpa: enabled: true minReplicas: 1 @@ -597,7 +598,7 @@ ui: # Optional startupProbe; same shape as gateway.startupProbe. Empty by default. startupProbe: {} # Same semantics as gateway.replicaCount. - replicaCount: 1 + replicaCount: hpa: enabled: false minReplicas: 1