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,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Local model in the rotation of devzone agent (#586), sourced by agent.sh.
|
|
3
|
+
# The model devzone-llm/local comes after every online model (never first, never
|
|
4
|
+
# when the module llm is off or the server does not answer /health): it is used
|
|
5
|
+
# when the online ones are all set aside (quota, network). Its internal name has
|
|
6
|
+
# no slash (a file ecart-<name> is written for it); opencode gets the reference.
|
|
7
|
+
LOCAL_NOM=devzone-llm-local
|
|
8
|
+
|
|
9
|
+
# Prints LOCAL_NOM when the module is on (in the pod: the cluster answers) and
|
|
10
|
+
# the server answers /health
|
|
11
|
+
local_pret() {
|
|
12
|
+
local url
|
|
13
|
+
if [ "${DEVZONE_WORKSPACE:-}" != kubernetes ]; then
|
|
14
|
+
bash "$ICI/devzone" is-enabled llm >/dev/null 2>&1 || return 0
|
|
15
|
+
fi
|
|
16
|
+
url="$(bash "$ICI/llm/opencode.sh" url)" || return 0
|
|
17
|
+
curl -fsS --max-time 3 "${url%/v1}/health" >/dev/null 2>&1 && echo "$LOCAL_NOM"
|
|
18
|
+
return 0
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Sets LOCAL_MODELE for this attempt (local_pret), read by modele_au_rang and
|
|
22
|
+
# modeles_total
|
|
23
|
+
local_charge() {
|
|
24
|
+
LOCAL_MODELE="$(local_pret)"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Model reference given to opencode -m
|
|
28
|
+
modele_ref() {
|
|
29
|
+
if [ "$1" = "$LOCAL_NOM" ]; then echo devzone-llm/local; else echo "opencode/$1"; fi
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Model of rank $1 in the attempt that starts at $2: online ones in rotation,
|
|
33
|
+
# then the local one
|
|
34
|
+
modele_au_rang() {
|
|
35
|
+
if [ "$1" -lt "${#FREE_MODELS[@]}" ]; then
|
|
36
|
+
echo "${FREE_MODELS[$(( ($2 + $1) % ${#FREE_MODELS[@]} ))]}"
|
|
37
|
+
else
|
|
38
|
+
echo "$LOCAL_MODELE"
|
|
39
|
+
fi
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Number of models to try: the online ones, plus the local one if ready
|
|
43
|
+
modeles_total() {
|
|
44
|
+
echo $(( ${#FREE_MODELS[@]} + ${#LOCAL_MODELE} / ${#LOCAL_NOM} ))
|
|
45
|
+
}
|
|
@@ -27,7 +27,7 @@ opencode_lancer() {
|
|
|
27
27
|
if agent_dans_pod; then
|
|
28
28
|
# Dans le pod, le compte de service limité est le seul accès : aucun
|
|
29
29
|
# kubeconfig du poste n'entre dans l'environnement d'opencode.
|
|
30
|
-
(cd "$dossier" && env -u KUBECONFIG DEVZONE_AGENT_SESSION=1 opencode run --print-logs --log-level ERROR --auto -m "
|
|
30
|
+
(cd "$dossier" && env -u KUBECONFIG DEVZONE_AGENT_SESSION=1 opencode run --print-logs --log-level ERROR --auto -m "$(modele_ref "$m")" "$(cat "$consigne")" </dev/null >>"$journal" 2>&1) &
|
|
31
31
|
else
|
|
32
32
|
if [ -f "$HOME/.kube/config" ]; then
|
|
33
33
|
(umask 077; KUBECONFIG="$HOME/.kube/config" kubectl config view --minify --flatten --context devzone >"$agent_kube") 2>/dev/null || : >"$agent_kube"
|
|
@@ -36,7 +36,7 @@ opencode_lancer() {
|
|
|
36
36
|
else
|
|
37
37
|
: >"$agent_kube"
|
|
38
38
|
fi
|
|
39
|
-
(cd "$dossier" && KUBECONFIG="$agent_kube" DEVZONE_AGENT_SESSION=1 opencode run --print-logs --log-level ERROR --auto -m "
|
|
39
|
+
(cd "$dossier" && KUBECONFIG="$agent_kube" DEVZONE_AGENT_SESSION=1 opencode run --print-logs --log-level ERROR --auto -m "$(modele_ref "$m")" "$(cat "$consigne")" </dev/null >>"$journal" 2>&1) &
|
|
40
40
|
fi
|
|
41
41
|
}
|
|
42
42
|
|
package/.devcontainer/agent.sh
CHANGED
|
@@ -23,21 +23,20 @@ ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
|
23
23
|
# shellcheck disable=SC2034 # lue par agent-session.sh
|
|
24
24
|
RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
25
25
|
# Écarts de modèles et attente du réseau (#328)
|
|
26
|
-
# shellcheck source=agent-erreurs.sh
|
|
27
|
-
# shellcheck disable=SC1091
|
|
26
|
+
# shellcheck source=agent-erreurs.sh disable=SC1091
|
|
28
27
|
. "$ICI/agent-erreurs.sh"
|
|
29
28
|
# Fichiers de droits des agents protégés (#361)
|
|
30
|
-
# shellcheck source=agent-droits.sh
|
|
31
|
-
# shellcheck disable=SC1091
|
|
29
|
+
# shellcheck source=agent-droits.sh disable=SC1091
|
|
32
30
|
. "$ICI/agent-droits.sh"
|
|
33
31
|
# Configuration, rang partagé, journal et état (#328)
|
|
34
|
-
# shellcheck source=agent-session.sh
|
|
35
|
-
# shellcheck disable=SC1091
|
|
32
|
+
# shellcheck source=agent-session.sh disable=SC1091
|
|
36
33
|
. "$ICI/agent-session.sh"
|
|
37
34
|
# Workspace Kubernetes : projet et journal dans le pod (#431)
|
|
38
|
-
# shellcheck source=agent-workspace.sh
|
|
39
|
-
# shellcheck disable=SC1091
|
|
35
|
+
# shellcheck source=agent-workspace.sh disable=SC1091
|
|
40
36
|
. "$ICI/agent-workspace.sh"
|
|
37
|
+
# Modèle local en dernier de la rotation (#586)
|
|
38
|
+
# shellcheck source=agent-local.sh disable=SC1091
|
|
39
|
+
. "$ICI/agent-local.sh"
|
|
41
40
|
# Liste de secours si « opencode models opencode » ne répond pas : même ordre
|
|
42
41
|
# que la configuration opencode livrée par devzone.
|
|
43
42
|
FREE_MODELS=(big-pickle deepseek-v4.1-flash-free glm-5.3-flash-free nemotron-3.5-super-vl-free
|
|
@@ -78,6 +77,7 @@ agent_lancer() {
|
|
|
78
77
|
if [ -n "$m" ]; then FREE_MODELS+=("$m"); fi
|
|
79
78
|
done < <(liste_modeles)
|
|
80
79
|
[ "${#FREE_MODELS[@]}" -gt 0 ] || refuse "aucun modèle gratuit disponible"
|
|
80
|
+
local_charge
|
|
81
81
|
verrou_prendre || refuse "rang des modèles verrouillé : réessayer"
|
|
82
82
|
debut=$(( $(cat "$etat/rang" 2>/dev/null || echo 0) % ${#FREE_MODELS[@]} ))
|
|
83
83
|
if [ "$PAUSE_RANG" -gt 0 ]; then sleep "$PAUSE_RANG"; fi
|
|
@@ -97,8 +97,8 @@ agent_lancer() {
|
|
|
97
97
|
consigne_courante="$c"
|
|
98
98
|
}
|
|
99
99
|
i=0
|
|
100
|
-
while [ "$i" -lt "$
|
|
101
|
-
m="$
|
|
100
|
+
while [ "$i" -lt "$(modeles_total)" ]; do
|
|
101
|
+
m="$(modele_au_rang "$i" "$debut")"
|
|
102
102
|
if [ "$m" != "$reseau_pour" ]; then reseau_pour="$m"; reseau_n=0; fi
|
|
103
103
|
if modele_ecarte "$m"; then
|
|
104
104
|
i=$(( i + 1 ))
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Services of the container held by Argo CD (#559, step 5). Called by devzone
|
|
3
3
|
# (changer) after the state line is written, before the helm-direct path:
|
|
4
4
|
# services-hook.sh <svc> <on|off>
|
|
5
|
-
# postgres and
|
|
5
|
+
# postgres, mysql and llm with the module argocd installed and held: enable writes
|
|
6
6
|
# [services] <svc> = on and reconciles it (services_reconcile, services.sh),
|
|
7
7
|
# then waits for the pods and starts the relay; disable removes the
|
|
8
8
|
# Application (its resources leave with it, namespace and volumes stay).
|
|
@@ -22,7 +22,7 @@ STATE_RACINE="${DEVZONE_RACINE:-$RACINE}"
|
|
|
22
22
|
# shellcheck disable=SC2034 # read by catalogue-argocd.sh
|
|
23
23
|
ETAT="${DEVZONE_ETAT:-$STATE_RACINE/.devzone.modules}"
|
|
24
24
|
APP_CONF="$RACINE/.devcontainer/catalogue/mysql/app.conf"
|
|
25
|
-
HOOK_SERVICES="postgres mysql"
|
|
25
|
+
HOOK_SERVICES="postgres mysql llm"
|
|
26
26
|
|
|
27
27
|
# shellcheck source=SCRIPTDIR/../cluster.sh
|
|
28
28
|
# shellcheck disable=SC1091
|
|
@@ -46,16 +46,19 @@ hook_script() {
|
|
|
46
46
|
case "$1" in
|
|
47
47
|
postgres) printf '%s' "$ICI/../postgres/postgres.sh" ;;
|
|
48
48
|
mysql) printf '%s' "$ICI/../catalogue/mysql/mysql.sh" ;;
|
|
49
|
+
llm) printf '%s' "$ICI/../llm/llm.sh" ;;
|
|
49
50
|
esac
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
# Waits for the pods of devzone-<svc> to be ready (the Application syncs
|
|
53
|
-
# within a few minutes); the relay needs a ready pod to forward to
|
|
54
|
+
# within a few minutes); the relay needs a ready pod to forward to. The model
|
|
55
|
+
# of llm is downloaded on its first start: LLM_ATTENTE seconds (1800)
|
|
54
56
|
hook_wait() {
|
|
55
|
-
local ns="devzone-$1" tour=0
|
|
57
|
+
local ns="devzone-$1" tour=0 limit=300
|
|
58
|
+
[ "$1" != llm ] || limit="${LLM_ATTENTE:-1800}"
|
|
56
59
|
while [ "$tour" -lt 60 ]; do
|
|
57
60
|
if argocd_kubectl -n "$ns" get pods -o name 2>/dev/null | grep -q .; then
|
|
58
|
-
argocd_kubectl -n "$ns" wait --for=condition=Ready pod --all --timeout=
|
|
61
|
+
argocd_kubectl -n "$ns" wait --for=condition=Ready pod --all --timeout="${limit}s" >/dev/null 2>&1 && return 0
|
|
59
62
|
fi
|
|
60
63
|
tour=$((tour + 1))
|
|
61
64
|
sleep 5
|
|
@@ -64,6 +67,12 @@ hook_wait() {
|
|
|
64
67
|
return 1
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
# The llm.sh subcommands used by enable (preset, policy); a function so the
|
|
71
|
+
# tests replace it
|
|
72
|
+
hook_llm() {
|
|
73
|
+
DEVZONE_RACINE="$STATE_RACINE" bash "$ICI/../llm/llm.sh" "$@"
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
# Starts the relay of the service, after the pods are ready
|
|
68
77
|
hook_relay() {
|
|
69
78
|
bash "$(hook_script "$1")" relay-start
|
|
@@ -95,6 +104,20 @@ services_secret_postgres() { services_secret_admin postgres devzone-postgres pos
|
|
|
95
104
|
# The superuser secret of MySQL, the same way
|
|
96
105
|
services_secret_mysql() { services_secret_admin mysql devzone-mysql mysql-admin; }
|
|
97
106
|
|
|
107
|
+
# The llm secret hook: the chart has no Secret, nothing to create
|
|
108
|
+
services_secret_llm() { :; }
|
|
109
|
+
|
|
110
|
+
# Parameters of the llm chart: the stored preset (devzone enable llm --preset
|
|
111
|
+
# light), the model and the memory it needs
|
|
112
|
+
services_chart_llm() {
|
|
113
|
+
local preset
|
|
114
|
+
# shellcheck source=SCRIPTDIR/../llm/presets.sh
|
|
115
|
+
# shellcheck disable=SC1091
|
|
116
|
+
. "$ICI/../llm/presets.sh"
|
|
117
|
+
preset="$(cat "$STATE_RACINE/workspace/.llm/preset" 2>/dev/null || true)"
|
|
118
|
+
llm_preset_sets "$preset"
|
|
119
|
+
}
|
|
120
|
+
|
|
98
121
|
# Value of a key of the MySQL application file (app.conf, read as text)
|
|
99
122
|
app_value() { sed -n "s/^$1=//p" "$APP_CONF" 2>/dev/null | tail -1; }
|
|
100
123
|
|
|
@@ -124,9 +147,16 @@ services_chart_mysql() {
|
|
|
124
147
|
hook_on() {
|
|
125
148
|
local svc="$1"
|
|
126
149
|
catalogue_argocd_active "$svc" || return 3
|
|
150
|
+
# llm: the preset of the command line, then the ingress of the workspace
|
|
151
|
+
if [ "$svc" = llm ]; then
|
|
152
|
+
hook_llm preset "${@:2}" || return 1
|
|
153
|
+
fi
|
|
127
154
|
services_note "$svc" on || return 1
|
|
128
155
|
services_reconcile || return 1
|
|
129
156
|
echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
|
|
157
|
+
if [ "$svc" = llm ]; then
|
|
158
|
+
hook_llm policy || return 1
|
|
159
|
+
fi
|
|
130
160
|
hook_wait "$svc" || return 1
|
|
131
161
|
hook_relay "$svc" || return 1
|
|
132
162
|
echo "✔ $svc held by Argo CD ([services] $svc = on in .argocd.conf)"
|
|
@@ -150,14 +180,14 @@ hook_off() {
|
|
|
150
180
|
# is on the Application itself, not on the module state.
|
|
151
181
|
hook_release() {
|
|
152
182
|
local svc app
|
|
153
|
-
for svc in postgres mysql gitlab; do
|
|
183
|
+
for svc in postgres mysql gitlab llm; do
|
|
154
184
|
app="devzone-$svc"
|
|
155
185
|
argocd_kubectl -n devzone-argocd get application.argoproj.io "$app" >/dev/null 2>&1 || continue
|
|
156
186
|
argocd_kubectl -n devzone-argocd patch application.argoproj.io "$app" --type merge \
|
|
157
187
|
-p '{"metadata":{"finalizers":null}}' >/dev/null 2>&1 || true
|
|
158
188
|
gitops_delete_application "$app" keep || return 1
|
|
159
189
|
case "$svc" in
|
|
160
|
-
postgres | mysql) services_note "$svc" off || return 1 ;;
|
|
190
|
+
postgres | mysql | llm) services_note "$svc" off || return 1 ;;
|
|
161
191
|
esac
|
|
162
192
|
echo "✔ Application $app released: its resources stay for the helm-direct path"
|
|
163
193
|
done
|
|
@@ -169,8 +199,8 @@ hook_main() {
|
|
|
169
199
|
local svc="${1:-}" action="${2:-}"
|
|
170
200
|
case "$svc:$action" in
|
|
171
201
|
argocd:off) hook_load && hook_release ;;
|
|
172
|
-
postgres:on | mysql:on) hook_load && hook_on "$svc" ;;
|
|
173
|
-
postgres:off | mysql:off) hook_load && hook_off "$svc" ;;
|
|
202
|
+
postgres:on | mysql:on | llm:on) hook_load && hook_on "$svc" "${@:3}" ;;
|
|
203
|
+
postgres:off | mysql:off | llm:off) hook_load && hook_off "$svc" ;;
|
|
174
204
|
*) return 3 ;;
|
|
175
205
|
esac
|
|
176
206
|
}
|
|
@@ -144,7 +144,7 @@ supprimer_donnees() {
|
|
|
144
144
|
CTX="$(cluster_lu)"
|
|
145
145
|
[ -n "$CTX" ] || refuse "aucun cluster choisi : devzone enable mysql"
|
|
146
146
|
installe || refuse "module inactif : devzone enable mysql"
|
|
147
|
-
echo "▶ Suppression de MySQL et de ses volumes sur $CTX…"
|
|
147
|
+
echo "▶ Suppression de MySQL et de ses volumes sur ${CTX}…"
|
|
148
148
|
# L'Application part d'abord (#538) : sinon Argo CD recrée le namespace
|
|
149
149
|
catalogue_argocd_delete mysql >/dev/null 2>&1 || true
|
|
150
150
|
# RoleBinding retiré puis namespace supprimé par l'administrateur (#430)
|
package/.devcontainer/devzone
CHANGED
|
@@ -28,7 +28,7 @@ VERSIONS="$ICI/../manage/scripts/versions.sh"
|
|
|
28
28
|
RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
29
29
|
# État par défaut de l'instance ; DEVZONE_ETAT garde la priorité (tests, CI)
|
|
30
30
|
ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
31
|
-
MODULES=(ia kubernetes gitlab postgres argocd mysql)
|
|
31
|
+
MODULES=(ia kubernetes gitlab postgres argocd mysql llm)
|
|
32
32
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
33
33
|
# shellcheck disable=SC1091
|
|
34
34
|
. "$ICI/cluster.sh"
|
|
@@ -78,6 +78,7 @@ description() {
|
|
|
78
78
|
postgres) echo "PostgreSQL partagé, une base par projet" ;;
|
|
79
79
|
argocd) echo "Argo CD, interface de déploiement du cluster des services" ;;
|
|
80
80
|
mysql) echo "MySQL partagé, une base par projet" ;;
|
|
81
|
+
llm) echo "modèle de code local (llama.cpp) dans le cluster des services" ;;
|
|
81
82
|
esac
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -301,18 +302,17 @@ fichier_echec() {
|
|
|
301
302
|
echo "$ETAT-echec-$1"
|
|
302
303
|
}
|
|
303
304
|
|
|
304
|
-
# Services in the Kubernetes workspace pod (#528): gitlab, postgres and
|
|
305
|
-
# live in the cluster
|
|
306
|
-
#
|
|
307
|
-
#
|
|
308
|
-
# like the catalogue (#515), never the failure marker of an installer.
|
|
305
|
+
# Services in the Kubernetes workspace pod (#528): gitlab, postgres, argocd and
|
|
306
|
+
# llm live in the cluster, installed from the workstation (devzone workspace
|
|
307
|
+
# services). The pod has no kubeconfig and a limited account (#430): their
|
|
308
|
+
# presence is the cluster DNS (like #515), never an installer failure marker.
|
|
309
309
|
dans_pod() {
|
|
310
310
|
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ]
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
service_module() {
|
|
314
314
|
case "$1" in
|
|
315
|
-
gitlab | postgres | argocd) return 0 ;;
|
|
315
|
+
gitlab | postgres | argocd | llm) return 0 ;;
|
|
316
316
|
esac
|
|
317
317
|
return 1
|
|
318
318
|
}
|
|
@@ -323,6 +323,7 @@ service_dns() {
|
|
|
323
323
|
gitlab) echo "gitlab-webservice-default.devzone-gitlab${INSTANCE_SUFFIX}.svc" ;;
|
|
324
324
|
postgres) echo "postgres.devzone-postgres.svc" ;;
|
|
325
325
|
argocd) echo "argocd-server.devzone-argocd.svc" ;;
|
|
326
|
+
llm) echo "llm.devzone-llm.svc" ;;
|
|
326
327
|
esac
|
|
327
328
|
}
|
|
328
329
|
|
|
@@ -565,6 +566,7 @@ appliquer_postgres() {
|
|
|
565
566
|
fi
|
|
566
567
|
}
|
|
567
568
|
|
|
569
|
+
appliquer_llm() { bash "$ICI/llm/llm.sh" apply "$@"; }
|
|
568
570
|
# Argo CD (#411) : installé dans le cluster des services, accès par le relais
|
|
569
571
|
# 127.0.0.1:8443 ; un échec est marqué dans l'état et repris par devzone apply
|
|
570
572
|
appliquer_argocd() {
|
|
@@ -942,7 +944,7 @@ appliquer_repowarden() {
|
|
|
942
944
|
ligne="$(bash "$VERSIONS" --installees 2>/dev/null | awk '$1 == "repowarden"' || true)"
|
|
943
945
|
[ -n "$ligne" ] || return 0
|
|
944
946
|
read -r _ figee installee <<<"$ligne"
|
|
945
|
-
echo "devzone : installation de repowarden $figee…"
|
|
947
|
+
echo "devzone : installation de repowarden ${figee}…"
|
|
946
948
|
npm install -g "$paquet@$figee" >/dev/null
|
|
947
949
|
repowarden install --global --lang fr
|
|
948
950
|
echo "devzone : repowarden $installee → $figee"
|
|
@@ -1235,8 +1237,8 @@ etat() {
|
|
|
1235
1237
|
elif [ "$(valeur "$m")" = on ] && [ "$m" = gitlab ]; then
|
|
1236
1238
|
# GitLab actif : son état réel (prêt, runner, en échec)
|
|
1237
1239
|
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/gitlab/gitlab.sh" status)"
|
|
1238
|
-
elif [ "$(valeur "$m")" = on ] && [ "$m" = postgres ]; then
|
|
1239
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI
|
|
1240
|
+
elif [ "$(valeur "$m")" = on ] && { [ "$m" = postgres ] || [ "$m" = llm ]; }; then
|
|
1241
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/$m/$m.sh" status)"
|
|
1240
1242
|
elif [ "$(valeur "$m")" = on ] && [ "$m" = argocd ]; then
|
|
1241
1243
|
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/argocd/argocd.sh" status)"
|
|
1242
1244
|
elif [ "$(valeur "$m")" = on ] && [ "$m" = mysql ]; then
|
|
@@ -1376,7 +1378,7 @@ changer() {
|
|
|
1376
1378
|
fi
|
|
1377
1379
|
ecrire "$m" "$1"
|
|
1378
1380
|
# Services held by Argo CD (#559): 0 done, 3 helm direct as before, else failed
|
|
1379
|
-
if DEVZONE_ETAT="$ETAT" bash "$ICI/argocd/services-hook.sh" "$m" "$1"; then return 0; elif [ $? -ne 3 ]; then return 1; fi
|
|
1381
|
+
if DEVZONE_ETAT="$ETAT" bash "$ICI/argocd/services-hook.sh" "$m" "$1" "${@:3}"; then return 0; elif [ $? -ne 3 ]; then return 1; fi
|
|
1380
1382
|
"appliquer_$m" "$1" "${@:3}"
|
|
1381
1383
|
}
|
|
1382
1384
|
|
|
@@ -1420,7 +1422,7 @@ case "${1:-}" in
|
|
|
1420
1422
|
# gitlab, postgres, argocd: installed from the workstation in the
|
|
1421
1423
|
# Kubernetes workspace pod (#528), by their installer elsewhere
|
|
1422
1424
|
[ "$(valeur gitlab)" = off ] || appliquer_service gitlab
|
|
1423
|
-
[ "$(valeur
|
|
1425
|
+
for m in postgres llm; do [ "$(valeur "$m")" = off ] || appliquer_service "$m"; done
|
|
1424
1426
|
[ "$(valeur mysql)" = off ] || appliquer_mysql on
|
|
1425
1427
|
[ "$(valeur argocd)" = off ] || appliquer_service argocd
|
|
1426
1428
|
;;
|
|
@@ -1443,7 +1445,7 @@ case "${1:-}" in
|
|
|
1443
1445
|
utiliser) utiliser "${@:2}" ;;
|
|
1444
1446
|
clusters) DEVZONE_ETAT="$ETAT" bash "$ICI/clusters.sh" "${@:2}" ;;
|
|
1445
1447
|
cluster) changer_cluster "${@:2}" ;;
|
|
1446
|
-
postgres) DEVZONE_ETAT="$ETAT" bash "$ICI
|
|
1448
|
+
postgres | llm) DEVZONE_ETAT="$ETAT" bash "$ICI/$1/$1.sh" "${@:2}" ;;
|
|
1447
1449
|
mysql) DEVZONE_ETAT="$ETAT" bash "$ICI/catalogue/mysql/mysql.sh" "${@:2}" ;;
|
|
1448
1450
|
gitlab) DEVZONE_ETAT="$ETAT" bash "$ICI/gitlab/gitlab.sh" "${@:2}" ;;
|
|
1449
1451
|
catalogue) DEVZONE_ETAT="$ETAT" bash "$ICI/catalogue.sh" list ;;
|
|
@@ -132,12 +132,12 @@ etat_json() {
|
|
|
132
132
|
etat_val=""
|
|
133
133
|
ajouter_erreur modules "gitlab.sh status indisponible"
|
|
134
134
|
fi
|
|
135
|
-
elif [ "$m" = postgres ]; then
|
|
136
|
-
if s="$(bash "$ICI
|
|
135
|
+
elif [ "$m" = postgres ] || [ "$m" = llm ]; then
|
|
136
|
+
if s="$(bash "$ICI/$m/$m.sh" status 2>/dev/null)"; then
|
|
137
137
|
etat_val="$s"
|
|
138
138
|
else
|
|
139
139
|
etat_val=""
|
|
140
|
-
ajouter_erreur modules "
|
|
140
|
+
ajouter_erreur modules "$m.sh etat indisponible"
|
|
141
141
|
fi
|
|
142
142
|
elif [ "$m" = argocd ]; then
|
|
143
143
|
if s="$(bash "$ICI/argocd/argocd.sh" status 2>/dev/null)"; then
|
|
@@ -99,7 +99,7 @@ gitlab_installer() {
|
|
|
99
99
|
gitlab_release_adopter
|
|
100
100
|
gitlab_application_apply || return 1
|
|
101
101
|
else
|
|
102
|
-
echo "▶ Installation du chart GitLab dans $GITLAB_NS…"
|
|
102
|
+
echo "▶ Installation du chart GitLab dans ${GITLAB_NS}…"
|
|
103
103
|
gitlab_chart_depend
|
|
104
104
|
gitlab_helm_pass 0 || return 1
|
|
105
105
|
fi
|
package/.devcontainer/help.sh
CHANGED
|
@@ -26,6 +26,8 @@ devzone_aide() {
|
|
|
26
26
|
devzone enable postgres [--context CTX] [--confirm CTX] shared PostgreSQL, cluster of choice
|
|
27
27
|
devzone postgres create <project> database and user of a project (also: list, psql, delete)
|
|
28
28
|
devzone mysql create <project> database and user of a MySQL project (also: list, delete)
|
|
29
|
+
devzone enable llm [--preset light] local code model (llama.cpp), devzone llm status
|
|
30
|
+
devzone llm status | delete-data [--yes] model and reachability | namespace and model removed
|
|
29
31
|
devzone gitlab migrate [--yes] GitLab in the services cluster, then the old kind cluster deleted
|
|
30
32
|
devzone gitlab new-password [root|dev] random password (root or dev) regenerated
|
|
31
33
|
devzone enable argocd Argo CD in the services cluster, access https://127.0.0.1:8443
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# devzone llm bench (#593), sourced by llm.sh (uses its NS, k, preset_read
|
|
3
|
+
# and refuse): llama-bench of the model in a Kubernetes Job of the
|
|
4
|
+
# namespace devzone-llm (image full-<llamaBuild> of the chart, same build as the
|
|
5
|
+
# server, pulled only here), then a table, a threads recommendation and whether
|
|
6
|
+
# the speed is enough for opencode.
|
|
7
|
+
# devzone llm bench [--apply] [--threads LIST] [--prompt N] [--gen N]
|
|
8
|
+
# --apply sets threads=<best> on the release llm (helm upgrade, values kept).
|
|
9
|
+
# Env: LLM_BENCH_ATTENTE (seconds, 1800: wait limit and activeDeadlineSeconds of
|
|
10
|
+
# the Job, which stops by itself if the call is interrupted), LLM_BENCH_POLL
|
|
11
|
+
# (seconds, 5), LLM_BENCH_SIGNE (seconds, 30: a progress line at least this
|
|
12
|
+
# often, so that the connection of kubectl exec is not cut), LLM_BENCH_MIN_PP (50 tok/s, prompt reading), LLM_BENCH_MIN_TG (8 tok/s,
|
|
13
|
+
# generation). The Job is deleted at the end, even on failure. bash 3.2 (macOS).
|
|
14
|
+
|
|
15
|
+
BENCH_JOB=llm-bench
|
|
16
|
+
|
|
17
|
+
# Server present, read with the rights of the namespace (the account of the pod
|
|
18
|
+
# cannot read a namespace, a cluster resource: installed would fail for it)
|
|
19
|
+
bench_present() { k get deployment llm >/dev/null 2>&1; }
|
|
20
|
+
|
|
21
|
+
# Job deleted (no error when it is already gone)
|
|
22
|
+
bench_cleanup() { k delete job "$BENCH_JOB" --ignore-not-found --wait=false >/dev/null 2>&1 || true; }
|
|
23
|
+
|
|
24
|
+
# Phase of the Job for the progress line, read from the state of the container
|
|
25
|
+
# (not the phase of the pod): waiting (ContainerCreating, PullImage...) is
|
|
26
|
+
# pulling, running or terminated is measuring. The caller keeps the phase
|
|
27
|
+
# monotone: once measuring, it never goes back to pulling.
|
|
28
|
+
bench_phase() {
|
|
29
|
+
local etat
|
|
30
|
+
etat="$(k get pods -l app=llm-bench -o jsonpath='{.items[0].status.containerStatuses[0].state.running.startedAt}|{.items[0].status.containerStatuses[0].state.terminated.reason}' 2>/dev/null || true)"
|
|
31
|
+
case "$etat" in
|
|
32
|
+
"|" | "") echo "pulling the image" ;;
|
|
33
|
+
*) echo "measuring" ;;
|
|
34
|
+
esac
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Waits for the Job: 0 done, 1 failed, 2 timeout. Writes a line (phase,
|
|
38
|
+
# elapsed time) at least every LLM_BENCH_SIGNE seconds
|
|
39
|
+
bench_wait() {
|
|
40
|
+
local waited=0 poll="${LLM_BENCH_POLL:-5}" limit="${LLM_BENCH_ATTENTE:-1800}" beat="${LLM_BENCH_SIGNE:-30}" st last="" phase="pulling the image"
|
|
41
|
+
while [ "$waited" -lt "$limit" ]; do
|
|
42
|
+
st="$(k get job "$BENCH_JOB" -o jsonpath='{.status.succeeded}/{.status.failed}' 2>/dev/null || true)"
|
|
43
|
+
case "$st" in
|
|
44
|
+
1/*) return 0 ;;
|
|
45
|
+
*/[1-9]*) return 1 ;;
|
|
46
|
+
esac
|
|
47
|
+
if [ -z "$last" ] || [ $((waited - last)) -ge "$beat" ]; then
|
|
48
|
+
# Monotone: once measuring, the phase is not read again
|
|
49
|
+
[ "$phase" = measuring ] || phase="$(bench_phase)"
|
|
50
|
+
echo " … $phase, ${waited}s elapsed"
|
|
51
|
+
last=$waited
|
|
52
|
+
fi
|
|
53
|
+
sleep "$poll"
|
|
54
|
+
waited=$((waited + poll))
|
|
55
|
+
done
|
|
56
|
+
return 2
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Table "threads pp tg" (tok/s) from the JSON of llama-bench (logs of the Job:
|
|
60
|
+
# the array is the part between the line "[" and the line "]")
|
|
61
|
+
bench_rows() {
|
|
62
|
+
sed -n '/^\[/,/^\]/p' | jq -r '
|
|
63
|
+
group_by(.n_threads)[]
|
|
64
|
+
| [.[0].n_threads,
|
|
65
|
+
(map(select(.n_prompt > 0 and .n_gen == 0)) | .[0].avg_ts // 0),
|
|
66
|
+
(map(select(.n_gen > 0 and .n_prompt == 0)) | .[0].avg_ts // 0)]
|
|
67
|
+
| @tsv' 2>/dev/null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Best row (generation speed, then fewer threads) and the verdict, from the
|
|
71
|
+
# rows on stdin: prints the table then "best=<n>" and "ok=0|1"
|
|
72
|
+
bench_report() {
|
|
73
|
+
awk -v mpp="${LLM_BENCH_MIN_PP:-50}" -v mtg="${LLM_BENCH_MIN_TG:-8}" '
|
|
74
|
+
{ t[NR] = $1; pp[NR] = $2; tg[NR] = $3 }
|
|
75
|
+
END {
|
|
76
|
+
printf "%-8s %-22s %s\n", "threads", "prompt (tok/s)", "generation (tok/s)"
|
|
77
|
+
b = 0
|
|
78
|
+
for (i = 1; i <= NR; i++) {
|
|
79
|
+
printf "%-8s %-22.1f %.1f\n", t[i], pp[i], tg[i]
|
|
80
|
+
if (b == 0 || tg[i] > tg[b] || (tg[i] == tg[b] && t[i] + 0 < t[b] + 0)) b = i
|
|
81
|
+
}
|
|
82
|
+
if (b == 0) exit 1
|
|
83
|
+
print "best=" t[b]
|
|
84
|
+
print "ok=" ((pp[b] >= mpp && tg[b] >= mtg) ? 1 : 0)
|
|
85
|
+
}'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Commands proposed to the user, by place: the Kubernetes workspace runs the
|
|
89
|
+
# bench through devzone workspace services (DEVZONE_SERVICES_ADMIN, set by
|
|
90
|
+
# services-admin.sh); the Docker container keeps devzone llm
|
|
91
|
+
bench_cmds() {
|
|
92
|
+
if [ -n "${DEVZONE_SERVICES_ADMIN:-}" ]; then
|
|
93
|
+
CMD_APPLY="devzone workspace services bench llm --apply"
|
|
94
|
+
CMD_LIGHT="devzone workspace services disable llm && devzone workspace services enable llm --preset light"
|
|
95
|
+
else
|
|
96
|
+
CMD_APPLY="devzone llm bench --apply"
|
|
97
|
+
CMD_LIGHT="devzone disable llm && devzone enable llm --preset light"
|
|
98
|
+
fi
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
bench_apply() {
|
|
102
|
+
helm --kube-context devzone upgrade llm "$CHART_CODE/charts/devzone-llm" -n "$NS" --reset-then-reuse-values --set "threads=$1" >/dev/null || return 1
|
|
103
|
+
wait_ready
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
bench() {
|
|
107
|
+
local apply="" want="" arg threads="" prompt="" gen="" sets logs rows report best ok
|
|
108
|
+
local -a args
|
|
109
|
+
for arg in "$@"; do
|
|
110
|
+
if [ -n "$want" ]; then
|
|
111
|
+
case "$want" in
|
|
112
|
+
threads) threads="$arg" ;;
|
|
113
|
+
prompt) prompt="$arg" ;;
|
|
114
|
+
gen) gen="$arg" ;;
|
|
115
|
+
esac
|
|
116
|
+
want=""
|
|
117
|
+
continue
|
|
118
|
+
fi
|
|
119
|
+
case "$arg" in
|
|
120
|
+
--apply) apply=1 ;;
|
|
121
|
+
--threads | --prompt | --gen) want="${arg#--}" ;;
|
|
122
|
+
*) refuse "unknown argument: $arg (devzone llm bench [--apply] [--threads 4,8] [--prompt 128] [--gen 32])" ;;
|
|
123
|
+
esac
|
|
124
|
+
done
|
|
125
|
+
[ -z "$want" ] || refuse "--$want needs a value"
|
|
126
|
+
# In the pod only devzone workspace services (DEVZONE_SERVICES_ADMIN) has rights on the namespace
|
|
127
|
+
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ] && [ -z "${DEVZONE_SERVICES_ADMIN:-}" ]; then
|
|
128
|
+
echo "devzone: llm bench runs from your computer: devzone workspace services bench llm" >&2
|
|
129
|
+
exit 2
|
|
130
|
+
fi
|
|
131
|
+
bench_present || refuse "bench: the module is not enabled (devzone enable llm)"
|
|
132
|
+
sets="$(llm_preset_sets "$(preset_read)") bench.enabled=true"
|
|
133
|
+
[ -z "$threads" ] || sets="$sets bench.threads=${threads//,/\\,}" # helm --set: a comma separates keys
|
|
134
|
+
[ -z "$prompt" ] || sets="$sets bench.prompt=$prompt"
|
|
135
|
+
[ -z "$gen" ] || sets="$sets bench.gen=$gen"
|
|
136
|
+
sets="$sets bench.deadline=${LLM_BENCH_ATTENTE:-1800}"
|
|
137
|
+
args=()
|
|
138
|
+
for arg in $sets; do args+=(--set "$arg"); done
|
|
139
|
+
trap bench_cleanup EXIT INT TERM
|
|
140
|
+
bench_cleanup
|
|
141
|
+
echo "▶ llama-bench in the namespace $NS (image full-<build>: larger than the server image, pulled on first use; the server keeps running, so the numbers are a bit low)…"
|
|
142
|
+
helm template llm "$CHART_CODE/charts/devzone-llm" -n "$NS" "${args[@]}" --show-only templates/bench-job.yaml | k apply -f - >/dev/null || return 1
|
|
143
|
+
bench_wait || {
|
|
144
|
+
echo "devzone: llm: bench Job failed or timed out (LLM_BENCH_ATTENTE=${LLM_BENCH_ATTENTE:-1800}s): kubectl --context devzone -n $NS logs job/$BENCH_JOB" >&2
|
|
145
|
+
k logs "job/$BENCH_JOB" --tail=5 >&2 2>/dev/null || true
|
|
146
|
+
return 1
|
|
147
|
+
}
|
|
148
|
+
logs="$(k logs "job/$BENCH_JOB" 2>/dev/null || true)"
|
|
149
|
+
rows="$(printf '%s\n' "$logs" | bench_rows)"
|
|
150
|
+
[ -n "$rows" ] || { echo "devzone: llm: no llama-bench result in the logs of the Job" >&2; return 1; }
|
|
151
|
+
report="$(printf '%s\n' "$rows" | bench_report)"
|
|
152
|
+
printf '%s\n' "$report" | grep -v '^best=\|^ok='
|
|
153
|
+
best="$(printf '%s\n' "$report" | sed -n 's/^best=//p')"
|
|
154
|
+
ok="$(printf '%s\n' "$report" | sed -n 's/^ok=//p')"
|
|
155
|
+
echo "▶ Recommended: threads=$best"
|
|
156
|
+
bench_cmds
|
|
157
|
+
if [ "$ok" = 1 ]; then
|
|
158
|
+
echo "✔ Fast enough for opencode (prompt >= ${LLM_BENCH_MIN_PP:-50} tok/s, generation >= ${LLM_BENCH_MIN_TG:-8} tok/s)"
|
|
159
|
+
else
|
|
160
|
+
echo "⚠ Too slow for opencode (needs prompt >= ${LLM_BENCH_MIN_PP:-50} tok/s and generation >= ${LLM_BENCH_MIN_TG:-8} tok/s)"
|
|
161
|
+
if [ "$(preset_read)" != light ]; then
|
|
162
|
+
echo " Lighter model (3B, context 16k, 2.1 GB download): $CMD_LIGHT"
|
|
163
|
+
fi
|
|
164
|
+
fi
|
|
165
|
+
if [ -n "$apply" ]; then
|
|
166
|
+
bench_apply "$best" || return 1
|
|
167
|
+
echo "✔ threads=$best applied to the release llm"
|
|
168
|
+
else
|
|
169
|
+
echo " $CMD_APPLY sets threads=$best on the release"
|
|
170
|
+
fi
|
|
171
|
+
}
|