From 34b7fd18c70d4a561d32639dbd702031980371d3 Mon Sep 17 00:00:00 2001 From: duhow Date: Mon, 19 Feb 2024 23:18:06 +0100 Subject: [PATCH] update storage definition --- .../helm/templates/ollama-statefulset.yaml | 35 ++++++++++++++++--- .../helm/templates/webui-deployment.yaml | 13 +++++-- kubernetes/helm/templates/webui-pvc.yaml | 16 ++++++++- kubernetes/helm/values.yaml | 14 +++++++- 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/kubernetes/helm/templates/ollama-statefulset.yaml b/kubernetes/helm/templates/ollama-statefulset.yaml index 393787163..38d4e8b48 100644 --- a/kubernetes/helm/templates/ollama-statefulset.yaml +++ b/kubernetes/helm/templates/ollama-statefulset.yaml @@ -21,6 +21,7 @@ spec: image: {{ .repository }}:{{ .tag }} imagePullPolicy: {{ .pullPolicy }} {{- end }} + tty: true ports: - name: http containerPort: {{ .Values.ollama.service.containerPort }} @@ -37,9 +38,8 @@ spec: resources: {{- toYaml . | nindent 10 }} {{- end }} volumeMounts: - - name: ollama-volume + - name: data mountPath: /root/.ollama - tty: true {{- with .Values.ollama.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -48,11 +48,36 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + volumes: + {{- if and .Values.ollama.persistence.enabled .Values.ollama.persistence.existingClaim }} + - name: data + persistentVolumeClaim: + claimName: {{ .Values.ollama.persistence.existingClaim }} + {{- else if not .Values.ollama.persistence.enabled }} + - name: data + emptyDir: {} + {{- else if and .Values.ollama.persistence.enabled (not .Values.ollama.persistence.existingClaim) }} + {} volumeClaimTemplates: - metadata: - name: ollama-volume + name: data + labels: + {{- include "ollama.selectorLabels" . | nindent 8 }} + {{- with .Values.ollama.persistence.annotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} spec: - accessModes: [ "ReadWriteOnce" ] + accessModes: + {{- range .Values.ollama.persistence.accessModes }} + - {{ . | quote }} + {{- end }} resources: requests: - storage: {{ .Values.ollama.persistence.size }} + storage: {{ .Values.ollama.persistence.size | quote }} + storageClass: {{ .Values.ollama.persistence.storageClass }} + {{- with .Values.ollama.persistence.selector }} + selector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} diff --git a/kubernetes/helm/templates/webui-deployment.yaml b/kubernetes/helm/templates/webui-deployment.yaml index 9250d315c..effac745d 100644 --- a/kubernetes/helm/templates/webui-deployment.yaml +++ b/kubernetes/helm/templates/webui-deployment.yaml @@ -27,7 +27,7 @@ spec: resources: {{- toYaml . | nindent 10 }} {{- end }} volumeMounts: - - name: webui-volume + - name: data mountPath: /app/backend/data env: - name: OLLAMA_API_BASE_URL @@ -38,6 +38,15 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: webui-volume + {{- if and .Values.webui.persistence.enabled .Values.webui.persistence.existingClaim }} + - name: data + persistentVolumeClaim: + claimName: {{ .Values.webui.persistence.existingClaim }} + {{- else if not .Values.webui.persistence.enabled }} + - name: data + emptyDir: {} + {{- else if and .Values.webui.persistence.enabled (not .Values.webui.persistence.existingClaim) }} + - name: data persistentVolumeClaim: claimName: {{ include "open-webui.name" . }} + {{- end }} diff --git a/kubernetes/helm/templates/webui-pvc.yaml b/kubernetes/helm/templates/webui-pvc.yaml index 3ceed2ca6..06b2cc4a4 100644 --- a/kubernetes/helm/templates/webui-pvc.yaml +++ b/kubernetes/helm/templates/webui-pvc.yaml @@ -1,11 +1,25 @@ +{{- if and .Values.webui.persistence.enabled (not .Values.webui.persistence.existingClaim) }} apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ include "open-webui.name" . }} labels: {{- include "open-webui.selectorLabels" . | nindent 4 }} + {{- with .Values.webui.persistence.annotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} spec: - accessModes: [ "ReadWriteOnce" ] + accessModes: + {{- range .Values.webui.persistence.accessModes }} + - {{ . | quote }} + {{- end }} resources: requests: storage: {{ .Values.webui.persistence.size }} + storageClass: {{ .Values.webui.persistence.storageClass }} + {{- with .Values.webui.persistence.selector }} + selector: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/kubernetes/helm/values.yaml b/kubernetes/helm/values.yaml index 60234bb35..41d430594 100644 --- a/kubernetes/helm/values.yaml +++ b/kubernetes/helm/values.yaml @@ -8,6 +8,11 @@ ollama: persistence: enabled: true size: 30Gi + accessModes: + - ReadWriteOnce + storageClass: "" + selector: {} + annotations: {} nodeSelector: {} tolerations: - key: nvidia.com/gpu @@ -18,6 +23,7 @@ ollama: port: 80 containerPort: 11434 gpu: + # -- Enable additional ENV values to help Ollama discover GPU usage enabled: false webui: @@ -35,7 +41,13 @@ webui: host: "" persistence: enabled: true - size: 2Gi + size: 30Gi + # -- If using multiple replicas, you must update accessModes to ReadWriteMany + accessModes: + - ReadWriteOnce + storageClass: "" + selector: {} + annotations: {} nodeSelector: {} tolerations: [] service: