|
| 1 | +{{- if not .Values.ollama.externalHost }} |
| 2 | +apiVersion: apps/v1 |
| 3 | +kind: StatefulSet |
| 4 | +metadata: |
| 5 | + name: {{ include "ollama.name" . }} |
| 6 | + labels: |
| 7 | + {{- include "ollama.labels" . | nindent 4 }} |
| 8 | + {{- with .Values.ollama.annotations }} |
| 9 | + annotations: |
| 10 | + {{- toYaml . | nindent 4 }} |
| 11 | + {{- end }} |
| 12 | +spec: |
| 13 | + serviceName: {{ include "ollama.name" . }} |
| 14 | + replicas: {{ .Values.ollama.replicaCount }} |
| 15 | + selector: |
| 16 | + matchLabels: |
| 17 | + {{- include "ollama.selectorLabels" . | nindent 6 }} |
| 18 | + template: |
| 19 | + metadata: |
| 20 | + labels: |
| 21 | + {{- include "ollama.labels" . | nindent 8 }} |
| 22 | + {{- with .Values.ollama.podAnnotations }} |
| 23 | + annotations: |
| 24 | + {{- toYaml . | nindent 8 }} |
| 25 | + {{- end }} |
| 26 | + spec: |
| 27 | + enableServiceLinks: false |
| 28 | + automountServiceAccountToken: false |
| 29 | + {{- with .Values.ollama.runtimeClassName }} |
| 30 | + runtimeClassName: {{ . }} |
| 31 | + {{- end }} |
| 32 | + containers: |
| 33 | + - name: {{ include "ollama.name" . }} |
| 34 | + {{- with .Values.ollama.image }} |
| 35 | + image: {{ .repository }}:{{ .tag }} |
| 36 | + imagePullPolicy: {{ .pullPolicy }} |
| 37 | + {{- end }} |
| 38 | + tty: true |
| 39 | + ports: |
| 40 | + - name: http |
| 41 | + containerPort: {{ .Values.ollama.service.containerPort }} |
| 42 | + env: |
| 43 | + {{- if .Values.ollama.gpu.enabled }} |
| 44 | + - name: PATH |
| 45 | + value: /usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
| 46 | + - name: LD_LIBRARY_PATH |
| 47 | + value: /usr/local/nvidia/lib:/usr/local/nvidia/lib64 |
| 48 | + - name: NVIDIA_DRIVER_CAPABILITIES |
| 49 | + value: compute,utility |
| 50 | + {{- end }} |
| 51 | + {{- with .Values.ollama.resources }} |
| 52 | + resources: {{- toYaml . | nindent 10 }} |
| 53 | + {{- end }} |
| 54 | + volumeMounts: |
| 55 | + - name: data |
| 56 | + mountPath: /root/.ollama |
| 57 | + {{- with .Values.ollama.nodeSelector }} |
| 58 | + nodeSelector: |
| 59 | + {{- toYaml . | nindent 8 }} |
| 60 | + {{- end }} |
| 61 | + {{- with .Values.ollama.tolerations }} |
| 62 | + tolerations: |
| 63 | + {{- toYaml . | nindent 8 }} |
| 64 | + {{- end }} |
| 65 | + volumes: |
| 66 | + {{- if and .Values.ollama.persistence.enabled .Values.ollama.persistence.existingClaim }} |
| 67 | + - name: data |
| 68 | + persistentVolumeClaim: |
| 69 | + claimName: {{ .Values.ollama.persistence.existingClaim }} |
| 70 | + {{- else if not .Values.ollama.persistence.enabled }} |
| 71 | + - name: data |
| 72 | + emptyDir: {} |
| 73 | + {{- else if and .Values.ollama.persistence.enabled (not .Values.ollama.persistence.existingClaim) }} |
| 74 | + [] |
| 75 | + volumeClaimTemplates: |
| 76 | + - metadata: |
| 77 | + name: data |
| 78 | + labels: |
| 79 | + {{- include "ollama.selectorLabels" . | nindent 8 }} |
| 80 | + {{- with .Values.ollama.persistence.annotations }} |
| 81 | + annotations: |
| 82 | + {{- toYaml . | nindent 8 }} |
| 83 | + {{- end }} |
| 84 | + spec: |
| 85 | + accessModes: |
| 86 | + {{- range .Values.ollama.persistence.accessModes }} |
| 87 | + - {{ . | quote }} |
| 88 | + {{- end }} |
| 89 | + resources: |
| 90 | + requests: |
| 91 | + storage: {{ .Values.ollama.persistence.size | quote }} |
| 92 | + storageClassName: {{ .Values.ollama.persistence.storageClass }} |
| 93 | + {{- with .Values.ollama.persistence.selector }} |
| 94 | + selector: |
| 95 | + {{- toYaml . | nindent 8 }} |
| 96 | + {{- end }} |
| 97 | + {{- end }} |
| 98 | +{{- end }} |
0 commit comments