Skip to content

Commit 41db537

Browse files
authored
Merge pull request #35 from go-skynet/revert-34-main
Revert "[v3.0.0] Major Version - PVC updates and sidecars"
2 parents 370e51f + 3dfb40d commit 41db537

File tree

7 files changed

+118
-244
lines changed

7 files changed

+118
-244
lines changed

Diff for: README.md

+21-54
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,11 @@ cat <<EOF > values.yaml
1313
replicaCount: 1
1414
1515
deployment:
16-
image:
17-
repository: quay.io/go-skynet/local-ai # Example: "docker.io/myapp"
18-
tag: latest
16+
image: quay.io/go-skynet/local-ai:latest
1917
env:
2018
threads: 4
2119
context_size: 512
2220
modelsPath: "/models"
23-
download_model:
24-
# To use cloud provided (eg AWS) image, provide it like: 1234356789.dkr.ecr.us-REGION-X.amazonaws.com/busybox
25-
image: busybox
26-
prompt_templates:
27-
# To use cloud provided (eg AWS) image, provide it like: 1234356789.dkr.ecr.us-REGION-X.amazonaws.com/busybox
28-
image: busybox
29-
pullPolicy: IfNotPresent
30-
imagePullSecrets: []
31-
# - name: secret-names
3221
3322
resources:
3423
{}
@@ -61,51 +50,31 @@ models:
6150
# The list of URLs to download models from
6251
# Note: the name of the file will be the name of the loaded model
6352
list:
64-
# - url: "https://gpt4all.io/models/ggml-gpt4all-j.bin"
53+
- url: "https://gpt4all.io/models/ggml-gpt4all-j.bin"
6554
# basicAuth: base64EncodedCredentials
6655
67-
initContainers: []
68-
# Example:
69-
# - name: my-init-container
70-
# image: my-init-image
71-
# imagePullPolicy: IfNotPresent
72-
# command: ["/bin/sh", "-c", "echo init"]
73-
# volumeMounts:
74-
# - name: my-volume
75-
# mountPath: /path/to/mount
76-
77-
sidecarContainers: []
78-
# Example:
79-
# - name: my-sidecar-container
80-
# image: my-sidecar-image
81-
# imagePullPolicy: IfNotPresent
82-
# ports:
83-
# - containerPort: 1234
84-
85-
# Persistent storage for models and prompt templates.
86-
# PVC and HostPath are mutually exclusive. If both are enabled,
87-
# PVC configuration takes precedence. If neither are enabled, ephemeral
88-
# storage is used.
89-
persistence:
90-
models:
91-
enabled: true
92-
annotations: {}
93-
storageClass: longhorn
94-
accessModes: ReadWriteMany
95-
size: 100Gi
96-
globalMount: /models
97-
images:
98-
enabled: true
99-
annotations: {}
100-
storageClass: longhorn
101-
accessModes: ReadWriteMany
102-
size: 5Gi
103-
globalMount: /tmp/generated/images
56+
# Persistent storage for models and prompt templates.
57+
# PVC and HostPath are mutually exclusive. If both are enabled,
58+
# PVC configuration takes precedence. If neither are enabled, ephemeral
59+
# storage is used.
60+
persistence:
61+
pvc:
62+
enabled: false
63+
size: 6Gi
64+
accessModes:
65+
- ReadWriteOnce
66+
67+
annotations: {}
68+
69+
# Optional
70+
storageClass: ~
71+
72+
hostPath:
73+
enabled: false
74+
path: "/models"
10475
10576
service:
10677
type: ClusterIP
107-
# If deferring to an internal only load balancer
108-
# externalTrafficPolicy: Local
10978
port: 80
11079
annotations: {}
11180
# If using an AWS load balancer, you'll need to override the default 60s load balancer idle timeout
@@ -134,8 +103,6 @@ tolerations: []
134103
135104
affinity: {}
136105
137-
138-
139106
```
140107
Install the LocalAI chart:
141108
```bash

Diff for: charts/local-ai/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ appVersion: 1.40
33
description: A Helm chart for deploying LocalAI to a Kubernetes cluster
44
name: local-ai
55
type: application
6-
version: 3.0.0
6+
version: 2.1.3

Diff for: charts/local-ai/templates/_pvc.yaml

-23
This file was deleted.

Diff for: charts/local-ai/templates/deployment.yaml

+50-121
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,11 @@ spec:
2727
checksum/config-prompt-templates: {{ include (print $.Template.BasePath "/configmap-prompt-templates.yaml") . | sha256sum }}
2828
{{- end }}
2929
spec:
30-
{{- with .Values.deployment.imagePullSecrets }}
30+
{{- with .Values.deployment.imagePullSecrets }}
3131
imagePullSecrets:
3232
{{- toYaml . | nindent 8 }}
33-
{{- end }}
33+
{{- end }}
3434
initContainers:
35-
# Additional initContainers from values.yaml
36-
{{- range .Values.initContainers }}
37-
- name: {{ .name }}
38-
image: {{ .image }}
39-
imagePullPolicy: {{ .imagePullPolicy }}
40-
command: {{ .command }}
41-
args: {{ .args | default list }}
42-
env:
43-
{{- toYaml .env | nindent 12 }}
44-
resources:
45-
{{- toYaml .resources | nindent 12 }}
46-
volumeMounts:
47-
{{- toYaml .volumeMounts | nindent 12 }}
48-
{{- range $key, $pvc := .Values.persistence }}
49-
{{- if $pvc.enabled }}
50-
- name: {{ $key }}
51-
mountPath: {{ $pvc.globalMount | default (print "/" $key) }}
52-
{{- end }}
53-
{{- end }}
54-
securityContext:
55-
{{- toYaml .securityContext | nindent 12 }}
56-
{{- end }}
5735
{{- if .Values.promptTemplates }}
5836
- name: prompt-templates
5937
image: {{ .Values.deployment.prompt_templates.image }}
@@ -65,12 +43,8 @@ spec:
6543
volumeMounts:
6644
- mountPath: /prompt-templates
6745
name: prompt-templates
68-
{{- range $key, $pvc := .Values.persistence }}
69-
{{- if $pvc.enabled }}
70-
- name: {{ $key }}
71-
mountPath: {{ $pvc.globalMount | default (print "/" $key) }}
72-
{{- end }}
73-
{{- end }}
46+
- mountPath: /models
47+
name: models
7448
{{- end }}
7549
- name: download-model
7650
image: {{ .Values.deployment.download_model.image }}
@@ -81,119 +55,74 @@ spec:
8155
MODEL_DIR={{ .Values.deployment.modelsPath }}
8256
FORCE_DOWNLOAD={{ .Values.models.forceDownload }}
8357
URLS="{{ $urls }}"
84-
LOCK_DIR=/tmp/model-download-locks
8558
8659
mkdir -p "$MODEL_DIR"
87-
mkdir -p "$LOCK_DIR"
88-
mkdir -p "/tmp/generated/images"
89-
mkdir -p "/tmp/generated/audio"
90-
rm -rf "/models/lost+found"
91-
9260
61+
# Split urls on commas
9362
echo "$URLS" | awk -F, '{for (i=1; i<=NF; i++) print $i}' | while read -r line; do
9463
url=$(echo "$line" | awk '{print $1}')
9564
auth=$(echo "$line" | awk '{print $2}')
96-
full_filename=$(basename "$url" .bin)
97-
short_filename=$(echo "$full_filename" | cut -c1-20)
98-
hash=$(echo "$full_filename" | sha256sum | cut -c1-12)
99-
filename="${short_filename}_${hash}"
100-
lockfile="$LOCK_DIR/$filename.lock"
10165
102-
if [ -e "$MODEL_DIR/$filename" ]; then
103-
echo "File $filename already exists. Skipping download."
104-
continue
105-
fi
66+
if [ -n "$url" ]; then
67+
filename=$(basename "$url" .bin)
10668
107-
if [ -e "$lockfile" ]; then
108-
echo "Another pod is downloading $filename. Waiting for download to complete."
109-
while [ -e "$lockfile" ]; do sleep 1; done
110-
continue
111-
fi
69+
if [ "$FORCE_DOWNLOAD" = false ] && [ -f "$MODEL_DIR/$filename" ]; then
70+
echo "File $filename already exists. Skipping download."
71+
continue
72+
fi
11273
113-
touch "$lockfile"
74+
rm -f "$MODEL_DIR/$filename"
11475
115-
echo "Downloading $filename"
116-
if [ -n "$auth" ]; then
117-
wget --header "Authorization: Basic $auth" "$url" -O "$MODEL_DIR/$filename"
118-
else
119-
wget "$url" -O "$MODEL_DIR/$filename"
120-
fi
76+
echo "Downloading $filename"
77+
78+
if [ -n "$auth" ]; then
79+
wget --header "Authorization: Basic $auth" "$url" -O "$MODEL_DIR/$filename"
80+
else
81+
wget "$url" -O "$MODEL_DIR/$filename"
82+
fi
12183
122-
if [ "$?" -ne 0 ]; then
123-
echo "Download failed."
124-
rm -f "$lockfile"
125-
exit 1
126-
else
127-
echo "Download completed."
128-
rm -f "$lockfile"
84+
if [ "$?" -ne 0 ]; then
85+
echo "Download failed."
86+
else
87+
echo "Download completed."
88+
fi
12989
fi
13090
done
13191
volumeMounts:
132-
{{- range $key, $pvc := .Values.persistence }}
133-
{{- if $pvc.enabled }}
134-
- name: {{ $key }}
135-
mountPath: {{ $pvc.globalMount | default (print "/" $key) }}
136-
{{- end }}
137-
{{- end }}
92+
- mountPath: {{ .Values.deployment.modelsPath }}
93+
name: models
13894
containers:
139-
# Sidecar containers from values.yaml
140-
{{- range .Values.sidecarContainers }}
141-
- name: {{ .name }}
142-
image: {{ .image }}
143-
imagePullPolicy: {{ .imagePullPolicy }}
144-
command: {{ .command }}
145-
args: {{ .args | default list }}
146-
env:
147-
{{- toYaml .env | nindent 12 }}
148-
ports:
149-
{{- toYaml .ports | nindent 12 }}
150-
resources:
151-
{{- toYaml .resources | nindent 12 }}
152-
volumeMounts:
153-
{{- toYaml .volumeMounts | nindent 12 }}
154-
{{- range $key, $pvc := .Values.persistence }}
155-
{{- if $pvc.enabled }}
156-
- name: {{ $key }}
157-
mountPath: {{ $pvc.globalMount | default (print "/" $key) }}
158-
{{- end }}
159-
{{- end }}
160-
livenessProbe:
161-
{{- toYaml .livenessProbe | nindent 12 }}
162-
readinessProbe:
163-
{{- toYaml .readinessProbe | nindent 12 }}
164-
securityContext:
165-
{{- toYaml .securityContext | nindent 12 }}
166-
{{- end }}
16795
- name: {{ template "local-ai.fullname" . }}
168-
image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}"
96+
image: {{ .Values.deployment.image }}
16997
imagePullPolicy: {{ .Values.deployment.pullPolicy }}
17098
resources:
17199
{{- toYaml .Values.resources | nindent 12 }}
172100
env:
173-
{{- range $key, $value := .Values.deployment.env }}
174-
- name: {{ $key | upper }}
175-
value: {{ quote $value }}
176-
{{- end }}
177-
- name: MODELS_PATH
178-
value: {{ .Values.deployment.modelsPath }}
101+
{{- range $key, $value := .Values.deployment.env }}
102+
- name: {{ $key | upper }}
103+
value: {{ quote $value }}
104+
{{- end }}
105+
- name: MODELS_PATH
106+
value: {{ .Values.deployment.modelsPath }}
179107
volumeMounts:
180-
{{- range $key, $pvc := .Values.persistence }}
181-
{{- if $pvc.enabled }}
182-
- name: {{ $key }}
183-
mountPath: {{ $pvc.globalMount | default (print "/" $key) }}
184-
{{- end }}
185-
{{- end }}
108+
- mountPath: {{ .Values.deployment.modelsPath }}
109+
name: models
186110
volumes:
187-
{{- range $key, $pvc := .Values.persistence }}
188-
{{- if $pvc.enabled }}
189-
- name: {{ $key }}
190-
persistentVolumeClaim:
191-
claimName: {{ printf "%s-%s" (include "local-ai.fullname" $) $key }}
192-
{{- end }}
193-
{{- end }}
194-
- name: prompt-templates
195-
configMap:
196-
name: {{ template "local-ai.fullname" . }}-prompt-templates
111+
{{- if .Values.models.persistence.pvc.enabled }}
112+
- name: models
113+
persistentVolumeClaim:
114+
claimName: {{ template "local-ai.fullname" . }}
115+
{{- else if .Values.models.persistence.hostPath.enabled }}
116+
- name: models
117+
hostPath:
118+
path: {{ .Values.models.persistence.hostPath.path }}
119+
{{- else }}
120+
- name: models
121+
emptyDir: {}
122+
{{- end }}
123+
- name: prompt-templates
124+
configMap:
125+
name: {{ template "local-ai.fullname" . }}-prompt-templates
197126
{{- with .Values.nodeSelector }}
198127
nodeSelector:
199128
{{- toYaml . | nindent 8 }}

Diff for: charts/local-ai/templates/pvc-models.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if .Values.models.persistence.pvc.enabled }}
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: {{ template "local-ai.fullname" . }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{ include "local-ai.labels" . | nindent 4 }}
8+
{{- with .Values.models.persistence.pvc.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- with .Values.models.persistence.pvc.storageClass }}
14+
storageClassName: {{ . }}
15+
{{- end }}
16+
{{- range .Values.models.persistence.pvc.accessModes }}
17+
accessModes:
18+
- {{ . | quote }}
19+
{{- end }}
20+
resources:
21+
requests:
22+
storage: {{ .Values.models.persistence.pvc.size | quote }}
23+
{{- end }}

Diff for: charts/local-ai/templates/pvcs.yaml

-5
This file was deleted.

0 commit comments

Comments
 (0)