Merge pull request #2018 from Lunik/feat/refresh-helm-chart

 Refresh Helm chart structure
This commit is contained in:
Ishaan Jaff 2024-02-17 13:19:11 -08:00 committed by GitHub
commit 3fe762b8b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 60 additions and 285 deletions

4
.gitignore vendored
View file

@ -40,7 +40,7 @@ ui/litellm-dashboard/node_modules
ui/litellm-dashboard/next-env.d.ts
ui/litellm-dashboard/package.json
ui/litellm-dashboard/package-lock.json
deploy/charts/litellm-helm/*.tgz
deploy/charts/litellm-helm/charts/*
deploy/charts/litellm/*.tgz
deploy/charts/litellm/charts/*
deploy/charts/*.tgz
litellm/proxy/vertex_key.json

View file

@ -1,89 +0,0 @@
{{- if .Values.ui.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "litellm.fullname" . }}-ui
labels:
{{- include "litellm.labels" . | nindent 4 }}
spec:
{{- if not .Values.ui.autoscaling.enabled }}
replicas: {{ .Values.ui.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "litellm.ui.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "litellm.ui.labels" . | nindent 8 }}
{{- with .Values.ui.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "litellm.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.ui.podSecurityContext | nindent 8 }}
containers:
- name: {{ include "litellm.name" . }}-ui
securityContext:
{{- toYaml .Values.ui.securityContext | nindent 12 }}
image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag | default (printf "main-%s" .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.ui.image.pullPolicy }}
env:
- name: BASE_URL
value: {{ (index .Values.ui.ingress.hosts 0).host | default "example.com" }}
ports:
- name: http
containerPort: {{ .Values.ui.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
# Give the container time to start up. Up to 5 minutes (10 * 30 seconds)
startupProbe:
httpGet:
path: /
port: http
failureThreshold: 30
periodSeconds: 10
resources:
{{- toYaml .Values.ui.resources | nindent 12 }}
volumeMounts:
- name: tmp
mountPath: /tmp
{{- with .Values.ui.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: tmp
emptyDir:
sizeLimit: 500Mi
{{- with .Values.ui.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ui.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ui.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ui.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}

View file

@ -1,61 +0,0 @@
{{- if .Values.ui.ingress.enabled -}}
{{- $fullName := (printf "%s%s" (include "litellm.fullname" .) "-ui") -}}
{{- $svcPort := .Values.ui.service.port -}}
{{- if and .Values.ui.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ui.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ui.ingress.annotations "kubernetes.io/ingress.class" .Values.ui.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "litellm.ui.labels" . | nindent 4 }}
{{- with .Values.ui.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ui.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ui.ingress.className }}
{{- end }}
{{- if .Values.ui.ingress.tls }}
tls:
{{- range .Values.ui.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ui.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,17 +0,0 @@
{{- if .Values.ui.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "litellm.fullname" . }}-ui
labels:
{{- include "litellm.labels" . | nindent 4 }}
spec:
type: {{ .Values.ui.service.type }}
ports:
- port: {{ .Values.ui.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "litellm.ui.selectorLabels" . | nindent 4 }}
{{ end -}}

View file

@ -2,7 +2,7 @@ apiVersion: v2
# We can't call ourselves just "litellm" because then we couldn't publish to the
# same OCI repository as the "litellm" OCI image
name: litellm-helm
name: litellm
description: Call all LLM APIs using the OpenAI format
# A chart can be either an 'application' or a 'library' chart.
@ -18,17 +18,16 @@ 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.1.0
version: 0.2.0
# 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 to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: v1.18.9
appVersion: v1.24.5
dependencies:
- name: "postgresql"
version: ">=13.3.0"
repository: oci://registry-1.docker.io/bitnamicharts
condition: db.deployStandalone

View file

@ -43,20 +43,6 @@ data:
type: Opaque
```
### LiteLLM Admin UI Settings
| Name | Description | Value |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| `ui.enabled` | Should the LiteLLM Admin UI be deployed | `true` |
| `ui.replicaCount` | The number of LiteLLM Admin UI pods to be deployed | `1` |
| `ui.image.repository` | LiteLLM Admin UI image repository | `ghcr.io/berriai/litellm` |
| `ui.image.pullPolicy` | LiteLLM Admin UI image pull policy | `IfNotPresent` |
| `ui.image.tag` | Overrides the image tag whose default the latest version of LiteLLM at the time this chart was published. | `""` |
| `ui.imagePullSecrets` | Registry credentials for the above images. | `[]` |
| `ui.service.type` | Kubernetes Service type (e.g. `LoadBalancer`, `ClusterIP`, etc.) | `ClusterIP` |
| `ui.service.port` | TCP port that the Kubernetes Service will listen on. Also the TCP port within the Pod that the web server will listen on. | `8000` |
| `ui.ingress.*` | See [values.yaml](./values.yaml) for example settings | N/A |
### Database Settings
| Name | Description | Value |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
@ -86,18 +72,18 @@ type: Opaque
```
## Accessing the Admin UI
When browsing to the URL published per the settings in `ui.ingress.*`, you will
When browsing to the URL published per the settings in `ingress.*`, you will
be prompted for **Admin Configuration**. The **Proxy Endpoint** is the internal
(from the `litellm-ui` pod's perspective) URL published by the `litellm-proxy`
(from the `litellm` pod's perspective) URL published by the `<RELEASE>-litellm`
Kubernetes Service. If the deployment uses the default settings for this
service, the **Proxy Endpoint** should be set to `http://litellm-proxy:8000`.
service, the **Proxy Endpoint** should be set to `http://<RELEASE>-litellm:8000`.
The **Proxy Key** is the value specified for `masterkey` or, if a `masterkey`
was not provided to the helm command line, the `masterkey` is a randomly
generated string stored in the `litellm-masterkey` Kubernetes Secret.
generated string stored in the `<RELEASE>-litellm-masterkey` Kubernetes Secret.
```bash
kubectl -n litellm get secret litellm-masterkey -o jsonpath="{.data.masterkey}"
kubectl -n litellm get secret <RELEASE>-litellm-masterkey -o jsonpath="{.data.masterkey}"
```
## Admin UI Limitations

View file

@ -41,14 +41,6 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "litellm.ui.labels" -}}
helm.sh/chart: {{ include "litellm.chart" . }}
{{ include "litellm.ui.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
@ -57,10 +49,6 @@ Selector labels
app.kubernetes.io/name: {{ include "litellm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "litellm.ui.selectorLabels" -}}
app.kubernetes.io/name: {{ include "litellm.name" . }}-ui
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use

View file

@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "litellm.fullname" . }}-proxy
name: {{ include "litellm.fullname" . }}
labels:
{{- include "litellm.labels" . | nindent 4 }}
spec:
@ -41,12 +41,12 @@ spec:
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "litellm.name" . }}-dbcredentials
name: {{ include "litellm.fullname" . }}-dbcredentials
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "litellm.name" . }}-dbcredentials
name: {{ include "litellm.fullname" . }}-dbcredentials
key: password
- name: DATABASE_HOST
value: {{ .Release.Name }}-postgresql
@ -108,12 +108,12 @@ spec:
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "litellm.name" . }}-dbcredentials
name: {{ include "litellm.fullname" . }}-dbcredentials
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "litellm.name" . }}-dbcredentials
name: {{ include "litellm.fullname" . }}-dbcredentials
key: password
- name: DATABASE_HOST
value: {{ .Release.Name }}-postgresql
@ -140,7 +140,7 @@ spec:
- name: PROXY_MASTER_KEY
valueFrom:
secretKeyRef:
name: {{ include "litellm.name" . }}-masterkey
name: {{ include "litellm.fullname" . }}-masterkey
key: masterkey
envFrom:
{{- range .Values.environmentSecrets }}
@ -150,16 +150,7 @@ spec:
args:
- --config
- /etc/litellm/config.yaml
# command:
# - bash
# - -c
# - |
# ls -la /etc/litellm/; cat /etc/litellm/config.yaml; export
# find / 2>/dev/null | grep -v -e '^/proc' -e '^/sys' -e '^/dev' >/tmp/before.list
# prisma generate
# find / 2>/dev/null | grep -v -e '^/proc' -e '^/sys' -e '^/dev' >/tmp/after.list
# diff -ruN /tmp/before.list /tmp/after.list
# sleep 3600
- --run_gunicorn
ports:
- name: http
containerPort: {{ .Values.service.port }}

View file

@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := (printf "%s%s" (include "litellm.fullname" .) "-proxy") -}}
{{- $fullName := include "litellm.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}

View file

@ -2,7 +2,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "litellm.name" . }}-dbcredentials
name: {{ include "litellm.fullname" . }}-dbcredentials
data:
# Password for the "postgres" user
postgres-password: {{ ( index .Values.postgresql.auth "postgres-password") | default "litellm" | b64enc }}

View file

@ -2,7 +2,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "litellm.name" . }}-masterkey
name: {{ include "litellm.fullname" . }}-masterkey
data:
masterkey: {{ $masterkey | b64enc }}
type: Opaque

View file

@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "litellm.fullname" . }}-proxy
name: {{ include "litellm.fullname" . }}
labels:
{{- include "litellm.labels" . | nindent 4 }}
spec:

View file

@ -11,5 +11,5 @@ spec:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "litellm.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include "litellm.fullname" . }}:{{ .Values.service.port }}/health/readiness']
restartPolicy: Never

View file

@ -5,7 +5,9 @@
replicaCount: 1
image:
repository: ghcr.io/berriai/litellm
# Use "ghcr.io/berriai/litellm-database" for optimized image with database
# Alternatively, use "ghcr.io/berriai/litellm" for the default image
repository: ghcr.io/berriai/litellm-database
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
# tag: "main-latest"
@ -56,7 +58,7 @@ service:
port: 8000
ingress:
enabled: true
enabled: false
className: "nginx"
annotations: {}
# kubernetes.io/ingress.class: nginx
@ -71,6 +73,8 @@ ingress:
# hosts:
# - chart-example.local
# masterkey: changeit
# 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
@ -159,61 +163,6 @@ postgresql:
# A secret is created by this chart (litellm-helm) with the credentials that
# the new Postgres instance should use.
existingSecret: litellm-dbcredentials
secretKeys:
userPasswordKey: password
ui:
enabled: true
replicaCount: 1
autoscaling:
enabled: false
image:
repository: ghcr.io/berriai/litellm-ui
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
# tag: "main-latest"
# TODO: Switch to BerryAI repo and tags if/when they provide a ui image
# https://github.com/BerriAI/litellm/pull/1505
tag: ""
service:
type: ClusterIP
port: 8501
ingress:
enabled: true
className: "nginx"
annotations: {}
hosts:
- host: ui.example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
podAnnotations: {}
podLabels: {}
podSecurityContext:
fsGroup: 1000
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
resources: {}
volumes: []
volumeMounts: []
nodeSelector: {}
tolerations: []
affinity: {}
# existingSecret: ""
# secretKeys:
# userPasswordKey: password

View file

@ -151,6 +151,35 @@ kubectl port-forward service/litellm-service 4000:4000
Your OpenAI proxy server is now running on `http://0.0.0.0:4000`.
</TabItem>
<TabItem value="helm-deploy" label="Helm">
### Step 1. Clone the repository
```bash
git clone https://github.com/BerriAI/litellm.git
```
### Step 2. Deploy with Helm
```bash
helm install \
--set masterkey=SuPeRsEcReT \
mydeploy \
deploy/charts/litellm
```
### Step 3. Expose the service to localhost
```bash
kubectl \
port-forward \
service/mydeploy-litellm \
8000:8000
```
Your OpenAI proxy server is now running on `http://127.0.0.1:8000`.
</TabItem>
</Tabs>