Skip to content

Commit 44373ba

Browse files
committed
feat: make masterkey secret configurable
1 parent 8cc63e0 commit 44373ba

File tree

8 files changed

+65
-5
lines changed

8 files changed

+65
-5
lines changed

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ help:
99
@echo " make test - Run all tests"
1010
@echo " make test-unit - Run unit tests"
1111
@echo " make test-integration - Run integration tests"
12+
@echo " make test-unit-helm - Run helm unit tests"
1213

1314
install-dev:
1415
poetry install --with dev
@@ -25,4 +26,7 @@ test-unit:
2526
poetry run pytest tests/litellm/
2627

2728
test-integration:
28-
poetry run pytest tests/ -k "not litellm"
29+
poetry run pytest tests/ -k "not litellm"
30+
31+
test-unit-helm:
32+
helm unittest -f 'tests/*.yaml' deploy/charts/litellm-helm

deploy/charts/litellm-helm/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type: application
1818
# This is the chart version. This version number should be incremented each time you make changes
1919
# to the chart and its templates, including the app version.
2020
# Versions are expected to follow Semantic Versioning (https://semver.org/)
21-
version: 0.4.1
21+
version: 0.4.2
2222

2323
# This is the version number of the application being deployed. This version number should be
2424
# incremented each time you make changes to the application. Versions are not expected to

deploy/charts/litellm-helm/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ If `db.useStackgresOperator` is used (not yet implemented):
2222
| Name | Description | Value |
2323
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
2424
| `replicaCount` | The number of LiteLLM Proxy pods to be deployed | `1` |
25+
| `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 |
26+
| `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 |
2527
| `masterkey` | The Master API Key for LiteLLM. If not specified, a random key is generated. | N/A |
2628
| `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. | `[]` |
2729
| `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. | `[]` |

deploy/charts/litellm-helm/templates/deployment.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ spec:
7878
- name: PROXY_MASTER_KEY
7979
valueFrom:
8080
secretKeyRef:
81-
name: {{ include "litellm.fullname" . }}-masterkey
82-
key: masterkey
81+
name: {{ .Values.masterkeySecretName | default (printf "%s-masterkey" (include "litellm.fullname" .)) }}
82+
key: {{ .Values.masterkeySecretKey | default "masterkey" }}
8383
{{- if .Values.redis.enabled }}
8484
- name: REDIS_HOST
8585
value: {{ include "litellm.redis.serviceName" . }}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
{{- if not .Values.masterkeySecretName }}
12
{{ $masterkey := (.Values.masterkey | default (randAlphaNum 17)) }}
23
apiVersion: v1
34
kind: Secret
45
metadata:
56
name: {{ include "litellm.fullname" . }}-masterkey
67
data:
78
masterkey: {{ $masterkey | b64enc }}
8-
type: Opaque
9+
type: Opaque
10+
{{- end }}

deploy/charts/litellm-helm/tests/deployment_tests.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,31 @@ tests:
5252
- equal:
5353
path: spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values[0]
5454
value: antarctica-east1
55+
- it: should work without masterkeySecretName or masterkeySecretKey
56+
template: deployment.yaml
57+
set:
58+
masterkeySecretName: ""
59+
masterkeySecretKey: ""
60+
asserts:
61+
- contains:
62+
path: spec.template.spec.containers[0].env
63+
content:
64+
name: PROXY_MASTER_KEY
65+
valueFrom:
66+
secretKeyRef:
67+
name: RELEASE-NAME-litellm-masterkey
68+
key: masterkey
69+
- it: should work with masterkeySecretName and masterkeySecretKey
70+
template: deployment.yaml
71+
set:
72+
masterkeySecretName: my-secret
73+
masterkeySecretKey: my-key
74+
asserts:
75+
- contains:
76+
path: spec.template.spec.containers[0].env
77+
content:
78+
name: PROXY_MASTER_KEY
79+
valueFrom:
80+
secretKeyRef:
81+
name: my-secret
82+
key: my-key
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
suite: test masterkey secret
2+
templates:
3+
- secret-masterkey.yaml
4+
tests:
5+
- it: should create a secret if masterkeySecretName is not set
6+
template: secret-masterkey.yaml
7+
set:
8+
masterkeySecretName: ""
9+
asserts:
10+
- isKind:
11+
of: Secret
12+
- it: should not create a secret if masterkeySecretName is set
13+
template: secret-masterkey.yaml
14+
set:
15+
masterkeySecretName: my-secret
16+
asserts:
17+
- hasDocuments:
18+
count: 0

deploy/charts/litellm-helm/values.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ ingress:
7575

7676
# masterkey: changeit
7777

78+
# if set, use this secret for the master key; otherwise, autogenerate a new one
79+
masterkeySecretName: ""
80+
81+
# if set, use this secret key for the master key; otherwise, use the default key
82+
masterkeySecretKey: ""
83+
7884
# The elements within proxy_config are rendered as config.yaml for the proxy
7985
# Examples: https://github.com/BerriAI/litellm/tree/main/litellm/proxy/example_config_yaml
8086
# Reference: https://docs.litellm.ai/docs/proxy/configs

0 commit comments

Comments
 (0)