From cbaada1410bbfb6caa0f4b5726b30a499ed30616 Mon Sep 17 00:00:00 2001 From: duhow Date: Mon, 19 Feb 2024 21:58:25 +0100 Subject: [PATCH] add define names --- kubernetes/helm/templates/_helpers.tpl | 7 +++++++ kubernetes/helm/templates/ollama-service.yaml | 2 +- kubernetes/helm/templates/ollama-statefulset.yaml | 4 ++-- kubernetes/helm/templates/webui-deployment.yaml | 8 ++++---- kubernetes/helm/templates/webui-ingress.yaml | 2 +- kubernetes/helm/templates/webui-pvc.yaml | 2 +- kubernetes/helm/templates/webui-service.yaml | 2 +- 7 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 kubernetes/helm/templates/_helpers.tpl diff --git a/kubernetes/helm/templates/_helpers.tpl b/kubernetes/helm/templates/_helpers.tpl new file mode 100644 index 000000000..16a6f947b --- /dev/null +++ b/kubernetes/helm/templates/_helpers.tpl @@ -0,0 +1,7 @@ +{{- define "open-webui.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end -}} + +{{- define "ollama.name" -}} +ollama +{{- end -}} diff --git a/kubernetes/helm/templates/ollama-service.yaml b/kubernetes/helm/templates/ollama-service.yaml index a993b6189..a8459b52f 100644 --- a/kubernetes/helm/templates/ollama-service.yaml +++ b/kubernetes/helm/templates/ollama-service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: ollama-service + name: {{ include "ollama.name" . }} spec: type: {{ .Values.ollama.service.type }} selector: diff --git a/kubernetes/helm/templates/ollama-statefulset.yaml b/kubernetes/helm/templates/ollama-statefulset.yaml index 76b1988f9..dfbf5ba4d 100644 --- a/kubernetes/helm/templates/ollama-statefulset.yaml +++ b/kubernetes/helm/templates/ollama-statefulset.yaml @@ -1,9 +1,9 @@ apiVersion: apps/v1 kind: StatefulSet metadata: - name: ollama + name: {{ include "ollama.name" . }} spec: - serviceName: "ollama" + serviceName: {{ include "ollama.name" . }} replicas: {{ .Values.ollama.replicaCount }} selector: matchLabels: diff --git a/kubernetes/helm/templates/webui-deployment.yaml b/kubernetes/helm/templates/webui-deployment.yaml index af42cecab..e62421298 100644 --- a/kubernetes/helm/templates/webui-deployment.yaml +++ b/kubernetes/helm/templates/webui-deployment.yaml @@ -1,7 +1,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: open-webui-deployment + name: {{ include "open-webui.name" . }} spec: replicas: 1 selector: @@ -13,7 +13,7 @@ spec: app: open-webui spec: containers: - - name: open-webui + - name: {{ .Chart.Name }} image: {{ .Values.webui.image }} ports: - containerPort: 8080 @@ -25,7 +25,7 @@ spec: mountPath: /app/backend/data env: - name: OLLAMA_API_BASE_URL - value: "http://ollama-service.{{ .Values.namespace }}.svc.cluster.local:{{ .Values.ollama.servicePort }}/api" + value: {{ printf "http://%s.%s.svc.cluster.local:%s/api" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.servicePort) | quote }} tty: true {{- with .Values.webui.nodeSelector }} nodeSelector: @@ -34,4 +34,4 @@ spec: volumes: - name: webui-volume persistentVolumeClaim: - claimName: open-webui-pvc + claimName: {{ include "open-webui.name" . }} diff --git a/kubernetes/helm/templates/webui-ingress.yaml b/kubernetes/helm/templates/webui-ingress.yaml index 28b90dc47..18fcd6cce 100644 --- a/kubernetes/helm/templates/webui-ingress.yaml +++ b/kubernetes/helm/templates/webui-ingress.yaml @@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: open-webui-ingress + name: {{ include "open-webui.name" . }} {{- if .Values.webui.ingress.annotations }} annotations: {{ toYaml .Values.webui.ingress.annotations | trimSuffix "\n" | indent 4 }} diff --git a/kubernetes/helm/templates/webui-pvc.yaml b/kubernetes/helm/templates/webui-pvc.yaml index 0db77c677..2b8d7d1cb 100644 --- a/kubernetes/helm/templates/webui-pvc.yaml +++ b/kubernetes/helm/templates/webui-pvc.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: open-webui-pvc + name: {{ include "open-webui.name" . }} labels: app: open-webui spec: diff --git a/kubernetes/helm/templates/webui-service.yaml b/kubernetes/helm/templates/webui-service.yaml index 8a96bd152..7ecf796d1 100644 --- a/kubernetes/helm/templates/webui-service.yaml +++ b/kubernetes/helm/templates/webui-service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: open-webui-service + name: {{ include "open-webui.name" . }} spec: type: {{ .Values.webui.service.type }} # Default: NodePort # Use LoadBalancer if you're on a cloud that supports it selector: