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