Skip to content

Commit 274accb

Browse files
authored
Merge pull request #54 from jimmykarily/fix-values-example
Various fixes (default values, pvcs and others)
2 parents 6d83a1f + 202b5cd commit 274accb

File tree

7 files changed

+17
-110
lines changed

7 files changed

+17
-110
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ cat <<EOF > values.yaml
1313
replicaCount: 1
1414
1515
deployment:
16-
image: quay.io/go-skynet/local-ai:latest
16+
image: quay.io/go-skynet/local-ai
17+
tag: latest
1718
env:
1819
threads: 4
1920
context_size: 512

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.3.1
6+
version: 3.4.0

charts/local-ai/templates/_pvc.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ metadata:
1919
annotations: {{- toYaml . | nindent 4 -}}
2020
{{- end }}
2121
spec:
22-
accessModes:
23-
- {{ required "accessMode is required for PVC" $pvcObject.accessMode | quote }}
22+
{{- with required "accessModes is required for PVC" $pvcObject.accessModes }}
23+
accessModes: {{- toYaml . | nindent 4 -}}
24+
{{- end }}
2425
resources:
2526
requests:
2627
storage: {{ required "size is required for PVC" $pvcObject.size | quote }}

charts/local-ai/templates/deployment.yaml

-87
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# yamllint disable rule:line-length
2-
{{- $urls := "" -}}
32
{{- $rootPersistence := .Values.persistence }}
4-
{{- range $idx, $model := .Values.models.list }}
5-
{{- $urls = printf "%s%s %s," $urls $model.url ($model.basicAuth | default "") }}
6-
{{- end }}
73

84
apiVersion: apps/v1
95
kind: Deployment
@@ -121,89 +117,6 @@ spec:
121117
{{- end }}
122118
{{- end }}
123119
{{- end }}
124-
- name: download-model
125-
image: {{ .Values.deployment.download_model.image }}
126-
imagePullPolicy: {{ .Values.deployment.pullPolicy }}
127-
command: ["/bin/sh", "-c"]
128-
args:
129-
- |
130-
MODEL_DIR={{ .Values.deployment.modelsPath }}
131-
FORCE_DOWNLOAD={{ .Values.models.forceDownload }}
132-
URLS="{{ $urls }}"
133-
LOCK_DIR=/tmp/model-download-locks
134-
135-
mkdir -p "$MODEL_DIR"
136-
mkdir -p "$LOCK_DIR"
137-
mkdir -p "/tmp/generated/images"
138-
mkdir -p "/tmp/generated/audio"
139-
rm -rf "/models/lost+found"
140-
141-
validate_url() {
142-
local url=$1
143-
local regex='^(https?|ftp)://[a-zA-Z0-9.-]+(:[a-zA-Z0-9.-]+)?(/[a-zA-Z0-9.-]*)*$'
144-
if [[ $url =~ $regex ]]; then
145-
return 0 # URL is valid
146-
else
147-
return 1 # URL is invalid
148-
fi
149-
}
150-
151-
echo "List of URLs:"
152-
echo "$URLS"
153-
154-
echo "$URLS" | awk -F, '{for (i=1; i<=NF; i++) print $i}' | while read -r line; do
155-
url=$(echo "$line" | awk '{print $1}')
156-
auth=$(echo "$line" | awk '{print $2}')
157-
full_filename=$(basename "$url" .bin)
158-
short_filename=$(echo "$full_filename" | cut -c1-20)
159-
hash=$(echo "$full_filename" | sha256sum | cut -c1-12)
160-
filename="${short_filename}_${hash}"
161-
lockfile="$LOCK_DIR/$filename.lock"
162-
163-
# Validate URL
164-
if ! validate_url "$url"; then
165-
echo "Invalid URL: $url. Skipping download."
166-
continue
167-
fi
168-
169-
if [ -e "$MODEL_DIR/$filename" ]; then
170-
echo "File $filename already exists. Skipping download."
171-
continue
172-
fi
173-
174-
if [ -e "$lockfile" ]; then
175-
echo "Another pod is downloading $filename. Waiting for download to complete."
176-
while [ -e "$lockfile" ]; do sleep 1; done
177-
continue
178-
fi
179-
180-
touch "$lockfile"
181-
182-
echo "Downloading $filename"
183-
if [ -n "$auth" ]; then
184-
wget --header "Authorization: Basic $auth" "$url" -O "$MODEL_DIR/$filename"
185-
else
186-
wget "$url" -O "$MODEL_DIR/$filename"
187-
fi
188-
189-
if [ "$?" -ne 0 ]; then
190-
echo "Download failed."
191-
rm -f "$lockfile"
192-
exit 1
193-
else
194-
echo "Download completed."
195-
rm -f "$lockfile"
196-
fi
197-
done
198-
199-
volumeMounts:
200-
{{- range $key, $pvc := $rootPersistence }}
201-
{{- if $pvc.enabled }}
202-
- name: {{ $key }}
203-
mountPath: {{ $pvc.globalMount | default (print "/" $key) }}
204-
{{- end }}
205-
{{- end }}
206-
207120
containers:
208121
# Sidecar containers from values.yaml
209122
{{- range .Values.sidecarContainers }}

charts/local-ai/templates/pvcs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- range $key, $pvc := .Values.persistence -}}
22
{{- if $pvc.enabled -}}
3-
{{- $pvcObject := dict "name" (printf "%s-%s" (include "local-ai.fullname" $) $key) "accessMode" $pvc.accessModes "size" $pvc.size "storageClass" $pvc.storageClass "annotations" $pvc.annotations "labels" $pvc.labels -}}
3+
{{- $pvcObject := dict "name" (printf "%s-%s" (include "local-ai.fullname" $) $key) "accessModes" $pvc.accessModes "size" $pvc.size "storageClass" $pvc.storageClass "annotations" $pvc.annotations "labels" $pvc.labels -}}
44

55
{{- /* Include the PVC template */ -}}
66
{{- include "local-ai.pvc" (dict "rootContext" $ "object" $pvcObject) | nindent 0 -}}

charts/local-ai/templates/service.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ spec:
1818
{{- end }}
1919
ports:
2020
- protocol: TCP
21+
{{- if not (quote .Values.service.nodePort | empty) }}
22+
nodePort: {{ .Values.service.nodePort }}
23+
{{- end }}
2124
port: {{ .Values.service.port }}
2225
targetPort: 8080
2326
name: http

charts/local-ai/values.yaml

+7-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ replicaCount: 1
22

33
deployment:
44
image:
5-
repository: quay.io/go-skynet/local-ai # Example: "docker.io/myapp"
6-
tag: latest
5+
repository: quay.io/go-skynet/local-ai
6+
tag: latest # Use the appropriate tag. E.g. for cpu only: "latest-cpu"
77
env:
88
threads: 4
99
context_size: 512
@@ -17,9 +17,6 @@ deployment:
1717
# key: hf-token
1818

1919
modelsPath: "/models"
20-
download_model:
21-
# To use cloud provided (eg AWS) image, provide it like: 1234356789.dkr.ecr.us-REGION-X.amazonaws.com/busybox
22-
image: busybox
2320
prompt_templates:
2421
# To use cloud provided (eg AWS) image, provide it like: 1234356789.dkr.ecr.us-REGION-X.amazonaws.com/busybox
2522
image: busybox
@@ -75,17 +72,6 @@ promptTemplates:
7572
# {{.Input}}
7673
# ### Response:
7774

78-
# Models to download at runtime
79-
models:
80-
# Whether to force download models even if they already exist
81-
forceDownload: false
82-
83-
# The list of URLs to download models from
84-
# Note: the name of the file will be the name of the loaded model
85-
list:
86-
# - url: "https://gpt4all.io/models/ggml-gpt4all-j.bin"
87-
# basicAuth: base64EncodedCredentials
88-
8975
initContainers: []
9076
# Example:
9177
# - name: my-init-container
@@ -113,14 +99,16 @@ persistence:
11399
enabled: true
114100
annotations: {}
115101
storageClass: "" # Use default storage class
116-
accessModes: ReadWriteMany
102+
accessModes:
103+
- ReadWriteMany
117104
size: 10Gi
118105
globalMount: /models
119106
output:
120107
enabled: true
121108
annotations: {}
122109
storageClass: "" # Use default storage class
123-
accessModes: ReadWriteMany
110+
accessModes:
111+
- ReadWriteMany
124112
size: 5Gi
125113
globalMount: /tmp/generated
126114

@@ -129,6 +117,7 @@ service:
129117
# If deferring to an internal only load balancer
130118
# externalTrafficPolicy: Local
131119
port: 80
120+
nodePort:
132121
annotations: {}
133122
# If using an AWS load balancer, you'll need to override the default 60s load balancer idle timeout
134123
# service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "1200"

0 commit comments

Comments
 (0)