diff --git a/helm/litellm-helm/templates/_helpers.tpl b/helm/litellm-helm/templates/_helpers.tpl index 929fc415163..6ad3a8bbb6b 100644 --- a/helm/litellm-helm/templates/_helpers.tpl +++ b/helm/litellm-helm/templates/_helpers.tpl @@ -311,6 +311,10 @@ and the same spend transaction buffer. - name: LITELLM_LOG value: {{ .Values.logLevel | quote }} {{- end }} +{{- if and (not (kindIs "invalid" .Values.rustGateway.enabled)) (not (hasKey (default dict .Values.envVars) "LITELLM_RUST")) }} +- name: LITELLM_RUST + value: {{ .Values.rustGateway.enabled | toString | quote }} +{{- end }} {{- if .Values.envVars }} {{- range $key, $val := .Values.envVars }} - name: {{ $key }} diff --git a/helm/litellm-helm/tests/rust_gateway_tests.yaml b/helm/litellm-helm/tests/rust_gateway_tests.yaml new file mode 100644 index 00000000000..b183d66cb70 --- /dev/null +++ b/helm/litellm-helm/tests/rust_gateway_tests.yaml @@ -0,0 +1,52 @@ +suite: Rust forwarding gateway +templates: + - deployment.yaml + - configmap-litellm.yaml +tests: + - it: leaves the image default in place when unset + template: deployment.yaml + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + any: true + - it: turns forwarding off explicitly + template: deployment.yaml + set: + rustGateway.enabled: false + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "false" + - it: enables forwarding without changing command or probes + template: deployment.yaml + set: + rustGateway.enabled: true + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "true" + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.port + value: http + - it: respects an explicit environment override + template: deployment.yaml + set: + rustGateway.enabled: true + envVars.LITELLM_RUST: "false" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "false" + - notContains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "true" diff --git a/helm/litellm-helm/values.yaml b/helm/litellm-helm/values.yaml index f51f8bdd173..93ce3124d42 100644 --- a/helm/litellm-helm/values.yaml +++ b/helm/litellm-helm/values.yaml @@ -3,6 +3,10 @@ # Declare variables to be passed into your templates. replicaCount: 1 + +rustGateway: + # null inherits the image default; true or false sets LITELLM_RUST + enabled: liteadmin: enabled: false existingSecret: "" diff --git a/helm/litellm/templates/gateway/deployment.yaml b/helm/litellm/templates/gateway/deployment.yaml index b0e7f0dcebb..f75c5ad05bf 100644 --- a/helm/litellm/templates/gateway/deployment.yaml +++ b/helm/litellm/templates/gateway/deployment.yaml @@ -60,6 +60,17 @@ spec: - name: LITELLM_CORS_ORIGINS value: {{ include "litellm.ui.publicOrigin" . | quote }} {{- end }} + {{- $rustGateway := .Values.gateway.rustGateway | default dict }} + {{- $rustGatewayOverridden := false }} + {{- range .Values.gateway.extraEnv }} + {{- if eq .name "LITELLM_RUST" }} + {{- $rustGatewayOverridden = true }} + {{- end }} + {{- end }} + {{- if and (not (kindIs "invalid" $rustGateway.enabled)) (not $rustGatewayOverridden) }} + - name: LITELLM_RUST + value: {{ $rustGateway.enabled | toString | quote }} + {{- end }} {{- include "litellm.serverEnv" (dict "root" $ "component" .Values.gateway) | nindent 12 }} {{- if .Values.gateway.config.create }} - name: CONFIG_FILE_PATH diff --git a/helm/litellm/tests/rust_gateway_tests.yaml b/helm/litellm/tests/rust_gateway_tests.yaml new file mode 100644 index 00000000000..0a887d23e95 --- /dev/null +++ b/helm/litellm/tests/rust_gateway_tests.yaml @@ -0,0 +1,56 @@ +suite: Rust forwarding gateway +templates: + - gateway/deployment.yaml + - gateway/configmap.yaml +values: + - ./values/required.yaml +tests: + - it: leaves the image default in place when unset + template: gateway/deployment.yaml + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + any: true + - it: turns forwarding off explicitly + template: gateway/deployment.yaml + set: + gateway.rustGateway.enabled: false + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "false" + - it: enables forwarding without changing command or probes + template: gateway/deployment.yaml + set: + gateway.rustGateway.enabled: true + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "true" + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.port + value: http + - it: respects an explicit extraEnv override + template: gateway/deployment.yaml + set: + gateway.rustGateway.enabled: true + gateway.extraEnv: + - name: LITELLM_RUST + value: "false" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "false" + - notContains: + path: spec.template.spec.containers[0].env + content: + name: LITELLM_RUST + value: "true" diff --git a/helm/litellm/values.yaml b/helm/litellm/values.yaml index 92a48153c5a..04ef05acc50 100644 --- a/helm/litellm/values.yaml +++ b/helm/litellm/values.yaml @@ -303,6 +303,9 @@ gateway: # Number of uvicorn worker processes per gateway pod. Sets NUM_WORKERS, # consumed by the gateway image entrypoint. Default is 1. numWorkers: 1 + rustGateway: + # null inherits the image default; true or false sets LITELLM_RUST + enabled: extraEnv: [] # Add extra environment variables to the gateway envConfigMaps: [] # Add extra environment variables to the gateway from config maps envSecrets: [] # Add extra environment variables to the gateway from secrets