ollama-statefulset.yaml 2.67 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 }}
7
spec:
duhow's avatar
duhow committed
8
  serviceName: {{ include "ollama.name" . }}
9
10
11
  replicas: {{ .Values.ollama.replicaCount }}
  selector:
    matchLabels:
duhow's avatar
duhow committed
12
      {{- include "ollama.selectorLabels" . | nindent 6 }}
13
14
15
  template:
    metadata:
      labels:
16
        {{- include "ollama.labels" . | nindent 8 }}
17
18
    spec:
      containers:
duhow's avatar
duhow committed
19
      - name: {{ include "ollama.name" . }}
duhow's avatar
duhow committed
20
21
22
23
        {{- with .Values.ollama.image }}
        image: {{ .repository }}:{{ .tag }}
        imagePullPolicy: {{ .pullPolicy }}
        {{- end }}
duhow's avatar
duhow committed
24
        tty: true
25
        ports:
26
27
        - name: http
          containerPort: {{ .Values.ollama.service.containerPort }}
28
29
30
31
32
33
34
35
        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
36
        {{- end }}
duhow's avatar
duhow committed
37
38
        {{- with .Values.ollama.resources }}
        resources: {{- toYaml . | nindent 10 }}
39
        {{- end }}
40
        volumeMounts:
duhow's avatar
duhow committed
41
        - name: data
42
          mountPath: /root/.ollama
43
44
45
46
      {{- with .Values.ollama.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
duhow's avatar
duhow committed
47
      {{- with .Values.ollama.tolerations }}
48
      tolerations:
duhow's avatar
duhow committed
49
50
        {{- toYaml . | nindent 8 }}
      {{- end }}
duhow's avatar
duhow committed
51
52
53
54
55
56
57
58
59
60
      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) }}
        {}
61
62
  volumeClaimTemplates:
  - metadata:
duhow's avatar
duhow committed
63
64
65
66
67
68
69
      name: data
      labels:
        {{- include "ollama.selectorLabels" . | nindent 8 }}
      {{- with .Values.ollama.persistence.annotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
70
    spec:
duhow's avatar
duhow committed
71
72
73
74
      accessModes:
        {{- range .Values.ollama.persistence.accessModes }}
        - {{ . | quote }}
        {{- end }}
75
76
      resources:
        requests:
duhow's avatar
duhow committed
77
78
79
80
81
82
83
          storage: {{ .Values.ollama.persistence.size | quote }}
      storageClass: {{ .Values.ollama.persistence.storageClass }}
      {{- with .Values.ollama.persistence.selector }}
      selector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- end }}