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