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: make masterkey secret configurable
Manuel Cañete44373baeee8f
diff --git a/Makefile b/Makefileindex 65553261689..6c231d3cc29 100644--- a/Makefile+++ b/Makefile@@ -9,6 +9,7 @@ help:@echo " make test - Run all tests"@echo " make test-unit - Run unit tests"@echo " make test-integration - Run integration tests"+ @echo " make test-unit-helm - Run helm unit tests"install-dev:poetry install --with dev@@ -25,4 +26,7 @@ test-unit:poetry run pytest tests/litellm/test-integration:- poetry run pytest tests/ -k "not litellm"\ No newline at end of file+ poetry run pytest tests/ -k "not litellm"++test-unit-helm:+ helm unittest -f 'tests/*.yaml' deploy/charts/litellm-helm\ No newline at end of filediff --git a/deploy/charts/litellm-helm/Chart.yaml b/deploy/charts/litellm-helm/Chart.yamlindex f1f2fd8d64a..4d856fdc0f0 100644--- a/deploy/charts/litellm-helm/Chart.yaml+++ b/deploy/charts/litellm-helm/Chart.yaml@@ -18,7 +18,7 @@ type: application# This is the chart version. This version number should be incremented each time you make changes# to the chart and its templates, including the app version.# Versions are expected to follow Semantic Versioning (https://semver.org/)-version: 0.4.1+version: 0.4.2# This is the version number of the application being deployed. This version number should be# incremented each time you make changes to the application. Versions are not expected todiff --git a/deploy/charts/litellm-helm/README.md b/deploy/charts/litellm-helm/README.mdindex 8b2196f5778..a0ba5781dfd 100644--- a/deploy/charts/litellm-helm/README.md+++ b/deploy/charts/litellm-helm/README.md@@ -22,6 +22,8 @@ If `db.useStackgresOperator` is used (not yet implemented):| Name | Description | Value || ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- || `replicaCount` | The number of LiteLLM Proxy pods to be deployed | `1` |+| `masterkeySecretName` | The name of the Kubernetes Secret that contains the Master API Key for LiteLLM. If not specified, use the generated secret name. | N/A |+| `masterkeySecretKey` | The key within the Kubernetes Secret that contains the Master API Key for LiteLLM. If not specified, use `masterkey` as the key. | N/A || `masterkey` | The Master API Key for LiteLLM. If not specified, a random key is generated. | N/A || `environmentSecrets` | An optional array of Secret object names. The keys and values in these secrets will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` || `environmentConfigMaps` | An optional array of ConfigMap object names. The keys and values in these configmaps will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` |diff --git a/deploy/charts/litellm-helm/templates/deployment.yaml b/deploy/charts/litellm-helm/templates/deployment.yamlindex 697148abf8c..52f761ed15a 100644--- a/deploy/charts/litellm-helm/templates/deployment.yaml+++ b/deploy/charts/litellm-helm/templates/deployment.yaml@@ -78,8 +78,8 @@ spec:- name: PROXY_MASTER_KEYvalueFrom:secretKeyRef:- name: {{ include "litellm.fullname" . }}-masterkey- key: masterkey+ name: {{ .Values.masterkeySecretName | default (printf "%s-masterkey" (include "litellm.fullname" .)) }}+ key: {{ .Values.masterkeySecretKey | default "masterkey" }}{{- if .Values.redis.enabled }}- name: REDIS_HOSTvalue: {{ include "litellm.redis.serviceName" . }}diff --git a/deploy/charts/litellm-helm/templates/secret-masterkey.yaml b/deploy/charts/litellm-helm/templates/secret-masterkey.yamlindex 57b854cc0ff..5632957dc05 100644--- a/deploy/charts/litellm-helm/templates/secret-masterkey.yaml+++ b/deploy/charts/litellm-helm/templates/secret-masterkey.yaml@@ -1,3 +1,4 @@+{{- if not .Values.masterkeySecretName }}{{ $masterkey := (.Values.masterkey | default (randAlphaNum 17)) }}apiVersion: v1kind: Secret@@ -5,4 +6,5 @@ metadata:name: {{ include "litellm.fullname" . }}-masterkeydata:masterkey: {{ $masterkey | b64enc }}-type: Opaque\ No newline at end of file+type: Opaque+{{- end }}diff --git a/deploy/charts/litellm-helm/tests/deployment_tests.yaml b/deploy/charts/litellm-helm/tests/deployment_tests.yamlindex e7ce44b0529..0e4b8e0b1fd 100644--- a/deploy/charts/litellm-helm/tests/deployment_tests.yaml+++ b/deploy/charts/litellm-helm/tests/deployment_tests.yaml@@ -52,3 +52,31 @@ tests:- equal:path: spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values[0]value: antarctica-east1+ - it: should work without masterkeySecretName or masterkeySecretKey+ template: deployment.yaml+ set:+ masterkeySecretName: ""+ masterkeySecretKey: ""+ asserts:+ - contains:+ path: spec.template.spec.containers[0].env+ content:+ name: PROXY_MASTER_KEY+ valueFrom:+ secretKeyRef:+ name: RELEASE-NAME-litellm-masterkey+ key: masterkey+ - it: should work with masterkeySecretName and masterkeySecretKey+ template: deployment.yaml+ set:+ masterkeySecretName: my-secret+ masterkeySecretKey: my-key+ asserts:+ - contains:+ path: spec.template.spec.containers[0].env+ content:+ name: PROXY_MASTER_KEY+ valueFrom:+ secretKeyRef:+ name: my-secret+ key: my-keydiff --git a/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yaml b/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yamlnew file mode 100644index 00000000000..eb1d3c3967f--- /dev/null+++ b/deploy/charts/litellm-helm/tests/masterkey-secret_tests.yaml@@ -0,0 +1,18 @@+suite: test masterkey secret+templates:+ - secret-masterkey.yaml+tests:+ - it: should create a secret if masterkeySecretName is not set+ template: secret-masterkey.yaml+ set:+ masterkeySecretName: ""+ asserts:+ - isKind:+ of: Secret+ - it: should not create a secret if masterkeySecretName is set+ template: secret-masterkey.yaml+ set:+ masterkeySecretName: my-secret+ asserts:+ - hasDocuments:+ count: 0diff --git a/deploy/charts/litellm-helm/values.yaml b/deploy/charts/litellm-helm/values.yamlindex 9f21fc40ade..70f6c2ef230 100644--- a/deploy/charts/litellm-helm/values.yaml+++ b/deploy/charts/litellm-helm/values.yaml@@ -75,6 +75,12 @@ ingress:# masterkey: changeit+# if set, use this secret for the master key; otherwise, autogenerate a new one+masterkeySecretName: ""++# if set, use this secret key for the master key; otherwise, use the default key+masterkeySecretKey: ""+# The elements within proxy_config are rendered as config.yaml for the proxy# Examples: https://github.com/BerriAI/litellm/tree/main/litellm/proxy/example_config_yaml# Reference: https://docs.litellm.ai/docs/proxy/configs