The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
feat(helm): add per-component PodDisruptionBudget and topologySpreadConstraints to componentized chart (#33430)
Yassin Kortam45fb9a70b9f7
diff --git a/helm/litellm/templates/NOTES.txt b/helm/litellm/templates/NOTES.txtindex 5b939fe480a..468cf621b32 100644--- a/helm/litellm/templates/NOTES.txt+++ b/helm/litellm/templates/NOTES.txt@@ -46,4 +46,9 @@ Reminders:- gateway.config.proxy_config (rendered into a ConfigMap and mounted at/app/config/config.yaml; gateway reads it viaCONFIG_FILE_PATH)+ - {component}.pdb.{enabled,minAvailable,maxUnavailable} (per-component PodDisruptionBudget; disabled by+ default — with hpa.minReplicas of 1, minAvailable: 1+ would block node drains)+ - {component}.topologySpreadConstraints (standard k8s list, e.g. spread replicas across+ topology.kubernetes.io/zone)- Enable ingress.enabled=true to dispatch / → ui, gateway data-plane prefixes → gateway, and the catch-all → backend.diff --git a/helm/litellm/templates/_helpers.tpl b/helm/litellm/templates/_helpers.tplindex 043a0afc173..a0205c0a3a2 100644--- a/helm/litellm/templates/_helpers.tpl+++ b/helm/litellm/templates/_helpers.tpl@@ -295,6 +295,52 @@ harmless no-op for the Job and authoritative for the app pods.{{- end }}{{- end -}}+{{/*+PodDisruptionBudget shared by gateway, backend, and ui.++Invoke with a dict:+ (dict "root" $ "component" .Values.gateway "componentName" "gateway"+ "fullname" (include "litellm.gateway.fullname" .)+ "selectorLabels" (include "litellm.gateway.selectorLabels" .))++Renders nothing unless both the component and its `pdb.enabled` are on.+Only one of minAvailable / maxUnavailable should be set; if both are,+minAvailable wins. If neither is set, falls back to `maxUnavailable: 1` so+an enabled-but-unconfigured PDB still permits node drains.++"Set" means non-nil and non-empty-string, so an explicit 0 (e.g.+`maxUnavailable: 0` to forbid all voluntary disruptions) is honored rather+than silently replaced by the fallback.+*/}}+{{- define "litellm.pdb" -}}+{{- $root := .root -}}+{{- $component := .component -}}+{{- $min := $component.pdb.minAvailable -}}+{{- $max := $component.pdb.maxUnavailable -}}+{{- $minSet := not (or (kindIs "invalid" $min) (eq (printf "%v" $min) "")) -}}+{{- $maxSet := not (or (kindIs "invalid" $max) (eq (printf "%v" $max) "")) -}}+{{- if and $component.enabled $component.pdb $component.pdb.enabled }}+apiVersion: policy/v1+kind: PodDisruptionBudget+metadata:+ name: {{ .fullname }}+ labels:+ {{- include "litellm.commonLabels" $root | nindent 4 }}+ app.kubernetes.io/component: {{ .componentName }}+spec:+ selector:+ matchLabels:+ {{- .selectorLabels | nindent 6 }}+ {{- if $minSet }}+ minAvailable: {{ $min }}+ {{- else if $maxSet }}+ maxUnavailable: {{ $max }}+ {{- else }}+ maxUnavailable: 1+ {{- end }}+{{- end }}+{{- end -}}+{{/*Renders `envFrom:` block for a component's `envConfigMaps` / `envSecrets`lists. Each entry is a resource name; the chart wires the whole ConfigMap /diff --git a/helm/litellm/templates/backend/deployment.yaml b/helm/litellm/templates/backend/deployment.yamlindex 9d056167fe1..892b84ff7d5 100644--- a/helm/litellm/templates/backend/deployment.yaml+++ b/helm/litellm/templates/backend/deployment.yaml@@ -98,4 +98,8 @@ spec:tolerations:{{- toYaml . | nindent 8 }}{{- end }}+ {{- with .Values.backend.topologySpreadConstraints }}+ topologySpreadConstraints:+ {{- toYaml . | nindent 8 }}+ {{- end }}{{- end }}diff --git a/helm/litellm/templates/backend/poddisruptionbudget.yaml b/helm/litellm/templates/backend/poddisruptionbudget.yamlnew file mode 100644index 00000000000..02853ac879c--- /dev/null+++ b/helm/litellm/templates/backend/poddisruptionbudget.yaml@@ -0,0 +1,6 @@+{{- include "litellm.pdb" (dict+ "root" $+ "component" .Values.backend+ "componentName" "backend"+ "fullname" (include "litellm.backend.fullname" .)+ "selectorLabels" (include "litellm.backend.selectorLabels" .)) }}diff --git a/helm/litellm/templates/gateway/deployment.yaml b/helm/litellm/templates/gateway/deployment.yamlindex 4c80d784156..b2e22612905 100644--- a/helm/litellm/templates/gateway/deployment.yaml+++ b/helm/litellm/templates/gateway/deployment.yaml@@ -100,4 +100,8 @@ spec:tolerations:{{- toYaml . | nindent 8 }}{{- end }}+ {{- with .Values.gateway.topologySpreadConstraints }}+ topologySpreadConstraints:+ {{- toYaml . | nindent 8 }}+ {{- end }}{{- end }}diff --git a/helm/litellm/templates/gateway/poddisruptionbudget.yaml b/helm/litellm/templates/gateway/poddisruptionbudget.yamlnew file mode 100644index 00000000000..15e89af17d7--- /dev/null+++ b/helm/litellm/templates/gateway/poddisruptionbudget.yaml@@ -0,0 +1,6 @@+{{- include "litellm.pdb" (dict+ "root" $+ "component" .Values.gateway+ "componentName" "gateway"+ "fullname" (include "litellm.gateway.fullname" .)+ "selectorLabels" (include "litellm.gateway.selectorLabels" .)) }}diff --git a/helm/litellm/templates/ui/deployment.yaml b/helm/litellm/templates/ui/deployment.yamlindex 79e9a3e43bb..cd1f8c08fd4 100644--- a/helm/litellm/templates/ui/deployment.yaml+++ b/helm/litellm/templates/ui/deployment.yaml@@ -76,4 +76,8 @@ spec:tolerations:{{- toYaml . | nindent 8 }}{{- end }}+ {{- with .Values.ui.topologySpreadConstraints }}+ topologySpreadConstraints:+ {{- toYaml . | nindent 8 }}+ {{- end }}{{- end }}diff --git a/helm/litellm/templates/ui/poddisruptionbudget.yaml b/helm/litellm/templates/ui/poddisruptionbudget.yamlnew file mode 100644index 00000000000..f7a3a694e9c--- /dev/null+++ b/helm/litellm/templates/ui/poddisruptionbudget.yaml@@ -0,0 +1,6 @@+{{- include "litellm.pdb" (dict+ "root" $+ "component" .Values.ui+ "componentName" "ui"+ "fullname" (include "litellm.ui.fullname" .)+ "selectorLabels" (include "litellm.ui.selectorLabels" .)) }}diff --git a/helm/litellm/tests/pdb_topology_spread_tests.yaml b/helm/litellm/tests/pdb_topology_spread_tests.yamlnew file mode 100644index 00000000000..8aa05f3a969--- /dev/null+++ b/helm/litellm/tests/pdb_topology_spread_tests.yaml@@ -0,0 +1,188 @@+suite: test pod disruption budgets and topology spread constraints+templates:+ - gateway/poddisruptionbudget.yaml+ - backend/poddisruptionbudget.yaml+ - ui/poddisruptionbudget.yaml+ - gateway/deployment.yaml+ - gateway/configmap.yaml+ - backend/deployment.yaml+ - ui/deployment.yaml+values:+ - ./values/required.yaml+tests:+ - it: renders no PDB by default+ templates:+ - gateway/poddisruptionbudget.yaml+ - backend/poddisruptionbudget.yaml+ - ui/poddisruptionbudget.yaml+ asserts:+ - hasDocuments:+ count: 0++ - it: gateway PDB uses minAvailable and matches the gateway selector labels+ template: gateway/poddisruptionbudget.yaml+ set:+ gateway.pdb.enabled: true+ gateway.pdb.minAvailable: 1+ asserts:+ - isKind:+ of: PodDisruptionBudget+ - equal:+ path: apiVersion+ value: policy/v1+ - equal:+ path: metadata.name+ value: RELEASE-NAME-litellm-gateway+ - equal:+ path: spec.minAvailable+ value: 1+ - notExists:+ path: spec.maxUnavailable+ - equal:+ path: spec.selector.matchLabels+ value:+ app.kubernetes.io/name: litellm+ app.kubernetes.io/instance: RELEASE-NAME+ app.kubernetes.io/component: gateway++ - it: backend PDB uses maxUnavailable when minAvailable is unset+ template: backend/poddisruptionbudget.yaml+ set:+ backend.pdb.enabled: true+ backend.pdb.maxUnavailable: 25%+ asserts:+ - equal:+ path: spec.maxUnavailable+ value: 25%+ - notExists:+ path: spec.minAvailable+ - equal:+ path: spec.selector.matchLabels+ value:+ app.kubernetes.io/name: litellm+ app.kubernetes.io/instance: RELEASE-NAME+ app.kubernetes.io/component: backend++ - it: minAvailable wins when both minAvailable and maxUnavailable are set+ template: gateway/poddisruptionbudget.yaml+ set:+ gateway.pdb.enabled: true+ gateway.pdb.minAvailable: 2+ gateway.pdb.maxUnavailable: 1+ asserts:+ - equal:+ path: spec.minAvailable+ value: 2+ - notExists:+ path: spec.maxUnavailable++ - it: an explicit maxUnavailable 0 is honored instead of the fallback+ template: backend/poddisruptionbudget.yaml+ set:+ backend.pdb.enabled: true+ backend.pdb.maxUnavailable: 0+ asserts:+ - equal:+ path: spec.maxUnavailable+ value: 0+ - notExists:+ path: spec.minAvailable++ - it: an explicit minAvailable 0 is honored and beats a set maxUnavailable+ template: gateway/poddisruptionbudget.yaml+ set:+ gateway.pdb.enabled: true+ gateway.pdb.minAvailable: 0+ gateway.pdb.maxUnavailable: 1+ asserts:+ - equal:+ path: spec.minAvailable+ value: 0+ - notExists:+ path: spec.maxUnavailable++ - it: enabled PDB with neither knob set falls back to maxUnavailable 1+ template: ui/poddisruptionbudget.yaml+ set:+ ui.pdb.enabled: true+ asserts:+ - equal:+ path: spec.maxUnavailable+ value: 1+ - notExists:+ path: spec.minAvailable+ - equal:+ path: spec.selector.matchLabels+ value:+ app.kubernetes.io/name: litellm+ app.kubernetes.io/instance: RELEASE-NAME+ app.kubernetes.io/component: ui++ - it: renders no PDB for a disabled component even when its pdb is enabled+ template: gateway/poddisruptionbudget.yaml+ set:+ gateway.enabled: false+ gateway.pdb.enabled: true+ asserts:+ - hasDocuments:+ count: 0++ - it: deployments omit topologySpreadConstraints by default+ templates:+ - gateway/deployment.yaml+ - backend/deployment.yaml+ - ui/deployment.yaml+ asserts:+ - notExists:+ path: spec.template.spec.topologySpreadConstraints++ - it: gateway deployment renders configured topologySpreadConstraints+ template: gateway/deployment.yaml+ set:+ gateway.topologySpreadConstraints:+ - maxSkew: 1+ topologyKey: topology.kubernetes.io/zone+ whenUnsatisfiable: ScheduleAnyway+ labelSelector:+ matchLabels:+ app.kubernetes.io/component: gateway+ asserts:+ - equal:+ path: spec.template.spec.topologySpreadConstraints+ value:+ - maxSkew: 1+ topologyKey: topology.kubernetes.io/zone+ whenUnsatisfiable: ScheduleAnyway+ labelSelector:+ matchLabels:+ app.kubernetes.io/component: gateway++ - it: backend deployment renders configured topologySpreadConstraints+ template: backend/deployment.yaml+ set:+ backend.topologySpreadConstraints:+ - maxSkew: 1+ topologyKey: kubernetes.io/hostname+ whenUnsatisfiable: DoNotSchedule+ labelSelector:+ matchLabels:+ app.kubernetes.io/component: backend+ asserts:+ - equal:+ path: spec.template.spec.topologySpreadConstraints[0].topologyKey+ value: kubernetes.io/hostname+ - equal:+ path: spec.template.spec.topologySpreadConstraints[0].whenUnsatisfiable+ value: DoNotSchedule++ - it: ui deployment renders configured topologySpreadConstraints+ template: ui/deployment.yaml+ set:+ ui.topologySpreadConstraints:+ - maxSkew: 1+ topologyKey: topology.kubernetes.io/zone+ whenUnsatisfiable: ScheduleAnyway+ asserts:+ - equal:+ path: spec.template.spec.topologySpreadConstraints[0].topologyKey+ value: topology.kubernetes.io/zonediff --git a/helm/litellm/values.yaml b/helm/litellm/values.yamlindex 74d02a25b7a..461935b2f50 100644--- a/helm/litellm/values.yaml+++ b/helm/litellm/values.yaml@@ -190,10 +190,28 @@ gateway:maxReplicas: 10targetCPUUtilizationPercentage: 70targetMemoryUtilizationPercentage: 80+ # PodDisruptionBudget for the gateway pods. Set exactly one of+ # `minAvailable` / `maxUnavailable` (minAvailable wins if both are set;+ # enabling without either falls back to `maxUnavailable: 1`). Disabled by+ # default: with the default hpa.minReplicas of 1, a `minAvailable: 1` PDB+ # would block node drains entirely.+ pdb:+ enabled: false+ minAvailable: ""+ maxUnavailable: ""podAnnotations: {}nodeSelector: {}tolerations: []affinity: {}+ # Standard k8s topologySpreadConstraints for the gateway pods, e.g. to+ # spread replicas across zones:+ # - maxSkew: 1+ # topologyKey: topology.kubernetes.io/zone+ # whenUnsatisfiable: ScheduleAnyway+ # labelSelector:+ # matchLabels:+ # app.kubernetes.io/component: gateway+ topologySpreadConstraints: []# ---------- backend (UI / management API) ----------backend:@@ -233,10 +251,17 @@ backend:minReplicas: 1maxReplicas: 4targetCPUUtilizationPercentage: 70+ # Same shape as gateway.pdb.+ pdb:+ enabled: false+ minAvailable: ""+ maxUnavailable: ""podAnnotations: {}nodeSelector: {}tolerations: []affinity: {}+ # Same shape as gateway.topologySpreadConstraints.+ topologySpreadConstraints: []# ---------- ui (Next.js static dashboard) ----------ui:@@ -279,7 +304,14 @@ ui:minReplicas: 1maxReplicas: 3targetCPUUtilizationPercentage: 80+ # Same shape as gateway.pdb.+ pdb:+ enabled: false+ minAvailable: ""+ maxUnavailable: ""podAnnotations: {}nodeSelector: {}tolerations: []affinity: {}+ # Same shape as gateway.topologySpreadConstraints.+ topologySpreadConstraints: []