ollama-statefulset.yaml 2.89 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
26
    spec:
      containers:
duhow's avatar
duhow committed
27
      - name: {{ include "ollama.name" . }}
duhow's avatar
duhow committed
28
29
30
31
        {{- with .Values.ollama.image }}
        image: {{ .repository }}:{{ .tag }}
        imagePullPolicy: {{ .pullPolicy }}
        {{- end }}
duhow's avatar
duhow committed
32
        tty: true
33
        ports:
34
35
        - name: http
          containerPort: {{ .Values.ollama.service.containerPort }}
36
37
38
39
40
41
42
43
        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
44
        {{- end }}
duhow's avatar
duhow committed
45
46
        {{- with .Values.ollama.resources }}
        resources: {{- toYaml . | nindent 10 }}
47
        {{- end }}
48
        volumeMounts:
duhow's avatar
duhow committed
49
        - name: data
50
          mountPath: /root/.ollama
51
52
53
54
      {{- with .Values.ollama.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
duhow's avatar
duhow committed
55
      {{- with .Values.ollama.tolerations }}
56
      tolerations:
duhow's avatar
duhow committed
57
58
        {{- toYaml . | nindent 8 }}
      {{- end }}
duhow's avatar
duhow committed
59
60
61
62
63
64
65
66
67
68
      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) }}
        {}
69
70
  volumeClaimTemplates:
  - metadata:
duhow's avatar
duhow committed
71
72
73
74
75
76
77
      name: data
      labels:
        {{- include "ollama.selectorLabels" . | nindent 8 }}
      {{- with .Values.ollama.persistence.annotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
78
    spec:
duhow's avatar
duhow committed
79
80
81
82
      accessModes:
        {{- range .Values.ollama.persistence.accessModes }}
        - {{ . | quote }}
        {{- end }}
83
84
      resources:
        requests:
duhow's avatar
duhow committed
85
86
87
88
89
90
91
          storage: {{ .Values.ollama.persistence.size | quote }}
      storageClass: {{ .Values.ollama.persistence.storageClass }}
      {{- with .Values.ollama.persistence.selector }}
      selector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- end }}