mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
feat(helm): support user-defined volumes and volumeMounts in microservices chart (#32233)
The componentized chart at helm/litellm had no way to mount extra volumes into its deployments, so custom callback or SSO handler code could not be mounted the way the docs describe for the monolithic chart. Adds per-component volumes and volumeMounts values for gateway, backend, and ui, merged with the existing gateway-config volume, plus a helm-unittest suite for the chart wired into the helm unit test workflow Resolves LIT-4209
This commit is contained in:
parent
4428c1b681
commit
6a9c242f66
7 changed files with 224 additions and 5 deletions
4
.github/workflows/helm_unit_test.yml
vendored
4
.github/workflows/helm_unit_test.yml
vendored
|
|
@ -38,4 +38,6 @@ jobs:
|
|||
echo "Helm unittest plugin integrity verified: $ACTUAL_SHA"
|
||||
|
||||
- name: Run unit tests
|
||||
run: helm unittest -f 'tests/*.yaml' deploy/charts/litellm-helm
|
||||
run: |
|
||||
helm unittest -f 'tests/*.yaml' deploy/charts/litellm-helm
|
||||
helm unittest -f 'tests/*.yaml' helm/litellm
|
||||
|
|
|
|||
|
|
@ -45,11 +45,16 @@ spec:
|
|||
value: /app/config/config.yaml
|
||||
{{- end }}
|
||||
{{- include "litellm.envFrom" .Values.backend | nindent 10 }}
|
||||
{{- if .Values.gateway.config.create }}
|
||||
{{- if or .Values.gateway.config.create .Values.backend.volumeMounts }}
|
||||
volumeMounts:
|
||||
{{- if .Values.gateway.config.create }}
|
||||
- name: gateway-config
|
||||
mountPath: /app/config/config.yaml
|
||||
subPath: config.yaml
|
||||
{{- end }}
|
||||
{{- with .Values.backend.volumeMounts }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.livenessProbe }}
|
||||
livenessProbe:
|
||||
|
|
@ -61,11 +66,16 @@ spec:
|
|||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.backend.resources | nindent 12 }}
|
||||
{{- if .Values.gateway.config.create }}
|
||||
{{- if or .Values.gateway.config.create .Values.backend.volumes }}
|
||||
volumes:
|
||||
{{- if .Values.gateway.config.create }}
|
||||
- name: gateway-config
|
||||
configMap:
|
||||
name: {{ include "litellm.gateway.fullname" . }}-config
|
||||
{{- end }}
|
||||
{{- with .Values.backend.volumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.nodeSelector }}
|
||||
nodeSelector:
|
||||
|
|
|
|||
|
|
@ -47,11 +47,16 @@ spec:
|
|||
value: {{ .Values.gateway.numWorkers | quote }}
|
||||
{{- end }}
|
||||
{{- include "litellm.envFrom" .Values.gateway | nindent 10 }}
|
||||
{{- if .Values.gateway.config.create }}
|
||||
{{- if or .Values.gateway.config.create .Values.gateway.volumeMounts }}
|
||||
volumeMounts:
|
||||
{{- if .Values.gateway.config.create }}
|
||||
- name: gateway-config
|
||||
mountPath: /app/config/config.yaml
|
||||
subPath: config.yaml
|
||||
{{- end }}
|
||||
{{- with .Values.gateway.volumeMounts }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.gateway.livenessProbe }}
|
||||
livenessProbe:
|
||||
|
|
@ -63,11 +68,16 @@ spec:
|
|||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.gateway.resources | nindent 12 }}
|
||||
{{- if .Values.gateway.config.create }}
|
||||
{{- if or .Values.gateway.config.create .Values.gateway.volumes }}
|
||||
volumes:
|
||||
{{- if .Values.gateway.config.create }}
|
||||
- name: gateway-config
|
||||
configMap:
|
||||
name: {{ include "litellm.gateway.fullname" . }}-config
|
||||
{{- end }}
|
||||
{{- with .Values.gateway.volumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.gateway.nodeSelector }}
|
||||
nodeSelector:
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ spec:
|
|||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- include "litellm.envFrom" .Values.ui | nindent 10 }}
|
||||
{{- with .Values.ui.volumeMounts }}
|
||||
volumeMounts:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.ui.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
|
|
@ -56,6 +60,10 @@ spec:
|
|||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.ui.resources | nindent 12 }}
|
||||
{{- with .Values.ui.volumes }}
|
||||
volumes:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.ui.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
|
|
|
|||
172
helm/litellm/tests/deployment_volumes_tests.yaml
Normal file
172
helm/litellm/tests/deployment_volumes_tests.yaml
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
suite: test deployment volumes and volumeMounts
|
||||
templates:
|
||||
- gateway/deployment.yaml
|
||||
- gateway/configmap.yaml
|
||||
- backend/deployment.yaml
|
||||
- ui/deployment.yaml
|
||||
values:
|
||||
- ./values/required.yaml
|
||||
tests:
|
||||
- it: gateway renders only the config volume by default
|
||||
template: gateway/deployment.yaml
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: gateway-config
|
||||
configMap:
|
||||
name: RELEASE-NAME-litellm-gateway-config
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: gateway-config
|
||||
mountPath: /app/config/config.yaml
|
||||
subPath: config.yaml
|
||||
|
||||
- it: gateway merges user volumes and volumeMounts with the config volume
|
||||
template: gateway/deployment.yaml
|
||||
set:
|
||||
gateway.volumes:
|
||||
- name: custom-callbacks
|
||||
configMap:
|
||||
name: custom-callbacks
|
||||
gateway.volumeMounts:
|
||||
- name: custom-callbacks
|
||||
mountPath: /app/custom_callbacks.py
|
||||
subPath: custom_callbacks.py
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0].name
|
||||
value: gateway-config
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[1]
|
||||
value:
|
||||
name: custom-callbacks
|
||||
configMap:
|
||||
name: custom-callbacks
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts[0].name
|
||||
value: gateway-config
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts[1]
|
||||
value:
|
||||
name: custom-callbacks
|
||||
mountPath: /app/custom_callbacks.py
|
||||
subPath: custom_callbacks.py
|
||||
|
||||
- it: gateway renders user volumes even when config creation is disabled
|
||||
template: gateway/deployment.yaml
|
||||
set:
|
||||
gateway.config.create: false
|
||||
gateway.volumes:
|
||||
- name: certs
|
||||
secret:
|
||||
secretName: tls-certs
|
||||
gateway.volumeMounts:
|
||||
- name: certs
|
||||
mountPath: /etc/certs
|
||||
readOnly: true
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: certs
|
||||
secret:
|
||||
secretName: tls-certs
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: certs
|
||||
mountPath: /etc/certs
|
||||
readOnly: true
|
||||
|
||||
- it: gateway omits volumes when config creation is disabled and no user volumes are set
|
||||
template: gateway/deployment.yaml
|
||||
set:
|
||||
gateway.config.create: false
|
||||
asserts:
|
||||
- isNull:
|
||||
path: spec.template.spec.volumes
|
||||
- isNull:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
|
||||
- it: backend merges user volumes and volumeMounts with the shared config volume
|
||||
template: backend/deployment.yaml
|
||||
set:
|
||||
backend.volumes:
|
||||
- name: sso-handler
|
||||
configMap:
|
||||
name: sso-handler
|
||||
backend.volumeMounts:
|
||||
- name: sso-handler
|
||||
mountPath: /app/custom_sso.py
|
||||
subPath: custom_sso.py
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[0].name
|
||||
value: gateway-config
|
||||
- equal:
|
||||
path: spec.template.spec.volumes[1]
|
||||
value:
|
||||
name: sso-handler
|
||||
configMap:
|
||||
name: sso-handler
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts[1]
|
||||
value:
|
||||
name: sso-handler
|
||||
mountPath: /app/custom_sso.py
|
||||
subPath: custom_sso.py
|
||||
|
||||
- it: backend renders user volumes even when config creation is disabled
|
||||
template: backend/deployment.yaml
|
||||
set:
|
||||
gateway.config.create: false
|
||||
backend.volumes:
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
backend.volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
|
||||
- it: ui renders no volumes by default
|
||||
template: ui/deployment.yaml
|
||||
asserts:
|
||||
- isNull:
|
||||
path: spec.template.spec.volumes
|
||||
- isNull:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
|
||||
- it: ui renders user volumes and volumeMounts
|
||||
template: ui/deployment.yaml
|
||||
set:
|
||||
ui.volumes:
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: custom-nginx
|
||||
ui.volumeMounts:
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/conf.d
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: custom-nginx
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/conf.d
|
||||
4
helm/litellm/tests/values/required.yaml
Normal file
4
helm/litellm/tests/values/required.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
database:
|
||||
writer:
|
||||
host: postgres.example.com
|
||||
dbname: litellm
|
||||
|
|
@ -124,6 +124,11 @@ gateway:
|
|||
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
|
||||
# Additional volumes on the gateway Deployment (e.g. a ConfigMap holding
|
||||
# custom callback / SSO handler code, mounted next to the proxy config).
|
||||
volumes: []
|
||||
# Additional volumeMounts on the gateway container.
|
||||
volumeMounts: []
|
||||
config:
|
||||
create: true
|
||||
proxy_config: {}
|
||||
|
|
@ -167,6 +172,10 @@ backend:
|
|||
extraEnv: []
|
||||
envConfigMaps: []
|
||||
envSecrets: []
|
||||
# Additional volumes on the backend Deployment.
|
||||
volumes: []
|
||||
# Additional volumeMounts on the backend container.
|
||||
volumeMounts: []
|
||||
image:
|
||||
repository: ghcr.io/berriai/litellm-backend
|
||||
tag: ""
|
||||
|
|
@ -206,6 +215,10 @@ ui:
|
|||
extraEnv: []
|
||||
envConfigMaps: []
|
||||
envSecrets: []
|
||||
# Additional volumes on the ui Deployment.
|
||||
volumes: []
|
||||
# Additional volumeMounts on the ui container.
|
||||
volumeMounts: []
|
||||
image:
|
||||
repository: ghcr.io/berriai/litellm-ui
|
||||
tag: ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue