From 34403dcf87245daaa29337b789a69dc2a98c7bbb Mon Sep 17 00:00:00 2001 From: Fabrizio Cafolla Date: Fri, 15 May 2026 12:36:24 +0200 Subject: [PATCH] feat(chart): add support for autoscaling behavior in HPA (#27990) Squash-merged by litellm-agent from FabrizioCafolla's PR. --- deploy/charts/litellm-helm/templates/hpa.yaml | 4 +++ .../charts/litellm-helm/tests/hpa_tests.yaml | 36 +++++++++++++++++++ deploy/charts/litellm-helm/values.yaml | 1 + 3 files changed, 41 insertions(+) create mode 100644 deploy/charts/litellm-helm/tests/hpa_tests.yaml diff --git a/deploy/charts/litellm-helm/templates/hpa.yaml b/deploy/charts/litellm-helm/templates/hpa.yaml index 71e199c5aeb..fec4d1f5c5e 100644 --- a/deploy/charts/litellm-helm/templates/hpa.yaml +++ b/deploy/charts/litellm-helm/templates/hpa.yaml @@ -12,6 +12,10 @@ spec: name: {{ include "litellm.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} + {{- if .Values.autoscaling.behavior }} + behavior: + {{- toYaml .Values.autoscaling.behavior | nindent 4 }} + {{- end }} metrics: {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource diff --git a/deploy/charts/litellm-helm/tests/hpa_tests.yaml b/deploy/charts/litellm-helm/tests/hpa_tests.yaml new file mode 100644 index 00000000000..ec18c3591d3 --- /dev/null +++ b/deploy/charts/litellm-helm/tests/hpa_tests.yaml @@ -0,0 +1,36 @@ +suite: "hpa with behavior" +templates: + - hpa.yaml +tests: + - it: "renders behavior when set" + set: + autoscaling.enabled: true + autoscaling.behavior: + scaleUp: + stabilizationWindowSeconds: 60 + policies: + - type: Pods + value: 2 + periodSeconds: 60 + scaleDown: + stabilizationWindowSeconds: 90 + policies: + - type: Pods + value: 1 + periodSeconds: 60 + asserts: + - isKind: { of: HorizontalPodAutoscaler } + - equal: { path: spec.behavior.scaleUp.stabilizationWindowSeconds, value: 60 } + - equal: { path: spec.behavior.scaleDown.stabilizationWindowSeconds, value: 90 } + +--- +suite: "hpa without behavior" +templates: + - hpa.yaml +tests: + - it: "does not render behavior when not set" + set: + autoscaling.enabled: true + asserts: + - isKind: { of: HorizontalPodAutoscaler } + - isNull: { path: spec.behavior } diff --git a/deploy/charts/litellm-helm/values.yaml b/deploy/charts/litellm-helm/values.yaml index 9c7c013341b..81558ed5b29 100644 --- a/deploy/charts/litellm-helm/values.yaml +++ b/deploy/charts/litellm-helm/values.yaml @@ -184,6 +184,7 @@ autoscaling: maxReplicas: 100 targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 + # behavior: {} # Autoscaling with keda is mutually exclusive with hpa keda: