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]

(helm) - allow specifying envVars on values.yaml + add helm lint test (#7789)

Ishaan Jaff4081aeb15e53
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 2072578709d..ad6c457f72d 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -902,6 +902,72 @@ jobs:
pwd
ls
python -m pytest -vv tests/local_testing/test_basic_python_version.py
+ helm_chart_testing:
+ machine:
+ image: ubuntu-2204:2023.10.1 # Use machine executor instead of docker
+ resource_class: medium
+ working_directory: ~/project
+
+ steps:
+ - checkout
+ # Install Helm
+ - run:
+ name: Install Helm
+ command: |
+ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
+
+ # Install kind
+ - run:
+ name: Install Kind
+ command: |
+ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
+ chmod +x ./kind
+ sudo mv ./kind /usr/local/bin/kind
+
+ # Install kubectl
+ - run:
+ name: Install kubectl
+ command: |
+ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
+ chmod +x kubectl
+ sudo mv kubectl /usr/local/bin/
+
+ # Create kind cluster
+ - run:
+ name: Create Kind Cluster
+ command: |
+ kind create cluster --name litellm-test
+
+ # Run helm lint
+ - run:
+ name: Run helm lint
+ command: |
+ helm lint ./deploy/charts/litellm-helm
+
+ # Run helm tests
+ - run:
+ name: Run helm tests
+ command: |
+ helm install litellm ./deploy/charts/litellm-helm -f ./deploy/charts/litellm-helm/ci/test-values.yaml
+ # Wait for pod to be ready
+ echo "Waiting 30 seconds for pod to be ready..."
+ sleep 30
+
+ # Print pod logs before running tests
+ echo "Printing pod logs..."
+ kubectl logs $(kubectl get pods -l app.kubernetes.io/name=litellm -o jsonpath="{.items[0].metadata.name}")
+
+ # Run the helm tests
+ helm test litellm --logs
+ helm test litellm --logs
+
+ # Cleanup
+ - run:
+ name: Cleanup
+ command: |
+ kind delete cluster --name litellm-test
+ when: always # This ensures cleanup runs even if previous steps fail
+
check_code_and_doc_quality:
docker:
@@ -1971,6 +2037,12 @@ workflows:
only:
- main
- /litellm_.*/
+ - helm_chart_testing:
+ filters:
+ branches:
+ only:
+ - main
+ - /litellm_.*/
- load_testing:
filters:
branches:
diff --git a/deploy/charts/litellm-helm/ci/test-values.yaml b/deploy/charts/litellm-helm/ci/test-values.yaml
new file mode 100644
index 00000000000..33a4df942ee
--- /dev/null
+++ b/deploy/charts/litellm-helm/ci/test-values.yaml
@@ -0,0 +1,15 @@
+fullnameOverride: ""
+# Disable database deployment and configuration
+db:
+ deployStandalone: false
+ useExisting: false
+
+# Test environment variables
+envVars:
+ DD_ENV: "dev_helm"
+ DD_SERVICE: "litellm"
+ USE_DDTRACE: "true"
+
+# Disable migration job since we're not using a database
+migrationJob:
+ enabled: false
\ No newline at end of file
diff --git a/deploy/charts/litellm-helm/templates/deployment.yaml b/deploy/charts/litellm-helm/templates/deployment.yaml
index 7f4e876532b..697148abf8c 100644
--- a/deploy/charts/litellm-helm/templates/deployment.yaml
+++ b/deploy/charts/litellm-helm/templates/deployment.yaml
@@ -91,6 +91,12 @@ spec:
name: {{ include "redis.secretName" .Subcharts.redis }}
key: {{include "redis.secretPasswordKey" .Subcharts.redis }}
{{- end }}
+ {{- if .Values.envVars }}
+ {{- range $key, $val := .Values.envVars }}
+ - name: {{ $key }}
+ value: {{ $val | quote }}
+ {{- end }}
+ {{- end }}
envFrom:
{{- range .Values.environmentSecrets }}
- secretRef:
diff --git a/deploy/charts/litellm-helm/templates/tests/test-connection.yaml b/deploy/charts/litellm-helm/templates/tests/test-connection.yaml
index d2a4034b114..86a8f66b10b 100644
--- a/deploy/charts/litellm-helm/templates/tests/test-connection.yaml
+++ b/deploy/charts/litellm-helm/templates/tests/test-connection.yaml
@@ -10,6 +10,16 @@ spec:
containers:
- name: wget
image: busybox
- command: ['wget']
- args: ['{{ include "litellm.fullname" . }}:{{ .Values.service.port }}/health/readiness']
- restartPolicy: Never
+ command: ['sh', '-c']
+ args:
+ - |
+ # Wait for a bit to allow the service to be ready
+ sleep 10
+ # Try multiple times with a delay between attempts
+ for i in $(seq 1 30); do
+ wget -T 5 "{{ include "litellm.fullname" . }}:{{ .Values.service.port }}/health/readiness" && exit 0
+ echo "Attempt $i failed, waiting..."
+ sleep 2
+ done
+ exit 1
+ restartPolicy: Never
\ No newline at end of file
diff --git a/deploy/charts/litellm-helm/templates/tests/test-env-vars.yaml b/deploy/charts/litellm-helm/templates/tests/test-env-vars.yaml
new file mode 100644
index 00000000000..9f0277557a4
--- /dev/null
+++ b/deploy/charts/litellm-helm/templates/tests/test-env-vars.yaml
@@ -0,0 +1,43 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: "{{ include "litellm.fullname" . }}-env-test"
+ labels:
+ {{- include "litellm.labels" . | nindent 4 }}
+ annotations:
+ "helm.sh/hook": test
+spec:
+ containers:
+ - name: test
+ image: busybox
+ command: ['sh', '-c']
+ args:
+ - |
+ # Test DD_ENV
+ if [ "$DD_ENV" != "dev_helm" ]; then
+ echo "❌ Environment variable DD_ENV mismatch. Expected: dev_helm, Got: $DD_ENV"
+ exit 1
+ fi
+ echo "✅ Environment variable DD_ENV matches expected value: $DD_ENV"
+
+ # Test DD_SERVICE
+ if [ "$DD_SERVICE" != "litellm" ]; then
+ echo "❌ Environment variable DD_SERVICE mismatch. Expected: litellm, Got: $DD_SERVICE"
+ exit 1
+ fi
+ echo "✅ Environment variable DD_SERVICE matches expected value: $DD_SERVICE"
+
+ # Test USE_DDTRACE
+ if [ "$USE_DDTRACE" != "true" ]; then
+ echo "❌ Environment variable USE_DDTRACE mismatch. Expected: true, Got: $USE_DDTRACE"
+ exit 1
+ fi
+ echo "✅ Environment variable USE_DDTRACE matches expected value: $USE_DDTRACE"
+ env:
+ - name: DD_ENV
+ value: {{ .Values.envVars.DD_ENV | quote }}
+ - name: DD_SERVICE
+ value: {{ .Values.envVars.DD_SERVICE | quote }}
+ - name: USE_DDTRACE
+ value: {{ .Values.envVars.USE_DDTRACE | quote }}
+ restartPolicy: Never
\ No newline at end of file
diff --git a/deploy/charts/litellm-helm/values.yaml b/deploy/charts/litellm-helm/values.yaml
index de020aa8c87..19cbf723211 100644
--- a/deploy/charts/litellm-helm/values.yaml
+++ b/deploy/charts/litellm-helm/values.yaml
@@ -188,4 +188,9 @@ migrationJob:
disableSchemaUpdate: false # Skip schema migrations for specific environments. When True, the job will exit with code 0.
annotations: {}
+# Additional environment variables to be added to the deployment
+envVars: {
+ # USE_DDTRACE: "true"
+}
+