Skip to content

Commit

Permalink
kubernetes: update
Browse files Browse the repository at this point in the history
  • Loading branch information
phymbert committed Apr 8, 2024
1 parent fa7cd05 commit 39efb7a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 68 deletions.
2 changes: 1 addition & 1 deletion examples/kubernetes/llama-cpp/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: llama-cpp
description: llama.cpp Helm chart for Kubernetes
type: application
version: 0.0.1
appVersion: "cbbd1efa06f8c09f9dff58ff9d9af509cc4c152b"
appVersion: "77d1ac7e00bf049b9f2bba1b5a310a78318c49c4"
74 changes: 15 additions & 59 deletions examples/kubernetes/llama-cpp/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,26 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: wait-model
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ .Values.images.downloader.repository }}:{{ .Values.images.downloader.name }}-{{ .Values.images.downloader.tag }}
env:
- name: MODEL_PATH
value: {{ .Values.model.path }}
- name: MODEL_FILE
value: {{ regexReplaceAll "(.*/)?([^/]+).gguf" .Values.model.file "${2}.gguf" }}
- name: MODEL_SHA256
value: {{ .Values.model.sha256 }}
- name: MODEL_DOWNLOAD_REPO
value: {{ .Values.model.repo }}
- name: MODEL_DOWNLOAD_FILE
value: {{ .Values.model.file }}
command:
- sh
- -c
args:
- >
set -eux;
while ! echo "${MODEL_SHA256} *${MODEL_PATH}/${MODEL_FILE}" | sha256sum -c - ; do
echo "waiting for model file${MODEL_PATH}/${MODEL_FILE}=${MODEL_SHA256}";
sleep 1;
done
volumeMounts:
- mountPath: {{ .Values.model.path }}
name: models
readOnly: true
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.images.server.repository }}:{{ .Values.images.server.name }}-{{ .Values.images.server.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.images.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
command:
- {{ .Values.server.command }}
args:
Expand Down Expand Up @@ -105,21 +87,6 @@ spec:
- name: http
containerPort: {{ .Values.server.port }}
protocol: TCP
startupProbe:
httpGet:
path: /health
port: {{ .Values.server.port }}

livenessProbe:
httpGet:
path: /health
port: {{ .Values.server.port }}

readinessProbe:
httpGet:
path: /health?fail_on_no_slot
port: {{ .Values.server.port }}

{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
Expand All @@ -132,15 +99,4 @@ spec:
- name: models
persistentVolumeClaim:
claimName: {{ include "server.llama.cpp.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
readOnly: true
21 changes: 17 additions & 4 deletions examples/kubernetes/llama-cpp/templates/jobs.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: batch/v1
kind: Job
metadata:
name: download-model-{{ include "server.llama.cpp.fullname" . }}
name: {{ include "server.llama.cpp.fullname" . }}-download-model
labels:
{{- include "server.llama.cpp.labels" . | nindent 4 }}
spec:
template:
metadata:
name: download-model-{{ include "server.llama.cpp.fullname" . }}
name: {{ include "server.llama.cpp.fullname" . }}-download-model
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
Expand All @@ -22,7 +22,7 @@ spec:
- name: {{ include "server.llama.cpp.fullname" . }}-download-model
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ .Values.images.downloader.repository }}:{{ .Values.images.downloader.name }}-{{ .Values.images.downloader.tag }}
image: {{ .Values.images.downloader.repository }}:{{ .Values.images.downloader.name }}{{if .Values.images.downloader.tag }}-{{end}}{{ .Values.images.downloader.tag }}
env:
- name: MODEL_PATH
value: {{ .Values.model.path }}
Expand Down Expand Up @@ -50,4 +50,17 @@ spec:
volumes:
- name: models
persistentVolumeClaim:
claimName: {{ include "server.llama.cpp.fullname" . }}
claimName: {{ include "server.llama.cpp.fullname" . }}
readOnly: false
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
6 changes: 3 additions & 3 deletions examples/kubernetes/llama-cpp/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ metadata:
name: {{ include "server.llama.cpp.fullname" . }}
labels:
{{- include "server.llama.cpp.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: "keep"
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.model.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (not empty .Values.persistence.storageClass) }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
storageClassName: {{ .Values.persistence.storageClass }}
{{- end }}
2 changes: 1 addition & 1 deletion examples/kubernetes/llama-cpp/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
targetPort: {{ .Values.server.port }}
protocol: TCP
name: http
selector:
Expand Down

0 comments on commit 39efb7a

Please sign in to comment.