Skip to content

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]

feat: Add envVars and extraEnvVars support to Helm migrations job (#12591)

Antonf05ec34e1117
diff --git a/deploy/charts/litellm-helm/templates/migrations-job.yaml b/deploy/charts/litellm-helm/templates/migrations-job.yaml
index f00466bc487..32b12aa10fa 100644
--- a/deploy/charts/litellm-helm/templates/migrations-job.yaml
+++ b/deploy/charts/litellm-helm/templates/migrations-job.yaml
@@ -49,6 +49,15 @@ spec:
{{- end }}
- name: DISABLE_SCHEMA_UPDATE
value: "false" # always run the migration from the Helm PreSync hook, override the value set
+ {{- if .Values.envVars }}
+ {{- range $key, $val := .Values.envVars }}
+ - name: {{ $key }}
+ value: {{ $val | quote }}
+ {{- end }}
+ {{- end }}
+ {{- with .Values.extraEnvVars }}
+ {{- toYaml . | nindent 12 }}
+ {{- end }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
diff --git a/deploy/charts/litellm-helm/tests/migrations-job_tests.yaml b/deploy/charts/litellm-helm/tests/migrations-job_tests.yaml
new file mode 100644
index 00000000000..686d20efa55
--- /dev/null
+++ b/deploy/charts/litellm-helm/tests/migrations-job_tests.yaml
@@ -0,0 +1,113 @@
+suite: test migrations job
+templates:
+ - migrations-job.yaml
+tests:
+ - it: should work with envVars
+ template: migrations-job.yaml
+ set:
+ envVars:
+ TEST_ENV_VAR: "test_value"
+ ANOTHER_VAR: "another_value"
+ migrationJob:
+ enabled: true
+ asserts:
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: TEST_ENV_VAR
+ value: "test_value"
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: ANOTHER_VAR
+ value: "another_value"
+
+ - it: should work with extraEnvVars
+ template: migrations-job.yaml
+ set:
+ extraEnvVars:
+ - name: EXTRA_ENV_VAR
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.labels['env']
+ - name: SIMPLE_EXTRA_VAR
+ value: "simple_value"
+ migrationJob:
+ enabled: true
+ asserts:
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: EXTRA_ENV_VAR
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.labels['env']
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: SIMPLE_EXTRA_VAR
+ value: "simple_value"
+
+ - it: should work with both envVars and extraEnvVars
+ template: migrations-job.yaml
+ set:
+ envVars:
+ ENV_VAR: "env_var_value"
+ extraEnvVars:
+ - name: EXTRA_ENV_VAR
+ value: "extra_env_var_value"
+ migrationJob:
+ enabled: true
+ asserts:
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: ENV_VAR
+ value: "env_var_value"
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: EXTRA_ENV_VAR
+ value: "extra_env_var_value"
+
+ - it: should not render when migrations job is disabled
+ template: migrations-job.yaml
+ set:
+ migrationJob:
+ enabled: false
+ asserts:
+ - hasDocuments:
+ count: 0
+
+ - it: should still include default env vars
+ template: migrations-job.yaml
+ set:
+ envVars:
+ CUSTOM_VAR: "custom_value"
+ migrationJob:
+ enabled: true
+ db:
+ useExisting: true
+ endpoint: "test-db"
+ database: "testdb"
+ url: "postgresql://user:pass@test-db:5432/testdb"
+ secret:
+ name: "test-secret"
+ usernameKey: "username"
+ passwordKey: "password"
+ asserts:
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: DISABLE_SCHEMA_UPDATE
+ value: "false"
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: DATABASE_HOST
+ value: "test-db"
+ - contains:
+ path: spec.template.spec.containers[0].env
+ content:
+ name: CUSTOM_VAR
+ value: "custom_value"
\ No newline at end of file