@@ -27,33 +27,11 @@ spec:
27
27
checksum/config-prompt-templates : {{ include (print $.Template.BasePath "/configmap-prompt-templates.yaml") . | sha256sum }}
28
28
{{- end }}
29
29
spec :
30
- {{- with .Values.deployment.imagePullSecrets }}
30
+ {{- with .Values.deployment.imagePullSecrets }}
31
31
imagePullSecrets :
32
32
{{- toYaml . | nindent 8 }}
33
- {{- end }}
33
+ {{- end }}
34
34
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 }}
57
35
{{- if .Values.promptTemplates }}
58
36
- name : prompt-templates
59
37
image : {{ .Values.deployment.prompt_templates.image }}
65
43
volumeMounts :
66
44
- mountPath : /prompt-templates
67
45
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
74
48
{{- end }}
75
49
- name : download-model
76
50
image : {{ .Values.deployment.download_model.image }}
@@ -81,119 +55,74 @@ spec:
81
55
MODEL_DIR={{ .Values.deployment.modelsPath }}
82
56
FORCE_DOWNLOAD={{ .Values.models.forceDownload }}
83
57
URLS="{{ $urls }}"
84
- LOCK_DIR=/tmp/model-download-locks
85
58
86
59
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
-
92
60
61
+ # Split urls on commas
93
62
echo "$URLS" | awk -F, '{for (i=1; i<=NF; i++) print $i}' | while read -r line; do
94
63
url=$(echo "$line" | awk '{print $1}')
95
64
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"
101
65
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)
106
68
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
112
73
113
- touch "$lockfile "
74
+ rm -f "$MODEL_DIR/$filename "
114
75
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
121
83
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
129
89
fi
130
90
done
131
91
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
138
94
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 }}
167
95
- name : {{ template "local-ai.fullname" . }}
168
- image : " {{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }} "
96
+ image : {{ .Values.deployment.image }}
169
97
imagePullPolicy : {{ .Values.deployment.pullPolicy }}
170
98
resources :
171
99
{{- toYaml .Values.resources | nindent 12 }}
172
100
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 }}
179
107
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
186
110
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
197
126
{{- with .Values.nodeSelector }}
198
127
nodeSelector :
199
128
{{- toYaml . | nindent 8 }}
0 commit comments