devzone 0.43.0 → 0.44.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.
@@ -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 "opencode/$m" "$(cat "$consigne")" </dev/null >>"$journal" 2>&1) &
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 "opencode/$m" "$(cat "$consigne")" </dev/null >>"$journal" 2>&1) &
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
 
@@ -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 "${#FREE_MODELS[@]}" ]; do
101
- m="${FREE_MODELS[$(( (debut + i) % ${#FREE_MODELS[@]} ))]}"
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 mysql with the module argocd installed and held: enable writes
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=300s >/dev/null 2>&1 && return 0
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)
@@ -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 argocd
305
- # live in the cluster and are installed from the workstation (devzone
306
- # workspace services). The pod has no kubeconfig and its service account is
307
- # limited (#430): their presence is the cluster DNS resolving the service,
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/postgres/postgres.sh" status)"
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 postgres)" = off ] || appliquer_service postgres
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/postgres/postgres.sh" "${@:2}" ;;
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/postgres/postgres.sh" status 2>/dev/null)"; then
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 "postgres.sh etat indisponible"
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
@@ -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,250 @@
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
+ # First start = model download: LLM_ATTENTE (seconds, default 1800) is the wait.
11
+ # The relay LLM_PORT (default 8089) reaches the service. The opencode provider is
12
+ # 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
+
32
+ NS=devzone-llm
33
+ STATE_DIR="$RACINE/workspace/.llm"
34
+ LLM_PORT="${LLM_PORT:-8089}"
35
+ LLM_ATTENTE="${LLM_ATTENTE:-1800}"
36
+ LLM_SIZE="${LLM_SIZE:-8Gi}"
37
+
38
+ refuse() { echo "devzone: llm: $*" >&2; exit 2; }
39
+
40
+ k() { kubectl --context devzone -n "$NS" "$@"; }
41
+
42
+ installed() { compte_admin "$(compte_ctx)" get namespace "$NS" >/dev/null 2>&1; }
43
+
44
+ # Preset stored by the last install, "default" without one
45
+ preset_read() {
46
+ local p
47
+ p="$(cat "$STATE_DIR/preset" 2>/dev/null || true)"
48
+ llm_preset_name "$p" 2>/dev/null || echo default
49
+ }
50
+
51
+ # --preset P and --context C of the arguments: PRESET and WANTED_CTX are set
52
+ parse_args() {
53
+ local want="" arg
54
+ PRESET=""
55
+ WANTED_CTX=""
56
+ for arg in "$@"; do
57
+ if [ -n "$want" ]; then
58
+ case "$want" in
59
+ preset) PRESET="$arg" ;;
60
+ context) WANTED_CTX="$arg" ;;
61
+ esac
62
+ want=""
63
+ continue
64
+ fi
65
+ case "$arg" in
66
+ --preset) want=preset ;;
67
+ --context) want=context ;;
68
+ *) refuse "unknown argument: $arg (devzone enable llm [--preset light] [--context CTX])" ;;
69
+ esac
70
+ done
71
+ [ -z "$want" ] || refuse "--$want needs a value"
72
+ if [ -n "$PRESET" ]; then
73
+ PRESET="$(llm_preset_name "$PRESET")" || refuse "unknown preset (default or light)"
74
+ fi
75
+ }
76
+
77
+ # Stores the preset: the explicit one, else the one already stored
78
+ preset_store() {
79
+ parse_args "$@"
80
+ [ -n "$PRESET" ] || PRESET="$(preset_read)"
81
+ mkdir -p "$STATE_DIR"
82
+ printf '%s\n' "$PRESET" >"$STATE_DIR/preset"
83
+ }
84
+
85
+ # Ingress from the workspace namespace (the pod of the workspace reaches
86
+ # llm:8080), next to the same-namespace rule of namespace_isoler
87
+ policy() {
88
+ kubectl --context devzone -n "$NS" apply -f - >/dev/null <<YAML
89
+ apiVersion: networking.k8s.io/v1
90
+ kind: NetworkPolicy
91
+ metadata:
92
+ name: devzone-llm-workspace
93
+ labels:
94
+ app.kubernetes.io/managed-by: devzone
95
+ spec:
96
+ podSelector: {}
97
+ ingress:
98
+ - from:
99
+ - namespaceSelector:
100
+ matchLabels:
101
+ kubernetes.io/metadata.name: devzone-workspace
102
+ YAML
103
+ }
104
+
105
+ # Waits for the deployment, a progress line each minute (the model is
106
+ # downloaded on the first start)
107
+ wait_ready() {
108
+ local waited=0 step=60
109
+ echo "▶ Waiting for the model (first start: download, several minutes; timeout ${LLM_ATTENTE}s, LLM_ATTENTE)…"
110
+ while [ "$waited" -lt "$LLM_ATTENTE" ]; do
111
+ if k rollout status deployment/llm --timeout="${step}s" >/dev/null 2>&1; then
112
+ return 0
113
+ fi
114
+ waited=$((waited + step))
115
+ echo " … ${waited}s/${LLM_ATTENTE}s: model not ready yet"
116
+ done
117
+ echo "devzone: llm: not ready after ${LLM_ATTENTE}s: kubectl --context devzone -n $NS logs deploy/llm -c fetch-model" >&2
118
+ return 1
119
+ }
120
+
121
+ install() {
122
+ local ctx sets
123
+ local -a args
124
+ preset_store "$@"
125
+ ctx="$(cluster_lu)"
126
+ if [ -z "$ctx" ]; then
127
+ ctx="$(cluster_choisir "$WANTED_CTX")" || return 2
128
+ cluster_ecrire "$ctx"
129
+ fi
130
+ cluster_preparer "$ctx"
131
+ contexte_devzone_poser "$ctx" || { echo "devzone: llm: cannot set the devzone context on $ctx" >&2; return 1; }
132
+ echo "▶ Local model on the cluster $ctx (namespace $NS, preset $(preset_read))…"
133
+ compte_namespace "$ctx" "$NS"
134
+ namespace_isoler "$NS" >/dev/null
135
+ policy
136
+ sets="$(llm_preset_sets "$(preset_read)") size=$LLM_SIZE"
137
+ read -r -a args <<<"$sets"
138
+ chart_install llm "$NS" "${args[@]}" || return 1
139
+ wait_ready || return 1
140
+ relais_arreter llm
141
+ relais_lancer llm "$ctx" "$NS" svc/llm "$LLM_PORT:8080"
142
+ bash "$ICI/opencode.sh" set
143
+ echo "✔ Local model ready: http://llm.$NS.svc.cluster.local:8080/v1 (127.0.0.1:$LLM_PORT here)"
144
+ }
145
+
146
+ # The release leaves, the volume (model) and the namespace stay
147
+ uninstall() {
148
+ local ctx
149
+ ctx="$(cluster_lu)"
150
+ relais_arreter llm
151
+ bash "$ICI/opencode.sh" unset
152
+ if [ -n "$ctx" ] && installed; then
153
+ contexte_devzone_poser "$ctx" || true
154
+ helm --kube-context devzone uninstall llm -n "$NS" >/dev/null 2>&1 || true
155
+ echo "✔ llm removed from $ctx; volume llm-models kept (devzone llm delete-data removes it)"
156
+ fi
157
+ }
158
+
159
+ delete_data() {
160
+ local ctx yes="" answer
161
+ ctx="$(cluster_lu)"
162
+ [ "${1:-}" != --yes ] || yes=1
163
+ installed || { echo "devzone: llm: nothing to delete"; return 0; }
164
+ if [ -z "$yes" ]; then
165
+ cluster_interactif || refuse "no terminal: devzone llm delete-data --yes"
166
+ printf 'Delete the namespace %s and the downloaded model? [y/N] ' "$NS" >&2
167
+ read -r answer || answer=""
168
+ case "$answer" in y | Y | yes | o | O | oui) ;; *) echo "Aborted: nothing deleted."; return 0 ;; esac
169
+ fi
170
+ uninstall
171
+ compte_retirer "$ctx" "$NS" >/dev/null 2>&1 || true
172
+ compte_admin "$ctx" delete namespace "$NS" --wait=true >/dev/null
173
+ cluster_liberer "$ctx"
174
+ echo "✔ namespace $NS and model volume deleted"
175
+ }
176
+
177
+ status() {
178
+ local ctx mem
179
+ ctx="$(cluster_lu)"
180
+ if [ -z "$ctx" ] || ! installed; then
181
+ echo "disabled"
182
+ return 0
183
+ fi
184
+ if [ "$(k get deployment llm -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" != 1 ]; then
185
+ echo "not ready on $ctx: starting (first download) or failed, devzone apply"
186
+ return 0
187
+ fi
188
+ mem="$(k get deployment llm -o jsonpath='{.spec.template.spec.containers[0].resources.limits.memory}' 2>/dev/null || true)"
189
+ if relais_actif llm; then
190
+ echo "ready on $ctx: $(llm_preset_file "$(preset_read)"), memory limit ${mem:-?}, reachable 127.0.0.1:$LLM_PORT"
191
+ else
192
+ echo "ready on $ctx: $(llm_preset_file "$(preset_read)"), memory limit ${mem:-?}, relay stopped: devzone apply"
193
+ fi
194
+ }
195
+
196
+ relay_start() {
197
+ local ctx
198
+ ctx="$(cluster_lu)"
199
+ if [ -n "$ctx" ] && installed; then
200
+ relais_lancer llm "$ctx" "$NS" svc/llm "$LLM_PORT:8080"
201
+ fi
202
+ }
203
+
204
+ # Writes llm=off in the state file (bad argument, no cluster)
205
+ state_off() {
206
+ [ -f "$ETAT" ] || return 0
207
+ grep -v '^llm=' "$ETAT" >"$ETAT.tmp" || true
208
+ echo "llm=off" >>"$ETAT.tmp"
209
+ mv "$ETAT.tmp" "$ETAT"
210
+ }
211
+
212
+ # What `devzone enable|disable llm` runs: on installs (or restarts the relay),
213
+ # off removes the release; a failure leaves a marker read by devzone status
214
+ apply() {
215
+ local action="${1:-}" current marker="$ETAT-echec-llm"
216
+ shift || true
217
+ if [ "$action" = on ]; then
218
+ current="$(status)"
219
+ if [[ "$current" == *"relay stopped"* ]]; then
220
+ relay_start
221
+ echo "devzone: llm: relay restarted"
222
+ elif [[ "$current" == "ready on"* ]]; then
223
+ bash "$ICI/opencode.sh" set && echo "devzone: llm already active, nothing to do."
224
+ elif ! bash "${BASH_SOURCE[0]}" install "$@"; then
225
+ state_off
226
+ echo llm >"$marker"
227
+ return 1
228
+ fi
229
+ rm -f "$marker"
230
+ else
231
+ uninstall
232
+ rm -f "$marker"
233
+ fi
234
+ }
235
+
236
+ case "${1:-}" in
237
+ install) install "${@:2}" ;;
238
+ uninstall) uninstall ;;
239
+ status) status ;;
240
+ preset) preset_store "${@:2}" ;;
241
+ policy) policy ;;
242
+ apply) apply "${@:2}" ;;
243
+ delete-data) delete_data "${2:-}" ;;
244
+ relay-start) relay_start ;;
245
+ relay-stop) relais_arreter llm ;;
246
+ *)
247
+ echo "devzone llm: status | delete-data [--yes]" >&2
248
+ exit 1
249
+ ;;
250
+ 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,5 +1,5 @@
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)
@@ -18,6 +18,9 @@
18
18
  set -euo pipefail
19
19
 
20
20
  HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ # The devzone command beside this script, not the one of the PATH: the copy
22
+ # that runs the installers is the one of this folder (#591)
23
+ DEVZONE_CMD="$HERE/devzone"
21
24
  RACINE="${DEVZONE_RACINE:-$(dirname "$HERE")}"
22
25
  ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
23
26
  SA_DIR="${DEVZONE_SA_DIR:-/var/run/secrets/kubernetes.io/serviceaccount}"
@@ -41,11 +44,11 @@ case "$action" in
41
44
  enable | activer) action=enable ;;
42
45
  disable | desactiver) action=disable ;;
43
46
  seed) ;;
44
- *) refuse "usage: services-admin.sh enable|disable|seed gitlab|postgres|argocd [options]" ;;
47
+ *) refuse "usage: services-admin.sh enable|disable|seed gitlab|postgres|argocd|llm [options]" ;;
45
48
  esac
46
49
  case "$service" in
47
- gitlab | postgres | argocd) ;;
48
- *) refuse "unknown service: ${service:-(none)} (gitlab, postgres, argocd)" ;;
50
+ gitlab | postgres | argocd | llm) ;;
51
+ *) refuse "unknown service: ${service:-(none)} (gitlab, postgres, argocd, llm)" ;;
49
52
  esac
50
53
  # The seed of the data (group, demo project, dev user, runner) is gitlab's (#538)
51
54
  if [ "$action" = seed ] && [ "$service" != gitlab ]; then
@@ -68,7 +71,7 @@ cluster_before="$(grep -E '^cluster=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f
68
71
  # cluster line of the state as before
69
72
  cleanup() {
70
73
  rm -f "$kubeconfig"
71
- devzone "$service" relay-stop >/dev/null 2>&1 || true
74
+ "$DEVZONE_CMD" "$service" relay-stop >/dev/null 2>&1 || true
72
75
  if [ -n "$cluster_before" ]; then
73
76
  etat_ecrire cluster "$cluster_before" || true
74
77
  else
@@ -110,6 +113,6 @@ etat_ecrire cluster "$ADMIN_CONTEXT" || refuse "cannot write the state: $ETAT"
110
113
  echo "devzone services: $action $service in the cluster of the pod (temporary administrator)"
111
114
  case "$action" in
112
115
  # The seed is a module command: devzone gitlab seed (#538)
113
- seed) devzone gitlab seed "${@:3}" ;;
114
- *) devzone "$action" "$service" "${@:3}" ;;
116
+ seed) "$DEVZONE_CMD" gitlab seed "${@:3}" ;;
117
+ *) "$DEVZONE_CMD" "$action" "$service" "${@:3}" ;;
115
118
  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.3
2
+ REPOWARDEN_VERSION=4.17.4
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,6 @@
1
+ apiVersion: v2
2
+ name: devzone-llm
3
+ description: Local code model of devzone, llama.cpp llama-server on CPU with a GGUF model on a volume (#586)
4
+ type: application
5
+ version: 0.1.0
6
+ appVersion: "b12407"
@@ -0,0 +1,97 @@
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 }}
58
+ args:
59
+ - --host
60
+ - 0.0.0.0
61
+ - --port
62
+ - "8080"
63
+ - -m
64
+ - /models/{{ .Values.model.file }}
65
+ - -c
66
+ - {{ .Values.contextSize | quote }}
67
+ - --cache-type-k
68
+ - {{ .Values.cacheType | quote }}
69
+ - --cache-type-v
70
+ - {{ .Values.cacheType | quote }}
71
+ - --flash-attn
72
+ - {{ .Values.flashAttention | quote }}
73
+ - -t
74
+ - {{ .Values.threads | quote }}
75
+ ports:
76
+ - containerPort: 8080
77
+ name: http
78
+ readinessProbe:
79
+ httpGet:
80
+ path: /health
81
+ port: 8080
82
+ initialDelaySeconds: 10
83
+ periodSeconds: 10
84
+ failureThreshold: 30
85
+ resources:
86
+ requests:
87
+ cpu: {{ .Values.resources.requests.cpu }}
88
+ memory: {{ .Values.memory }}
89
+ limits:
90
+ memory: {{ .Values.resources.limits.memory }}
91
+ volumeMounts:
92
+ - name: models
93
+ mountPath: /models
94
+ volumes:
95
+ - name: models
96
+ persistentVolumeClaim:
97
+ 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
@@ -0,0 +1,46 @@
1
+ # The one definition of the local model: the helm-direct path installs this
2
+ # chart (.devcontainer/llm/llm.sh) as the release llm. No Secret: the model is
3
+ # public and checked by its sha256.
4
+ # Official llama.cpp server image, CPU, pinned build
5
+ image: ghcr.io/ggml-org/llama.cpp:server-b12407
6
+ # Image of the init container that downloads and checks the model
7
+ fetchImage: curlimages/curl:8.11.1
8
+ # Port of the Service and of llama-server
9
+ port: 8080
10
+ # Memory request of the container (the limit is resources.limits.memory)
11
+ memory: 6Gi
12
+ # Name of the volume claim holding the models; kept when the release goes
13
+ claim: llm-models
14
+ # Size of the models volume
15
+ size: 8Gi
16
+ # Context size (-c) and threads (-t) of llama-server. 32768 is the native
17
+ # window of Qwen2.5; the light preset uses 16384 (--set contextSize=16384).
18
+ contextSize: 32768
19
+ # KV cache type for K and V (--cache-type-k / --cache-type-v): q8_0 costs about
20
+ # 1 GB at 32k for the 7B (f16 about 1.9 GB). A quantized V cache needs flash
21
+ # attention.
22
+ cacheType: q8_0
23
+ # Flash attention (--flash-attn on|off|auto in server-b12407)
24
+ flashAttention: "on"
25
+ threads: 4
26
+ # The model: downloaded only when the file is missing, then its sha256 is
27
+ # checked (the file is removed and the pod fails when it differs). The URL is
28
+ # pinned to a Hugging Face commit (resolve/<commit>).
29
+ # Preset "qwen2.5-coder-7b-instruct-q4_k_m" (default, 4.7 GB):
30
+ # url: https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF/resolve/13fb94bfda8c8cf22497dc57b78f391a9acb426a/qwen2.5-coder-7b-instruct-q4_k_m.gguf
31
+ # file: qwen2.5-coder-7b-instruct-q4_k_m.gguf
32
+ # sha256: 509287f78cb4d4cf6b3843734733b914b2c158e43e22a7f4bf5e963800894d3c
33
+ # Preset "qwen2.5-coder-3b-instruct-q4_k_m" (light, 2.1 GB; memory=3Gi,
34
+ # resources.limits.memory=4Gi and contextSize=16384):
35
+ # url: https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct-GGUF/resolve/f74adce6aa16316c625447af059dbebe4983757c/qwen2.5-coder-3b-instruct-q4_k_m.gguf
36
+ # file: qwen2.5-coder-3b-instruct-q4_k_m.gguf
37
+ # sha256: 724fb256bec1ff062b2f65e4569e871ad2e95ab2a3989723d1769c54294730b7
38
+ model:
39
+ url: https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct-GGUF/resolve/13fb94bfda8c8cf22497dc57b78f391a9acb426a/qwen2.5-coder-7b-instruct-q4_k_m.gguf
40
+ file: qwen2.5-coder-7b-instruct-q4_k_m.gguf
41
+ sha256: 509287f78cb4d4cf6b3843734733b914b2c158e43e22a7f4bf5e963800894d3c
42
+ resources:
43
+ requests:
44
+ cpu: 500m
45
+ limits:
46
+ memory: 7Gi
package/manage/devzone CHANGED
@@ -582,7 +582,7 @@ commande_du_conteneur() {
582
582
  case "$1" in
583
583
  actif | activer | agent | appliquer | argocd | build | catalogue | cluster | clusters | \
584
584
  demarrer | desactiver | etat | gitlab | metrics | modules | mots-de-passe | \
585
- mysql | paquets | plateforme | port | postgres | reparer | test-bash32 | \
585
+ llm | mysql | paquets | plateforme | port | postgres | reparer | test-bash32 | \
586
586
  test-gitlab | ticket | utiliser) return 0 ;;
587
587
  # English names of the container commands (#502)
588
588
  is-enabled | enable | disable | apply | catalog | start | status | \
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # CI check: in the shell scripts tracked by git, a variable name immediately
3
+ # followed by a non-ASCII byte must be written ${NAME}. Under the macOS locale
4
+ # bash reads the multi-byte character as part of the name, so $NAME followed by
5
+ # an accented letter or an ellipsis breaks (#591). Scripts checked: *.sh,
6
+ # *.bash, .devcontainer/devzone, manage/devzone, and any tracked file whose
7
+ # first line is a bash shebang. A fault is printed as "path:line: text" and the
8
+ # run exits 1; otherwise it prints "utf8 vars check: N files ok" and exits 0.
9
+ # bash 3.2 (macOS).
10
+
11
+ set -u
12
+
13
+ ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
+ ROOT="$(cd "$ICI/../.." && pwd)"
15
+
16
+ # Byte matching only. The class is every byte outside printable ASCII, minus
17
+ # the tab (a tab after a name is not a fault). Built from a printf so this
18
+ # file holds no literal non-ASCII byte and never matches its own rule.
19
+ TAB="$(printf '\t')"
20
+ PATTERN='\$[A-Za-z_][A-Za-z_0-9]*[^ -~'"$TAB"']'
21
+
22
+ LC_ALL=C
23
+ export LC_ALL
24
+
25
+ # True when the tracked file $1 (relative to ROOT) is a bash script
26
+ is_bash_script() {
27
+ local first
28
+ case "$1" in
29
+ *.sh | *.bash | .devcontainer/devzone | manage/devzone) return 0 ;;
30
+ esac
31
+ first="$(head -n 1 "$ROOT/$1" 2>/dev/null)"
32
+ case "$first" in
33
+ '#!'*bash*) return 0 ;;
34
+ esac
35
+ return 1
36
+ }
37
+
38
+ files="$(git -C "$ROOT" ls-files)" || {
39
+ echo "check-utf8-vars: git ls-files fails in $ROOT" >&2
40
+ exit 1
41
+ }
42
+
43
+ fails=0
44
+ count=0
45
+ while IFS= read -r f; do
46
+ [ -n "$f" ] || continue
47
+ [ -f "$ROOT/$f" ] || continue
48
+ is_bash_script "$f" || continue
49
+ count=$((count + 1))
50
+ matches="$(grep -naE -- "$PATTERN" "$ROOT/$f")" || matches=""
51
+ while IFS= read -r m; do
52
+ [ -n "$m" ] || continue
53
+ n="${m%%:*}"
54
+ printf '%s:%s: %s\n' "$f" "$n" "${m#*:}"
55
+ fails=1
56
+ done <<EOF
57
+ $matches
58
+ EOF
59
+ done <<EOF
60
+ $files
61
+ EOF
62
+
63
+ if [ "$fails" -ne 0 ]; then
64
+ echo "check-utf8-vars: write \${NAME} instead of \$NAME before a non-ASCII byte" >&2
65
+ exit 1
66
+ fi
67
+ echo "utf8 vars check: $count files ok"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # devzone workspace services (#528): installs or removes the devzone services
3
- # (gitlab, postgres, mysql, argocd) of a Kubernetes workspace from the workstation.
3
+ # (gitlab, postgres, mysql, argocd, llm) of a Kubernetes workspace from the workstation.
4
4
  # Sourced by manage/workspace.sh (drapeau_kubectl, POD, NAMESPACE).
5
5
  # devzone workspace services enable <service> [options]
6
6
  # devzone workspace services disable <service> [--yes]
@@ -19,12 +19,12 @@ SERVICES_ADMIN_SCRIPT="${DEVZONE_SERVICES_ADMIN_SCRIPT:-/usr/local/share/devzone
19
19
  SERVICES_TOKEN_DURATION="${DEVZONE_SERVICES_TOKEN_DURATION:-1h}"
20
20
 
21
21
  services_usage() {
22
- echo "devzone workspace services enable|disable <gitlab|postgres|mysql|argocd> [options] | seed gitlab | status"
22
+ echo "devzone workspace services enable|disable <gitlab|postgres|mysql|argocd|llm> [options] | seed gitlab | status"
23
23
  }
24
24
 
25
25
  services_known() {
26
26
  case "${1:-}" in
27
- gitlab | postgres | mysql | argocd) return 0 ;;
27
+ gitlab | postgres | mysql | argocd | llm) return 0 ;;
28
28
  esac
29
29
  return 1
30
30
  }
@@ -36,6 +36,7 @@ services_namespace() {
36
36
  postgres) echo devzone-postgres ;;
37
37
  mysql) echo devzone-mysql ;;
38
38
  argocd) echo devzone-argocd ;;
39
+ llm) echo devzone-llm ;;
39
40
  esac
40
41
  }
41
42
 
@@ -99,7 +100,7 @@ services_run() {
99
100
  return
100
101
  fi
101
102
  case "$service" in
102
- postgres | mysql)
103
+ postgres | mysql | llm)
103
104
  if argocd_holds_charts; then
104
105
  services_argocd_toggle "$service" "$action" "$@"
105
106
  return
@@ -124,7 +125,7 @@ services_run() {
124
125
  trap - EXIT
125
126
  return 1
126
127
  fi
127
- echo "▶ $action $service in the pod $POD…"
128
+ echo "▶ $action $service in the pod ${POD}…"
128
129
  # The installer of the pod takes --yes (#557) : no translation, no warning
129
130
  # shellcheck disable=SC2046
130
131
  printf '%s\n' "$token" | kubectl $(drapeau_kubectl) exec -i "$POD" --namespace "$NAMESPACE" \
@@ -141,7 +142,7 @@ services_run() {
141
142
  # One line per service: installed (namespace present) or not
142
143
  services_status() {
143
144
  local s ns
144
- for s in gitlab postgres mysql argocd; do
145
+ for s in gitlab postgres mysql argocd llm; do
145
146
  ns="$(services_namespace "$s")"
146
147
  # shellcheck disable=SC2046
147
148
  if kubectl $(drapeau_kubectl) get namespace "$ns" >/dev/null 2>&1; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {