From 18463d935e734383cf928b0215674cc896723f20 Mon Sep 17 00:00:00 2001 From: duhow Date: Mon, 19 Feb 2024 23:32:50 +0100 Subject: [PATCH] pod optimization and advanced settings --- kubernetes/helm/templates/_helpers.tpl | 4 ++++ kubernetes/helm/templates/ollama-statefulset.yaml | 5 +++++ kubernetes/helm/templates/webui-deployment.yaml | 4 +++- kubernetes/helm/templates/webui-ingress.yaml | 2 +- kubernetes/helm/values.yaml | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/kubernetes/helm/templates/_helpers.tpl b/kubernetes/helm/templates/_helpers.tpl index 0ed9ddea..0647a42a 100644 --- a/kubernetes/helm/templates/_helpers.tpl +++ b/kubernetes/helm/templates/_helpers.tpl @@ -6,6 +6,10 @@ ollama {{- end -}} +{{- define "ollama.url" -}} +{{- printf "http://%s.%s.svc.cluster.local:%d/api" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }} +{{- end }} + {{- define "chart.name" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} diff --git a/kubernetes/helm/templates/ollama-statefulset.yaml b/kubernetes/helm/templates/ollama-statefulset.yaml index da88de82..db7ffe45 100644 --- a/kubernetes/helm/templates/ollama-statefulset.yaml +++ b/kubernetes/helm/templates/ollama-statefulset.yaml @@ -23,6 +23,11 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + enableServiceLinks: false + automountServiceAccountToken: false + {{- with .Values.ollama.runtimeClassName }} + runtimeClassName: {{ . }} + {{- end }} containers: - name: {{ include "ollama.name" . }} {{- with .Values.ollama.image }} diff --git a/kubernetes/helm/templates/webui-deployment.yaml b/kubernetes/helm/templates/webui-deployment.yaml index 766cd188..4b6605e1 100644 --- a/kubernetes/helm/templates/webui-deployment.yaml +++ b/kubernetes/helm/templates/webui-deployment.yaml @@ -22,6 +22,8 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + enableServiceLinks: false + automountServiceAccountToken: false containers: - name: {{ .Chart.Name }} {{- with .Values.webui.image }} @@ -39,7 +41,7 @@ spec: mountPath: /app/backend/data env: - name: OLLAMA_API_BASE_URL - value: {{ printf "http://%s.%s.svc.cluster.local:%s/api" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.servicePort) | quote }} + value: {{ include "ollama.url" . | quote }} tty: true {{- with .Values.webui.nodeSelector }} nodeSelector: diff --git a/kubernetes/helm/templates/webui-ingress.yaml b/kubernetes/helm/templates/webui-ingress.yaml index 2c6b045f..4513b39d 100644 --- a/kubernetes/helm/templates/webui-ingress.yaml +++ b/kubernetes/helm/templates/webui-ingress.yaml @@ -20,5 +20,5 @@ spec: service: name: {{ include "open-webui.name" . }} port: - number: {{ .Values.webui.service.port }} + name: http {{- end }} diff --git a/kubernetes/helm/values.yaml b/kubernetes/helm/values.yaml index d7db1d66..fa8cca52 100644 --- a/kubernetes/helm/values.yaml +++ b/kubernetes/helm/values.yaml @@ -1,3 +1,5 @@ +nameOverride: "" + ollama: annotations: {} podAnnotations: {} @@ -16,6 +18,8 @@ ollama: selector: {} annotations: {} nodeSelector: {} + # -- If using a special runtime container such as nvidia, set it here. + runtimeClassName: "" tolerations: - key: nvidia.com/gpu operator: Exists