devzone 0.43.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/agent-local.sh +45 -0
- package/.devcontainer/agent-workspace.sh +2 -2
- package/.devcontainer/agent.sh +10 -10
- package/.devcontainer/argocd/services-hook.sh +39 -9
- package/.devcontainer/catalogue/mysql/mysql.sh +1 -1
- package/.devcontainer/devzone +15 -13
- package/.devcontainer/etat-json.sh +3 -3
- package/.devcontainer/gitlab/installation.sh +1 -1
- package/.devcontainer/help.sh +2 -0
- package/.devcontainer/llm/bench.sh +171 -0
- package/.devcontainer/llm/llm.sh +249 -0
- package/.devcontainer/llm/opencode.sh +56 -0
- package/.devcontainer/llm/presets.sh +43 -0
- package/.devcontainer/postgres/postgres.sh +1 -1
- package/.devcontainer/services-admin.sh +16 -8
- package/.devcontainer/versions.env +1 -1
- package/README.md +2 -0
- package/charts/devzone-llm/Chart.yaml +6 -0
- package/charts/devzone-llm/templates/bench-job.yaml +65 -0
- package/charts/devzone-llm/templates/deployment.yaml +113 -0
- package/charts/devzone-llm/templates/pvc.yaml +19 -0
- package/charts/devzone-llm/templates/service.yaml +18 -0
- package/charts/devzone-llm/values.yaml +72 -0
- package/manage/devzone +1 -1
- package/manage/scripts/check-utf8-vars.sh +67 -0
- package/manage/scripts/services-workspace.sh +18 -7
- package/package.json +1 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Module llm (#586): local code model (llama.cpp llama-server, CPU) in the
|
|
3
|
+
# cluster of the services, namespace devzone-llm, chart charts/devzone-llm.
|
|
4
|
+
# llm.sh install [--preset default|light] [--context CTX]
|
|
5
|
+
# llm.sh uninstall release removed, the volume llm-models is kept
|
|
6
|
+
# llm.sh status | relay-start | relay-stop | policy (ingress from devzone-workspace)
|
|
7
|
+
# llm.sh preset [--preset P] preset stored for the next install (Argo CD path)
|
|
8
|
+
# llm.sh apply on|off [...] what `devzone enable|disable llm` runs
|
|
9
|
+
# llm.sh delete-data [--yes] namespace and volume removed (the model is downloaded again)
|
|
10
|
+
# llm.sh bench [--apply] llama-bench Job and threads recommendation (bench.sh)
|
|
11
|
+
# First start = model download: LLM_ATTENTE (seconds, default 1800) is the wait.
|
|
12
|
+
# Relay LLM_PORT (default 8089); opencode provider: opencode.sh. bash 3.2 (macOS).
|
|
13
|
+
set -euo pipefail
|
|
14
|
+
|
|
15
|
+
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
16
|
+
RACINE="${DEVZONE_RACINE:-$(dirname "$(dirname "$ICI")")}"
|
|
17
|
+
# shellcheck disable=SC2034 # read by cluster.sh (sourced library)
|
|
18
|
+
ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
19
|
+
# shellcheck source=SCRIPTDIR/../cluster.sh
|
|
20
|
+
# shellcheck disable=SC1091
|
|
21
|
+
. "$ICI/../cluster.sh"
|
|
22
|
+
# shellcheck source=SCRIPTDIR/../chart-direct.sh
|
|
23
|
+
# shellcheck disable=SC1091
|
|
24
|
+
. "$ICI/../chart-direct.sh"
|
|
25
|
+
# shellcheck source=SCRIPTDIR/../isolement.sh
|
|
26
|
+
# shellcheck disable=SC1091
|
|
27
|
+
. "$ICI/../isolement.sh"
|
|
28
|
+
# shellcheck source=SCRIPTDIR/presets.sh
|
|
29
|
+
# shellcheck disable=SC1091
|
|
30
|
+
. "$ICI/presets.sh"
|
|
31
|
+
# shellcheck source=SCRIPTDIR/bench.sh
|
|
32
|
+
# shellcheck disable=SC1091
|
|
33
|
+
. "$ICI/bench.sh"
|
|
34
|
+
|
|
35
|
+
NS=devzone-llm
|
|
36
|
+
STATE_DIR="$RACINE/workspace/.llm"
|
|
37
|
+
LLM_PORT="${LLM_PORT:-8089}"
|
|
38
|
+
LLM_ATTENTE="${LLM_ATTENTE:-1800}"
|
|
39
|
+
LLM_SIZE="${LLM_SIZE:-8Gi}"
|
|
40
|
+
|
|
41
|
+
refuse() { echo "devzone: llm: $*" >&2; exit 2; }
|
|
42
|
+
|
|
43
|
+
k() { kubectl --context devzone -n "$NS" "$@"; }
|
|
44
|
+
|
|
45
|
+
installed() { compte_admin "$(compte_ctx)" get namespace "$NS" >/dev/null 2>&1; }
|
|
46
|
+
|
|
47
|
+
# Preset stored by the last install, "default" without one
|
|
48
|
+
preset_read() {
|
|
49
|
+
local p
|
|
50
|
+
p="$(cat "$STATE_DIR/preset" 2>/dev/null || true)"
|
|
51
|
+
llm_preset_name "$p" 2>/dev/null || echo default
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# --preset P and --context C of the arguments: PRESET and WANTED_CTX are set
|
|
55
|
+
parse_args() {
|
|
56
|
+
local want="" arg
|
|
57
|
+
PRESET=""
|
|
58
|
+
WANTED_CTX=""
|
|
59
|
+
for arg in "$@"; do
|
|
60
|
+
if [ -n "$want" ]; then
|
|
61
|
+
case "$want" in
|
|
62
|
+
preset) PRESET="$arg" ;;
|
|
63
|
+
context) WANTED_CTX="$arg" ;;
|
|
64
|
+
esac
|
|
65
|
+
want=""
|
|
66
|
+
continue
|
|
67
|
+
fi
|
|
68
|
+
case "$arg" in
|
|
69
|
+
--preset) want=preset ;;
|
|
70
|
+
--context) want=context ;;
|
|
71
|
+
*) refuse "unknown argument: $arg (devzone enable llm [--preset light] [--context CTX])" ;;
|
|
72
|
+
esac
|
|
73
|
+
done
|
|
74
|
+
[ -z "$want" ] || refuse "--$want needs a value"
|
|
75
|
+
if [ -n "$PRESET" ]; then
|
|
76
|
+
PRESET="$(llm_preset_name "$PRESET")" || refuse "unknown preset (default or light)"
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Stores the preset: the explicit one, else the one already stored
|
|
81
|
+
preset_store() {
|
|
82
|
+
parse_args "$@"
|
|
83
|
+
[ -n "$PRESET" ] || PRESET="$(preset_read)"
|
|
84
|
+
mkdir -p "$STATE_DIR"
|
|
85
|
+
printf '%s\n' "$PRESET" >"$STATE_DIR/preset"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Ingress from the workspace namespace (the pod of the workspace reaches
|
|
89
|
+
# llm:8080), next to the same-namespace rule of namespace_isoler
|
|
90
|
+
policy() {
|
|
91
|
+
kubectl --context devzone -n "$NS" apply -f - >/dev/null <<YAML
|
|
92
|
+
apiVersion: networking.k8s.io/v1
|
|
93
|
+
kind: NetworkPolicy
|
|
94
|
+
metadata:
|
|
95
|
+
name: devzone-llm-workspace
|
|
96
|
+
labels:
|
|
97
|
+
app.kubernetes.io/managed-by: devzone
|
|
98
|
+
spec:
|
|
99
|
+
podSelector: {}
|
|
100
|
+
ingress:
|
|
101
|
+
- from:
|
|
102
|
+
- namespaceSelector:
|
|
103
|
+
matchLabels:
|
|
104
|
+
kubernetes.io/metadata.name: devzone-workspace
|
|
105
|
+
YAML
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# Waits for the deployment, a progress line each minute (the model is
|
|
109
|
+
# downloaded on the first start)
|
|
110
|
+
wait_ready() {
|
|
111
|
+
local waited=0 step=60
|
|
112
|
+
echo "▶ Waiting for the model (first start: download, several minutes; timeout ${LLM_ATTENTE}s, LLM_ATTENTE)…"
|
|
113
|
+
while [ "$waited" -lt "$LLM_ATTENTE" ]; do
|
|
114
|
+
if k rollout status deployment/llm --timeout="${step}s" >/dev/null 2>&1; then
|
|
115
|
+
return 0
|
|
116
|
+
fi
|
|
117
|
+
waited=$((waited + step))
|
|
118
|
+
echo " … ${waited}s/${LLM_ATTENTE}s: model not ready yet"
|
|
119
|
+
done
|
|
120
|
+
echo "devzone: llm: not ready after ${LLM_ATTENTE}s: kubectl --context devzone -n $NS logs deploy/llm -c fetch-model" >&2
|
|
121
|
+
return 1
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
install() {
|
|
125
|
+
local ctx sets
|
|
126
|
+
local -a args
|
|
127
|
+
preset_store "$@"
|
|
128
|
+
ctx="$(cluster_lu)"
|
|
129
|
+
if [ -z "$ctx" ]; then
|
|
130
|
+
ctx="$(cluster_choisir "$WANTED_CTX")" || return 2
|
|
131
|
+
cluster_ecrire "$ctx"
|
|
132
|
+
fi
|
|
133
|
+
cluster_preparer "$ctx"
|
|
134
|
+
contexte_devzone_poser "$ctx" || { echo "devzone: llm: cannot set the devzone context on $ctx" >&2; return 1; }
|
|
135
|
+
echo "▶ Local model on the cluster $ctx (namespace $NS, preset $(preset_read))…"
|
|
136
|
+
compte_namespace "$ctx" "$NS"
|
|
137
|
+
namespace_isoler "$NS" >/dev/null
|
|
138
|
+
policy
|
|
139
|
+
sets="$(llm_preset_sets "$(preset_read)") size=$LLM_SIZE"
|
|
140
|
+
read -r -a args <<<"$sets"
|
|
141
|
+
chart_install llm "$NS" "${args[@]}" || return 1
|
|
142
|
+
wait_ready || return 1
|
|
143
|
+
relais_arreter llm
|
|
144
|
+
relais_lancer llm "$ctx" "$NS" svc/llm "$LLM_PORT:8080"
|
|
145
|
+
bash "$ICI/opencode.sh" set
|
|
146
|
+
echo "✔ Local model ready: http://llm.$NS.svc.cluster.local:8080/v1 (127.0.0.1:$LLM_PORT here)"
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
# The release leaves, the volume (model) and the namespace stay
|
|
150
|
+
uninstall() {
|
|
151
|
+
local ctx
|
|
152
|
+
ctx="$(cluster_lu)"
|
|
153
|
+
relais_arreter llm
|
|
154
|
+
bash "$ICI/opencode.sh" unset
|
|
155
|
+
if [ -n "$ctx" ] && installed; then
|
|
156
|
+
contexte_devzone_poser "$ctx" || true
|
|
157
|
+
helm --kube-context devzone uninstall llm -n "$NS" >/dev/null 2>&1 || true
|
|
158
|
+
echo "✔ llm removed from $ctx; volume llm-models kept (devzone llm delete-data removes it)"
|
|
159
|
+
fi
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
delete_data() {
|
|
163
|
+
local ctx yes="" answer
|
|
164
|
+
ctx="$(cluster_lu)"
|
|
165
|
+
[ "${1:-}" != --yes ] || yes=1
|
|
166
|
+
installed || { echo "devzone: llm: nothing to delete"; return 0; }
|
|
167
|
+
if [ -z "$yes" ]; then
|
|
168
|
+
cluster_interactif || refuse "no terminal: devzone llm delete-data --yes"
|
|
169
|
+
printf 'Delete the namespace %s and the downloaded model? [y/N] ' "$NS" >&2
|
|
170
|
+
read -r answer || answer=""
|
|
171
|
+
case "$answer" in y | Y | yes | o | O | oui) ;; *) echo "Aborted: nothing deleted."; return 0 ;; esac
|
|
172
|
+
fi
|
|
173
|
+
uninstall
|
|
174
|
+
compte_retirer "$ctx" "$NS" >/dev/null 2>&1 || true
|
|
175
|
+
compte_admin "$ctx" delete namespace "$NS" --wait=true >/dev/null
|
|
176
|
+
cluster_liberer "$ctx"
|
|
177
|
+
echo "✔ namespace $NS and model volume deleted"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
status() {
|
|
181
|
+
local ctx mem
|
|
182
|
+
ctx="$(cluster_lu)"
|
|
183
|
+
if [ -z "$ctx" ] || ! installed; then
|
|
184
|
+
echo "disabled"
|
|
185
|
+
return 0
|
|
186
|
+
fi
|
|
187
|
+
if [ "$(k get deployment llm -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" != 1 ]; then
|
|
188
|
+
echo "not ready on $ctx: starting (first download) or failed, devzone apply"
|
|
189
|
+
return 0
|
|
190
|
+
fi
|
|
191
|
+
mem="$(k get deployment llm -o jsonpath='{.spec.template.spec.containers[0].resources.limits.memory}' 2>/dev/null || true)"
|
|
192
|
+
if relais_actif llm; then
|
|
193
|
+
echo "ready on $ctx: $(llm_preset_file "$(preset_read)"), memory limit ${mem:-?}, reachable 127.0.0.1:$LLM_PORT"
|
|
194
|
+
else
|
|
195
|
+
echo "ready on $ctx: $(llm_preset_file "$(preset_read)"), memory limit ${mem:-?}, relay stopped: devzone apply"
|
|
196
|
+
fi
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
relay_start() {
|
|
200
|
+
local ctx
|
|
201
|
+
ctx="$(cluster_lu)"
|
|
202
|
+
[ -z "$ctx" ] || ! installed || relais_lancer llm "$ctx" "$NS" svc/llm "$LLM_PORT:8080"
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
# Writes llm=off in the state file (bad argument, no cluster)
|
|
206
|
+
state_off() {
|
|
207
|
+
[ -f "$ETAT" ] || return 0
|
|
208
|
+
grep -v '^llm=' "$ETAT" >"$ETAT.tmp" || true
|
|
209
|
+
echo "llm=off" >>"$ETAT.tmp"
|
|
210
|
+
mv "$ETAT.tmp" "$ETAT"
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
# What `devzone enable|disable llm` runs: on installs (or restarts the relay),
|
|
214
|
+
# off removes the release; a failure leaves a marker read by devzone status
|
|
215
|
+
apply() {
|
|
216
|
+
local action="${1:-}" current marker="$ETAT-echec-llm"
|
|
217
|
+
shift || true
|
|
218
|
+
if [ "$action" = on ]; then
|
|
219
|
+
current="$(status)"
|
|
220
|
+
if [[ "$current" == *"relay stopped"* ]]; then
|
|
221
|
+
relay_start
|
|
222
|
+
echo "devzone: llm: relay restarted"
|
|
223
|
+
elif [[ "$current" == "ready on"* ]]; then
|
|
224
|
+
bash "$ICI/opencode.sh" set && echo "devzone: llm already active, nothing to do."
|
|
225
|
+
elif ! bash "${BASH_SOURCE[0]}" install "$@"; then
|
|
226
|
+
state_off
|
|
227
|
+
echo llm >"$marker"
|
|
228
|
+
return 1
|
|
229
|
+
fi
|
|
230
|
+
rm -f "$marker"
|
|
231
|
+
else
|
|
232
|
+
uninstall
|
|
233
|
+
rm -f "$marker"
|
|
234
|
+
fi
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
case "${1:-}" in
|
|
238
|
+
install) install "${@:2}" ;;
|
|
239
|
+
uninstall) uninstall ;;
|
|
240
|
+
status) status ;;
|
|
241
|
+
preset) preset_store "${@:2}" ;;
|
|
242
|
+
policy) policy ;;
|
|
243
|
+
apply) apply "${@:2}" ;;
|
|
244
|
+
delete-data) delete_data "${2:-}" ;;
|
|
245
|
+
bench) bench "${@:2}" ;;
|
|
246
|
+
relay-start) relay_start ;;
|
|
247
|
+
relay-stop) relais_arreter llm ;;
|
|
248
|
+
*) echo "devzone llm: status | bench [--apply] | delete-data [--yes]" >&2; exit 1 ;;
|
|
249
|
+
esac
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# opencode provider of the local model (#586), in a file apart managed by devzone:
|
|
3
|
+
# opencode.sh set provider devzone-llm (model local) put in the config
|
|
4
|
+
# opencode.sh unset provider removed (the rest of the file is kept)
|
|
5
|
+
# opencode.sh url base URL of the model seen from here
|
|
6
|
+
# File: ~/.config/opencode/config.json. opencode (1.19) reads it on its own, for
|
|
7
|
+
# the interactive session and for `opencode run`, with no environment variable,
|
|
8
|
+
# before opencode.json(c) (devzone enable ia) and OPENCODE_CONFIG_CONTENT (devzone
|
|
9
|
+
# agent), which keep the priority; providers merge, nothing of ia is replaced.
|
|
10
|
+
# URL: cluster DNS in the Kubernetes workspace pod, the relay of the container
|
|
11
|
+
# (127.0.0.1:LLM_PORT) elsewhere. bash 3.2 (macOS).
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
FILE="$HOME/.config/opencode/config.json"
|
|
15
|
+
|
|
16
|
+
base_url() {
|
|
17
|
+
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
|
|
18
|
+
echo "http://llm.devzone-llm.svc.cluster.local:8080/v1"
|
|
19
|
+
else
|
|
20
|
+
echo "http://127.0.0.1:${LLM_PORT:-8089}/v1"
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# jq program $1 applied to the file (or {}), written back atomically
|
|
25
|
+
rewrite() {
|
|
26
|
+
local current="{}" out
|
|
27
|
+
[ ! -f "$FILE" ] || current="$(cat "$FILE")"
|
|
28
|
+
mkdir -p "$(dirname "$FILE")"
|
|
29
|
+
out="$(printf '%s' "$current" | jq --arg url "$(base_url)" "$1")" || {
|
|
30
|
+
echo "devzone: llm: $FILE is not valid JSON: provider not touched" >&2
|
|
31
|
+
return 1
|
|
32
|
+
}
|
|
33
|
+
# Nothing left but the schema: the file was ours, it goes
|
|
34
|
+
if [ "$(printf '%s' "$out" | jq -c 'del(."$schema") | length')" = 0 ] && [ "$1" != "$SET" ]; then
|
|
35
|
+
rm -f "$FILE"
|
|
36
|
+
else
|
|
37
|
+
printf '%s\n' "$out" >"$FILE.tmp" && mv "$FILE.tmp" "$FILE"
|
|
38
|
+
fi
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# shellcheck disable=SC2016 # jq programs, $url is a jq variable
|
|
42
|
+
SET='."$schema" = (."$schema" // "https://opencode.ai/config.json")
|
|
43
|
+
| .provider["devzone-llm"] = {npm: "@ai-sdk/openai-compatible", name: "devzone local model",
|
|
44
|
+
options: {baseURL: $url}, models: {local: {name: "Local code model"}}}'
|
|
45
|
+
# shellcheck disable=SC2016
|
|
46
|
+
UNSET='if .provider then del(.provider["devzone-llm"]) | (if .provider == {} then del(.provider) else . end) else . end'
|
|
47
|
+
|
|
48
|
+
case "${1:-}" in
|
|
49
|
+
set) rewrite "$SET" ;;
|
|
50
|
+
unset) [ ! -f "$FILE" ] || rewrite "$UNSET" ;;
|
|
51
|
+
url) base_url ;;
|
|
52
|
+
*)
|
|
53
|
+
echo "usage: opencode.sh set|unset|url" >&2
|
|
54
|
+
exit 1
|
|
55
|
+
;;
|
|
56
|
+
esac
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Presets of the local model (#586), sourced by llm.sh and argocd/services-hook.sh.
|
|
3
|
+
# The values are the ones documented in charts/devzone-llm/values.yaml: the
|
|
4
|
+
# Hugging Face URL is pinned to a commit (resolve/<commit>) and the sha256 is
|
|
5
|
+
# the one of the file, checked by the init container of the chart.
|
|
6
|
+
# llm_preset_name <name> canonical preset (default | light), 1 when unknown
|
|
7
|
+
# llm_preset_sets <name> helm parameters key=value, space separated
|
|
8
|
+
# llm_preset_file <name> file name of the model of the preset
|
|
9
|
+
# bash 3.2 (macOS).
|
|
10
|
+
|
|
11
|
+
LLM_HF_7B="https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF/resolve/13fb94bfda8c8cf22497dc57b78f391a9acb426a"
|
|
12
|
+
LLM_HF_3B="https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct-GGUF/resolve/f74adce6aa16316c625447af059dbebe4983757c"
|
|
13
|
+
|
|
14
|
+
llm_preset_name() {
|
|
15
|
+
case "${1:-}" in
|
|
16
|
+
"" | default | qwen2.5-coder-7b-instruct-q4_k_m) echo default ;;
|
|
17
|
+
light | qwen2.5-coder-3b-instruct-q4_k_m) echo light ;;
|
|
18
|
+
*) return 1 ;;
|
|
19
|
+
esac
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
llm_preset_file() {
|
|
23
|
+
case "$(llm_preset_name "${1:-}")" in
|
|
24
|
+
default) echo qwen2.5-coder-7b-instruct-q4_k_m.gguf ;;
|
|
25
|
+
light) echo qwen2.5-coder-3b-instruct-q4_k_m.gguf ;;
|
|
26
|
+
esac
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
llm_preset_sets() {
|
|
30
|
+
local name file
|
|
31
|
+
name="$(llm_preset_name "${1:-}")" || return 1
|
|
32
|
+
file="$(llm_preset_file "$name")"
|
|
33
|
+
case "$name" in
|
|
34
|
+
default)
|
|
35
|
+
printf 'model.url=%s/%s model.file=%s model.sha256=%s' "$LLM_HF_7B" "$file" "$file" \
|
|
36
|
+
509287f78cb4d4cf6b3843734733b914b2c158e43e22a7f4bf5e963800894d3c
|
|
37
|
+
;;
|
|
38
|
+
light)
|
|
39
|
+
printf 'model.url=%s/%s model.file=%s model.sha256=%s memory=3Gi resources.limits.memory=4Gi contextSize=16384' \
|
|
40
|
+
"$LLM_HF_3B" "$file" "$file" 724fb256bec1ff062b2f65e4569e871ad2e95ab2a3989723d1769c54294730b7
|
|
41
|
+
;;
|
|
42
|
+
esac
|
|
43
|
+
}
|
|
@@ -153,7 +153,7 @@ desinstaller() {
|
|
|
153
153
|
echo "devzone : postgres : contexte devzone non posé sur $CTX ; nettoyage local seulement" >&2
|
|
154
154
|
fi
|
|
155
155
|
if [ -n "$CTX" ] && installe; then
|
|
156
|
-
echo "▶ Suppression de PostgreSQL et de toutes ses bases sur $CTX…"
|
|
156
|
+
echo "▶ Suppression de PostgreSQL et de toutes ses bases sur ${CTX}…"
|
|
157
157
|
# RoleBinding retiré puis namespace supprimé par l'administrateur (#430)
|
|
158
158
|
compte_retirer "$CTX" "$NS" >/dev/null 2>&1 || true
|
|
159
159
|
compte_admin "$CTX" delete namespace "$NS" --wait=true >/dev/null
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Installs or removes a devzone service (gitlab, postgres, argocd) from inside
|
|
2
|
+
# Installs or removes a devzone service (gitlab, postgres, argocd, llm) from inside
|
|
3
3
|
# the Kubernetes workspace pod, with a temporary administrator token (#528).
|
|
4
4
|
# services-admin.sh enable|disable <service> [options of devzone enable]
|
|
5
5
|
# services-admin.sh seed gitlab data of gitlab seeded again, in the pod (#538)
|
|
6
|
+
# services-admin.sh bench llm [options] speed of the model (#593)
|
|
6
7
|
# Run by the workstation (manage/scripts/services-workspace.sh) through
|
|
7
8
|
# kubectl exec -i: the token comes on stdin, is never printed and lives only
|
|
8
9
|
# in a temporary kubeconfig removed at the end.
|
|
@@ -18,6 +19,9 @@
|
|
|
18
19
|
set -euo pipefail
|
|
19
20
|
|
|
20
21
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
# The devzone command beside this script, not the one of the PATH: the copy
|
|
23
|
+
# that runs the installers is the one of this folder (#591)
|
|
24
|
+
DEVZONE_CMD="$HERE/devzone"
|
|
21
25
|
RACINE="${DEVZONE_RACINE:-$(dirname "$HERE")}"
|
|
22
26
|
ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
23
27
|
SA_DIR="${DEVZONE_SA_DIR:-/var/run/secrets/kubernetes.io/serviceaccount}"
|
|
@@ -40,17 +44,20 @@ service="${2:-}"
|
|
|
40
44
|
case "$action" in
|
|
41
45
|
enable | activer) action=enable ;;
|
|
42
46
|
disable | desactiver) action=disable ;;
|
|
43
|
-
seed) ;;
|
|
44
|
-
*) refuse "usage: services-admin.sh enable|disable|seed gitlab|postgres|argocd [options]" ;;
|
|
47
|
+
seed | bench) ;;
|
|
48
|
+
*) refuse "usage: services-admin.sh enable|disable|seed|bench gitlab|postgres|argocd|llm [options]" ;;
|
|
45
49
|
esac
|
|
46
50
|
case "$service" in
|
|
47
|
-
gitlab | postgres | argocd) ;;
|
|
48
|
-
*) refuse "unknown service: ${service:-(none)} (gitlab, postgres, argocd)" ;;
|
|
51
|
+
gitlab | postgres | argocd | llm) ;;
|
|
52
|
+
*) refuse "unknown service: ${service:-(none)} (gitlab, postgres, argocd, llm)" ;;
|
|
49
53
|
esac
|
|
50
54
|
# The seed of the data (group, demo project, dev user, runner) is gitlab's (#538)
|
|
51
55
|
if [ "$action" = seed ] && [ "$service" != gitlab ]; then
|
|
52
56
|
refuse "seed: only gitlab"
|
|
53
57
|
fi
|
|
58
|
+
if [ "$action" = bench ] && [ "$service" != llm ]; then
|
|
59
|
+
refuse "bench: only llm"
|
|
60
|
+
fi
|
|
54
61
|
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ] || refuse "only in the Kubernetes workspace pod"
|
|
55
62
|
[ -f "$SA_DIR/ca.crt" ] || refuse "cluster CA not found: $SA_DIR/ca.crt"
|
|
56
63
|
if [ -t 0 ]; then
|
|
@@ -68,7 +75,7 @@ cluster_before="$(grep -E '^cluster=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f
|
|
|
68
75
|
# cluster line of the state as before
|
|
69
76
|
cleanup() {
|
|
70
77
|
rm -f "$kubeconfig"
|
|
71
|
-
|
|
78
|
+
"$DEVZONE_CMD" "$service" relay-stop >/dev/null 2>&1 || true
|
|
72
79
|
if [ -n "$cluster_before" ]; then
|
|
73
80
|
etat_ecrire cluster "$cluster_before" || true
|
|
74
81
|
else
|
|
@@ -110,6 +117,7 @@ etat_ecrire cluster "$ADMIN_CONTEXT" || refuse "cannot write the state: $ETAT"
|
|
|
110
117
|
echo "devzone services: $action $service in the cluster of the pod (temporary administrator)"
|
|
111
118
|
case "$action" in
|
|
112
119
|
# The seed is a module command: devzone gitlab seed (#538)
|
|
113
|
-
seed)
|
|
114
|
-
|
|
120
|
+
seed) "$DEVZONE_CMD" gitlab seed "${@:3}" ;;
|
|
121
|
+
bench) "$DEVZONE_CMD" llm bench "${@:3}" ;;
|
|
122
|
+
*) "$DEVZONE_CMD" "$action" "$service" "${@:3}" ;;
|
|
115
123
|
esac
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Single source for the repowarden version used by post-create.sh and workspace-init.sh.
|
|
2
|
-
REPOWARDEN_VERSION=4.17.
|
|
2
|
+
REPOWARDEN_VERSION=4.17.5
|
|
3
3
|
|
|
4
4
|
# BuildKit client version installed in the workspace image (#514). Must match
|
|
5
5
|
# buildkit.image in charts/devzone-workspace/values.yaml.
|
package/README.md
CHANGED
|
@@ -230,6 +230,8 @@ Dans le conteneur, le récapitulatif `devzone` signale une version publiée plus
|
|
|
230
230
|
|
|
231
231
|
**Module `postgres`** : un PostgreSQL partagé, une base par projet (voir [Accéder à PostgreSQL](#accéder-à-postgresql)). Pour l'activer : `devzone enable postgres`.
|
|
232
232
|
|
|
233
|
+
**Module `llm`** : un modèle de code local (Qwen2.5-Coder, sur CPU) dans le cluster de devzone, utilisé par opencode quand les modèles en ligne sont épuisés ou injoignables ; premier téléchargement de plusieurs Go (voir [manage/docs/reference.md](manage/docs/reference.md#modèle-de-code-local)). Pour l'activer : `devzone enable llm` (`--preset light` sur une machine juste en mémoire).
|
|
234
|
+
|
|
233
235
|
**Module `argocd`** : Argo CD sur le cluster de devzone, interface sur https://127.0.0.1:8443 dans le conteneur (voir [Argo CD](manage/docs/reference.md#argo-cd)). Pour l'activer : `devzone enable argocd`.
|
|
234
236
|
|
|
235
237
|
Ces modules sont désactivés par défaut, activables à la demande depuis le conteneur (sans rebuild), et leur choix est conservé d'un démarrage à l'autre.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{{- if .Values.bench.enabled }}
|
|
2
|
+
# One-off llama-bench of the model (#593), never rendered by default. The
|
|
3
|
+
# volume is ReadWriteOnce: the pod must land on the node of the server pod.
|
|
4
|
+
apiVersion: batch/v1
|
|
5
|
+
kind: Job
|
|
6
|
+
metadata:
|
|
7
|
+
name: llm-bench
|
|
8
|
+
namespace: {{ .Release.Namespace }}
|
|
9
|
+
labels:
|
|
10
|
+
app: llm-bench
|
|
11
|
+
app.kubernetes.io/name: llm-bench
|
|
12
|
+
app.kubernetes.io/part-of: devzone
|
|
13
|
+
app.kubernetes.io/managed-by: devzone
|
|
14
|
+
spec:
|
|
15
|
+
backoffLimit: 0
|
|
16
|
+
activeDeadlineSeconds: {{ .Values.bench.deadline }}
|
|
17
|
+
ttlSecondsAfterFinished: {{ .Values.bench.ttl }}
|
|
18
|
+
template:
|
|
19
|
+
metadata:
|
|
20
|
+
labels:
|
|
21
|
+
app: llm-bench
|
|
22
|
+
app.kubernetes.io/managed-by: devzone
|
|
23
|
+
spec:
|
|
24
|
+
restartPolicy: Never
|
|
25
|
+
affinity:
|
|
26
|
+
podAffinity:
|
|
27
|
+
requiredDuringSchedulingIgnoredDuringExecution:
|
|
28
|
+
- topologyKey: kubernetes.io/hostname
|
|
29
|
+
labelSelector:
|
|
30
|
+
matchLabels:
|
|
31
|
+
app: llm
|
|
32
|
+
containers:
|
|
33
|
+
- name: bench
|
|
34
|
+
image: {{ .Values.image }}:full-{{ .Values.llamaBuild }}
|
|
35
|
+
command:
|
|
36
|
+
- /app/llama-bench
|
|
37
|
+
args:
|
|
38
|
+
- -m
|
|
39
|
+
- /models/{{ .Values.model.file }}
|
|
40
|
+
- -p
|
|
41
|
+
- {{ .Values.bench.prompt | quote }}
|
|
42
|
+
- -n
|
|
43
|
+
- {{ .Values.bench.gen | quote }}
|
|
44
|
+
- -r
|
|
45
|
+
- {{ .Values.bench.repetitions | quote }}
|
|
46
|
+
- -t
|
|
47
|
+
- {{ .Values.bench.threads | quote }}
|
|
48
|
+
- -o
|
|
49
|
+
- json
|
|
50
|
+
resources:
|
|
51
|
+
requests:
|
|
52
|
+
cpu: {{ .Values.resources.requests.cpu }}
|
|
53
|
+
memory: {{ .Values.memory }}
|
|
54
|
+
limits:
|
|
55
|
+
memory: {{ .Values.resources.limits.memory }}
|
|
56
|
+
volumeMounts:
|
|
57
|
+
- name: models
|
|
58
|
+
mountPath: /models
|
|
59
|
+
readOnly: true
|
|
60
|
+
volumes:
|
|
61
|
+
- name: models
|
|
62
|
+
persistentVolumeClaim:
|
|
63
|
+
claimName: {{ .Values.claim }}
|
|
64
|
+
readOnly: true
|
|
65
|
+
{{- end }}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: Deployment
|
|
3
|
+
metadata:
|
|
4
|
+
name: llm
|
|
5
|
+
namespace: {{ .Release.Namespace }}
|
|
6
|
+
labels:
|
|
7
|
+
app: llm
|
|
8
|
+
app.kubernetes.io/name: llm
|
|
9
|
+
app.kubernetes.io/part-of: devzone
|
|
10
|
+
app.kubernetes.io/managed-by: devzone
|
|
11
|
+
spec:
|
|
12
|
+
replicas: 1
|
|
13
|
+
strategy:
|
|
14
|
+
type: Recreate
|
|
15
|
+
selector:
|
|
16
|
+
matchLabels:
|
|
17
|
+
app: llm
|
|
18
|
+
template:
|
|
19
|
+
metadata:
|
|
20
|
+
labels:
|
|
21
|
+
app: llm
|
|
22
|
+
app.kubernetes.io/managed-by: devzone
|
|
23
|
+
spec:
|
|
24
|
+
initContainers:
|
|
25
|
+
- name: fetch-model
|
|
26
|
+
image: {{ .Values.fetchImage }}
|
|
27
|
+
securityContext:
|
|
28
|
+
runAsUser: 0
|
|
29
|
+
env:
|
|
30
|
+
- name: MODEL_URL
|
|
31
|
+
value: {{ .Values.model.url | quote }}
|
|
32
|
+
- name: MODEL_FILE
|
|
33
|
+
value: {{ .Values.model.file | quote }}
|
|
34
|
+
- name: MODEL_SHA256
|
|
35
|
+
value: {{ .Values.model.sha256 | quote }}
|
|
36
|
+
command:
|
|
37
|
+
- sh
|
|
38
|
+
- -c
|
|
39
|
+
- |
|
|
40
|
+
set -eu
|
|
41
|
+
f="/models/$MODEL_FILE"
|
|
42
|
+
if [ ! -f "$f" ]; then
|
|
43
|
+
echo "downloading $MODEL_FILE (first start: several minutes)"
|
|
44
|
+
curl -fL --retry 5 --retry-delay 5 -C - -o "$f.part" "$MODEL_URL"
|
|
45
|
+
mv "$f.part" "$f"
|
|
46
|
+
fi
|
|
47
|
+
if ! echo "$MODEL_SHA256 $f" | sha256sum -c -; then
|
|
48
|
+
echo "sha256 differs: $MODEL_FILE removed" >&2
|
|
49
|
+
rm -f "$f"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
volumeMounts:
|
|
53
|
+
- name: models
|
|
54
|
+
mountPath: /models
|
|
55
|
+
containers:
|
|
56
|
+
- name: llm
|
|
57
|
+
image: {{ .Values.image }}:server-{{ .Values.llamaBuild }}
|
|
58
|
+
env:
|
|
59
|
+
- name: THREADS
|
|
60
|
+
value: {{ .Values.threads | quote }}
|
|
61
|
+
- name: MAX_THREADS
|
|
62
|
+
value: {{ .Values.maxThreads | quote }}
|
|
63
|
+
command:
|
|
64
|
+
- sh
|
|
65
|
+
- -c
|
|
66
|
+
- |
|
|
67
|
+
set -eu
|
|
68
|
+
t="$THREADS"
|
|
69
|
+
if [ "$t" = auto ]; then
|
|
70
|
+
t="$(nproc)"
|
|
71
|
+
[ "$t" -le "$MAX_THREADS" ] || t="$MAX_THREADS"
|
|
72
|
+
fi
|
|
73
|
+
echo "llama-server: $t threads"
|
|
74
|
+
exec /app/llama-server "$@" -t "$t" --threads-batch "$t"
|
|
75
|
+
- llama-server
|
|
76
|
+
args:
|
|
77
|
+
- --host
|
|
78
|
+
- 0.0.0.0
|
|
79
|
+
- --port
|
|
80
|
+
- "8080"
|
|
81
|
+
- -m
|
|
82
|
+
- /models/{{ .Values.model.file }}
|
|
83
|
+
- -c
|
|
84
|
+
- {{ .Values.contextSize | quote }}
|
|
85
|
+
- --cache-type-k
|
|
86
|
+
- {{ .Values.cacheType | quote }}
|
|
87
|
+
- --cache-type-v
|
|
88
|
+
- {{ .Values.cacheType | quote }}
|
|
89
|
+
- --flash-attn
|
|
90
|
+
- {{ .Values.flashAttention | quote }}
|
|
91
|
+
ports:
|
|
92
|
+
- containerPort: 8080
|
|
93
|
+
name: http
|
|
94
|
+
readinessProbe:
|
|
95
|
+
httpGet:
|
|
96
|
+
path: /health
|
|
97
|
+
port: 8080
|
|
98
|
+
initialDelaySeconds: 10
|
|
99
|
+
periodSeconds: 10
|
|
100
|
+
failureThreshold: 30
|
|
101
|
+
resources:
|
|
102
|
+
requests:
|
|
103
|
+
cpu: {{ .Values.resources.requests.cpu }}
|
|
104
|
+
memory: {{ .Values.memory }}
|
|
105
|
+
limits:
|
|
106
|
+
memory: {{ .Values.resources.limits.memory }}
|
|
107
|
+
volumeMounts:
|
|
108
|
+
- name: models
|
|
109
|
+
mountPath: /models
|
|
110
|
+
volumes:
|
|
111
|
+
- name: models
|
|
112
|
+
persistentVolumeClaim:
|
|
113
|
+
claimName: {{ .Values.claim }}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: PersistentVolumeClaim
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ .Values.claim }}
|
|
5
|
+
namespace: {{ .Release.Namespace }}
|
|
6
|
+
labels:
|
|
7
|
+
app: llm
|
|
8
|
+
app.kubernetes.io/name: llm
|
|
9
|
+
app.kubernetes.io/part-of: devzone
|
|
10
|
+
app.kubernetes.io/managed-by: devzone
|
|
11
|
+
annotations:
|
|
12
|
+
# The model is not downloaded again: the volume outlives the release
|
|
13
|
+
helm.sh/resource-policy: keep
|
|
14
|
+
argocd.argoproj.io/sync-options: Delete=false
|
|
15
|
+
spec:
|
|
16
|
+
accessModes: ["ReadWriteOnce"]
|
|
17
|
+
resources:
|
|
18
|
+
requests:
|
|
19
|
+
storage: {{ .Values.size }}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Service
|
|
3
|
+
metadata:
|
|
4
|
+
name: llm
|
|
5
|
+
namespace: {{ .Release.Namespace }}
|
|
6
|
+
labels:
|
|
7
|
+
app: llm
|
|
8
|
+
app.kubernetes.io/name: llm
|
|
9
|
+
app.kubernetes.io/part-of: devzone
|
|
10
|
+
app.kubernetes.io/managed-by: devzone
|
|
11
|
+
spec:
|
|
12
|
+
type: ClusterIP
|
|
13
|
+
selector:
|
|
14
|
+
app: llm
|
|
15
|
+
ports:
|
|
16
|
+
- name: http
|
|
17
|
+
port: {{ .Values.port }}
|
|
18
|
+
targetPort: 8080
|