From 7a1b3ca30dc145f6604393e89e30c007e23e632d Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Sun, 10 Mar 2024 01:52:36 +0530 Subject: [PATCH 1/4] feat(helm-chart): redis as cache managed by chart --- .gitignore | 1 + deploy/charts/litellm/Chart.yaml | 4 ++++ deploy/charts/litellm/templates/_helpers.tpl | 8 ++++++++ deploy/charts/litellm/templates/deployment.yaml | 11 +++++++++++ deploy/charts/litellm/values.yaml | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/.gitignore b/.gitignore index de1c7598f60..b03bc895bf9 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ deploy/charts/litellm/*.tgz deploy/charts/litellm/charts/* deploy/charts/*.tgz litellm/proxy/vertex_key.json +**/.vim/ diff --git a/deploy/charts/litellm/Chart.yaml b/deploy/charts/litellm/Chart.yaml index 6ecdebb506a..cc08a9921e4 100644 --- a/deploy/charts/litellm/Chart.yaml +++ b/deploy/charts/litellm/Chart.yaml @@ -31,3 +31,7 @@ dependencies: version: ">=13.3.0" repository: oci://registry-1.docker.io/bitnamicharts condition: db.deployStandalone + - name: redis + version: ">=18.0.0" + repository: oci://registry-1.docker.io/bitnamicharts + condition: redis.enabled diff --git a/deploy/charts/litellm/templates/_helpers.tpl b/deploy/charts/litellm/templates/_helpers.tpl index b8893d07c16..fa563fadc8f 100644 --- a/deploy/charts/litellm/templates/_helpers.tpl +++ b/deploy/charts/litellm/templates/_helpers.tpl @@ -60,3 +60,11 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Get redis service name +*/}} +{{- define "litellm.redis.serviceName" -}} +{{- printf "%s-headless" (default "redis" .Values.redis.nameOverride | trunc 63 | trimSuffix "-") -}} +{{- end -}} + diff --git a/deploy/charts/litellm/templates/deployment.yaml b/deploy/charts/litellm/templates/deployment.yaml index 6ed112dac38..bc2a0bd090a 100644 --- a/deploy/charts/litellm/templates/deployment.yaml +++ b/deploy/charts/litellm/templates/deployment.yaml @@ -142,6 +142,17 @@ spec: secretKeyRef: name: {{ include "litellm.fullname" . }}-masterkey key: masterkey + {{- if .Values.redis.enabled }} + - name: REDIS_HOST + value: {{ template "litellm.redis.serviceName" . }} + - name: REDIS_PORT + value: {{ if .Values.redis.sentinel.enabled }}{{ .Values.redis.sentinel.service.ports.sentinel }}{{ else }}{{ .Values.redis.master.service.ports.redis}}{{ end }} + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "redis.secretName" . }} + key: {{include "redis.secretPasswordKey" . }} + {{- end }} envFrom: {{- range .Values.environmentSecrets }} - secretRef: diff --git a/deploy/charts/litellm/values.yaml b/deploy/charts/litellm/values.yaml index 1b83fe801a4..9b697b01311 100644 --- a/deploy/charts/litellm/values.yaml +++ b/deploy/charts/litellm/values.yaml @@ -166,3 +166,9 @@ postgresql: # existingSecret: "" # secretKeys: # userPasswordKey: password + +# requires cache: true in config file +# either enable this or pass a secret for REDIS_HOST, REDIS_PORT, REDIS_PASSWORD or REDIS_URL +# with cache: true to use existing redis instance +redis: + enabled: false From b3646f6644efaa6dc8ec851e035069833797f954 Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Sun, 10 Mar 2024 02:37:10 +0530 Subject: [PATCH 2/4] fix: redis context --- deploy/charts/litellm/Chart.lock | 9 ++++++--- deploy/charts/litellm/templates/deployment.yaml | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/deploy/charts/litellm/Chart.lock b/deploy/charts/litellm/Chart.lock index 7b6ed69d9ad..f13578d8d35 100644 --- a/deploy/charts/litellm/Chart.lock +++ b/deploy/charts/litellm/Chart.lock @@ -1,6 +1,9 @@ dependencies: - name: postgresql repository: oci://registry-1.docker.io/bitnamicharts - version: 13.3.1 -digest: sha256:f5c129150f0d38dd06752ab37f3c8e143d7c14d30379af058767bcd9f4ba83dd -generated: "2024-01-19T11:32:56.694808861+11:00" + version: 14.3.1 +- name: redis + repository: oci://registry-1.docker.io/bitnamicharts + version: 18.19.1 +digest: sha256:8660fe6287f9941d08c0902f3f13731079b8cecd2a5da2fbc54e5b7aae4a6f62 +generated: "2024-03-10T02:28:52.275022+05:30" diff --git a/deploy/charts/litellm/templates/deployment.yaml b/deploy/charts/litellm/templates/deployment.yaml index bc2a0bd090a..42cf84935af 100644 --- a/deploy/charts/litellm/templates/deployment.yaml +++ b/deploy/charts/litellm/templates/deployment.yaml @@ -150,8 +150,8 @@ spec: - name: REDIS_PASSWORD valueFrom: secretKeyRef: - name: {{ include "redis.secretName" . }} - key: {{include "redis.secretPasswordKey" . }} + name: {{ include "redis.secretName" .Subcharts.redis }} + key: {{include "redis.secretPasswordKey" .Subcharts.redis }} {{- end }} envFrom: {{- range .Values.environmentSecrets }} From eea803cae44ab34a90075042f468b09512fe1014 Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Sun, 10 Mar 2024 03:06:17 +0530 Subject: [PATCH 3/4] chore: better handling redis deployment architecture and connection --- deploy/charts/litellm/templates/_helpers.tpl | 16 +++++++++++++++- deploy/charts/litellm/templates/deployment.yaml | 4 ++-- deploy/charts/litellm/values.yaml | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/deploy/charts/litellm/templates/_helpers.tpl b/deploy/charts/litellm/templates/_helpers.tpl index fa563fadc8f..a1eda28c679 100644 --- a/deploy/charts/litellm/templates/_helpers.tpl +++ b/deploy/charts/litellm/templates/_helpers.tpl @@ -65,6 +65,20 @@ Create the name of the service account to use Get redis service name */}} {{- define "litellm.redis.serviceName" -}} -{{- printf "%s-headless" (default "redis" .Values.redis.nameOverride | trunc 63 | trimSuffix "-") -}} +{{- if and (eq .Values.redis.architecture "standalone") .Values.redis.sentinel.enabled -}} +{{- printf "%s-%s" .Release.Name (default "redis" .Values.redis.nameOverride | trunc 63 | trimSuffix "-") -}} +{{- else -}} +{{- printf "%s-%s-master" .Release.Name (default "redis" .Values.redis.nameOverride | trunc 63 | trimSuffix "-") -}} +{{- end -}} {{- end -}} +{{/* +Get redis service port +*/}} +{{- define "litellm.redis.port" -}} +{{- if .Values.redis.sentinel.enabled -}} +{{ .Values.redis.sentinel.service.ports.sentinel }} +{{- else -}} +{{ .Values.redis.master.service.ports.redis }} +{{- end -}} +{{- end -}} diff --git a/deploy/charts/litellm/templates/deployment.yaml b/deploy/charts/litellm/templates/deployment.yaml index 42cf84935af..736f35680e5 100644 --- a/deploy/charts/litellm/templates/deployment.yaml +++ b/deploy/charts/litellm/templates/deployment.yaml @@ -144,9 +144,9 @@ spec: key: masterkey {{- if .Values.redis.enabled }} - name: REDIS_HOST - value: {{ template "litellm.redis.serviceName" . }} + value: {{ include "litellm.redis.serviceName" . }} - name: REDIS_PORT - value: {{ if .Values.redis.sentinel.enabled }}{{ .Values.redis.sentinel.service.ports.sentinel }}{{ else }}{{ .Values.redis.master.service.ports.redis}}{{ end }} + value: {{ include "litellm.redis.port" . | quote }} - name: REDIS_PASSWORD valueFrom: secretKeyRef: diff --git a/deploy/charts/litellm/values.yaml b/deploy/charts/litellm/values.yaml index 9b697b01311..1d8f9ba3e97 100644 --- a/deploy/charts/litellm/values.yaml +++ b/deploy/charts/litellm/values.yaml @@ -87,6 +87,8 @@ proxy_config: api_key: eXaMpLeOnLy general_settings: master_key: os.environ/PROXY_MASTER_KEY +# litellm_settings: +# cache: true resources: {} # We usually recommend not to specify default resources and to leave this as a conscious @@ -172,3 +174,4 @@ postgresql: # with cache: true to use existing redis instance redis: enabled: false + architecture: replication From 5777aeb36e679c26b6c3dca39405601a321468e9 Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Sun, 10 Mar 2024 03:09:00 +0530 Subject: [PATCH 4/4] chore: set simpler redis architecture as default --- deploy/charts/litellm/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/charts/litellm/values.yaml b/deploy/charts/litellm/values.yaml index 1d8f9ba3e97..3ae089636c0 100644 --- a/deploy/charts/litellm/values.yaml +++ b/deploy/charts/litellm/values.yaml @@ -174,4 +174,4 @@ postgresql: # with cache: true to use existing redis instance redis: enabled: false - architecture: replication + architecture: standalone