devzone 0.45.1 → 0.46.1

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.
@@ -21,6 +21,11 @@ ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
21
21
  # shellcheck source=SCRIPTDIR/../isolement.sh
22
22
  # shellcheck disable=SC1091
23
23
  . "$ICI/../isolement.sh"
24
+ # Shared memory check of the services cluster (#608): quantite_ki and
25
+ # memoire_cluster_ki.
26
+ # shellcheck source=SCRIPTDIR/../memoire.sh
27
+ # shellcheck disable=SC1091
28
+ . "$ICI/../memoire.sh"
24
29
 
25
30
  NS=devzone-argocd
26
31
  SECRETS="$RACINE/workspace/.argocd"
@@ -38,42 +43,6 @@ regenerer_identifiants() {
38
43
  echo "devzone : argocd : identifiants regroupés non mis à jour (devzone passwords)" >&2
39
44
  }
40
45
 
41
- # Convertit une quantité de mémoire Kubernetes (Ki, Mi, Gi, K, M, G, octets)
42
- # en Kio, pour additionner la mémoire allouable des nœuds.
43
- quantite_ki() {
44
- local q="${1:-}" nombre
45
- case "$q" in
46
- *Ki) nombre="${q%Ki}"; echo $((nombre)) ;;
47
- *Mi) nombre="${q%Mi}"; echo $((nombre * 1024)) ;;
48
- *Gi) nombre="${q%Gi}"; echo $((nombre * 1024 * 1024)) ;;
49
- *Ti) nombre="${q%Ti}"; echo $((nombre * 1024 * 1024 * 1024)) ;;
50
- *K | *k) nombre="${q%[Kk]}"; echo $((nombre * 1000 / 1024)) ;;
51
- *M) nombre="${q%M}"; echo $((nombre * 1000 * 1000 / 1024)) ;;
52
- *G) nombre="${q%G}"; echo $((nombre * 1000 * 1000 * 1000 / 1024)) ;;
53
- *)
54
- case "$q" in
55
- '' | *[!0-9]*) echo 0 ;;
56
- *) echo $((q / 1024)) ;;
57
- esac
58
- ;;
59
- esac
60
- }
61
-
62
- # Somme des mémoires allouables des nœuds du cluster des services, en Kio ;
63
- # échoue si le cluster ne répond pas. Lecture des nœuds réservée à
64
- # l'administrateur (#430).
65
- memoire_cluster_ki() {
66
- local sortie valeur total=0
67
- sortie="$(compte_admin "$(compte_ctx)" get nodes \
68
- -o jsonpath='{range .items[*]}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
69
- [ -n "$sortie" ] || return 1
70
- while IFS= read -r valeur; do
71
- [ -n "$valeur" ] || continue
72
- total=$((total + $(quantite_ki "$valeur")))
73
- done <<<"$sortie"
74
- echo "$total"
75
- }
76
-
77
46
  # Refuse l'installation sous 1 Go de mémoire allouable dans le cluster ; le
78
47
  # message indique où agrandir le cluster et la commande à relancer.
79
48
  verifier_memoire() {
@@ -6,62 +6,18 @@
6
6
  # Le chart enveloppe charts/devzone-gitlab (#538) porte les dépendances et les
7
7
  # valeurs ; chart.sh (helm direct) et argocd.sh (Application) l'installent.
8
8
 
9
+ # Shared memory check of the services cluster (#608): quantite_ki,
10
+ # memoire_cluster_ki and verifier_memoire_module.
11
+ # shellcheck source=SCRIPTDIR/../memoire.sh
12
+ # shellcheck disable=SC1091
13
+ . "$ICI/../memoire.sh"
14
+
9
15
  # Namespace isolé du module : un par instance, comme postgres
10
16
  GITLAB_NS="devzone-gitlab${INSTANCE_SUFFIX}"
11
17
  # Ancien cluster kind de GitLab, supprimé par « devzone gitlab migrate »
12
18
  GITLAB_ANCIEN_CLUSTER="gitlab${INSTANCE_SUFFIX}"
13
19
  GITLAB_ANCIEN_CONTEXTE="kind-gitlab${INSTANCE_SUFFIX}"
14
20
 
15
- # Convertit une quantité de mémoire Kubernetes (Ki, Mi, Gi, K, M, G, octets)
16
- # en Kio, pour additionner la mémoire allouable des nœuds.
17
- quantite_ki() {
18
- local q="${1:-}" nombre
19
- case "$q" in
20
- *Ki) nombre="${q%Ki}"; echo $((nombre)) ;;
21
- *Mi) nombre="${q%Mi}"; echo $((nombre * 1024)) ;;
22
- *Gi) nombre="${q%Gi}"; echo $((nombre * 1024 * 1024)) ;;
23
- *Ti) nombre="${q%Ti}"; echo $((nombre * 1024 * 1024 * 1024)) ;;
24
- *K | *k) nombre="${q%[Kk]}"; echo $((nombre * 1000 / 1024)) ;;
25
- *M) nombre="${q%M}"; echo $((nombre * 1000 * 1000 / 1024)) ;;
26
- *G) nombre="${q%G}"; echo $((nombre * 1000 * 1000 * 1000 / 1024)) ;;
27
- *)
28
- case "$q" in
29
- '' | *[!0-9]*) echo 0 ;;
30
- *) echo $((q / 1024)) ;;
31
- esac
32
- ;;
33
- esac
34
- }
35
-
36
- # Somme des mémoires allouables des nœuds du cluster des services, en Kio.
37
- # Lecture des nœuds réservée à l'administrateur (#430).
38
- gitlab_memoire_cluster_ki() {
39
- local sortie valeur total=0
40
- sortie="$(compte_admin "$(compte_ctx)" get nodes \
41
- -o jsonpath='{range .items[*]}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
42
- [ -n "$sortie" ] || return 1
43
- while IFS= read -r valeur; do
44
- [ -n "$valeur" ] || continue
45
- total=$((total + $(quantite_ki "$valeur")))
46
- done <<<"$sortie"
47
- echo "$total"
48
- }
49
-
50
- # Refuse l'installation sous 8 Go de mémoire allouable dans le cluster.
51
- # Le message indique où agrandir le cluster (Docker Desktop) et la commande.
52
- gitlab_verifier_memoire_cluster() {
53
- local memoire
54
- if ! memoire="$(gitlab_memoire_cluster_ki)"; then
55
- echo "devzone : gitlab : cluster des services injoignable : devzone cluster" >&2
56
- return 2
57
- fi
58
- if [ "$memoire" -lt 8388608 ]; then
59
- echo "devzone : gitlab : il faut au moins 8 Go de mémoire allouable dans le cluster (disponible : $((memoire / 1048576)) Go) ; agrandir le cluster (Docker Desktop → Settings → Resources) puis relancer : devzone enable gitlab" >&2
60
- return 2
61
- fi
62
- return 0
63
- }
64
-
65
21
  # Namespace présent dans le cluster des services : GitLab est installé.
66
22
  # Lecture des namespaces réservée à l'administrateur (#430).
67
23
  gitlab_installe() {
@@ -80,7 +36,7 @@ gitlab_namespace_preparer() {
80
36
  # l'accès (relais web/SSH, /etc/hosts) et le seed des données de test.
81
37
  gitlab_installer() {
82
38
  echo "▶ Vérification de la mémoire allouable du cluster des services…"
83
- gitlab_verifier_memoire_cluster || return 2
39
+ verifier_memoire_module gitlab 8 || return 2
84
40
 
85
41
  mkdir -p "$GITLAB_SECRETS_DIR"
86
42
  gitlab_namespace_preparer
@@ -31,6 +31,10 @@ ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
31
31
  # shellcheck source=SCRIPTDIR/bench.sh
32
32
  # shellcheck disable=SC1091
33
33
  . "$ICI/bench.sh"
34
+ # Memory check of the services cluster, shared with the other modules (#608)
35
+ # shellcheck source=SCRIPTDIR/../memoire.sh
36
+ # shellcheck disable=SC1091
37
+ . "$ICI/../memoire.sh"
34
38
 
35
39
  NS=devzone-llm
36
40
  STATE_DIR="$RACINE/workspace/.llm"
@@ -122,9 +126,18 @@ wait_ready() {
122
126
  }
123
127
 
124
128
  install() {
125
- local ctx sets
129
+ local ctx sets minimum_go=12 astuce=""
126
130
  local -a args
131
+
127
132
  preset_store "$@"
133
+ # The light preset (3B) asks for 8 Gi, the 7B model for 12 Gi
134
+ if [ "$(preset_read)" = light ]; then
135
+ minimum_go=8
136
+ else
137
+ astuce="--preset light (8 Go)"
138
+ fi
139
+ verifier_memoire_module llm "$minimum_go" "$astuce" || return 2
140
+
128
141
  ctx="$(cluster_lu)"
129
142
  if [ -z "$ctx" ]; then
130
143
  ctx="$(cluster_choisir "$WANTED_CTX")" || return 2
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env bash
2
+ # Memory check of the services cluster (#608, #612): a module refuses its
3
+ # installation when the allocatable memory of the nodes is below its minimum.
4
+ # Sourced by the modules (gitlab, llm) and by the tests; bash 3.2 (macOS).
5
+ # quantite_ki <quantite> Kubernetes quantity in Ki
6
+ # memoire_cluster_ki allocatable memory of the cluster, in Ki
7
+ # verifier_memoire_module <module> <minimum_go> [astuce]
8
+ # Messages in French. Return 0 when the memory is enough, 2 when it is not or
9
+ # when the cluster is unreachable.
10
+
11
+ # Globals written by memoire_cluster_ki (#612) and read by
12
+ # verifier_memoire_module, which calls the function directly: a call written
13
+ # memoire="$(memoire_cluster_ki)" would run it in a subshell and lose them.
14
+ # Callers that only need the number keep using $(memoire_cluster_ki): the
15
+ # value is still printed on stdout (argocd, gitlab, llm are unaffected).
16
+ # MEMOIRE_KI same value as on stdout, in Ki
17
+ # MEMOIRE_REGLE "maximum" when every node is a kind node (the nodes share
18
+ # one VM), "somme" otherwise
19
+ MEMOIRE_KI=""
20
+ MEMOIRE_REGLE=""
21
+
22
+ # Converts a Kubernetes memory quantity (Ki, Mi, Gi, Ti, K, M, G, bytes)
23
+ # into Ki, to total the allocatable memory of the nodes.
24
+ quantite_ki() {
25
+ local q="${1:-}" nombre
26
+ case "$q" in
27
+ *Ki) nombre="${q%Ki}"; echo $((nombre)) ;;
28
+ *Mi) nombre="${q%Mi}"; echo $((nombre * 1024)) ;;
29
+ *Gi) nombre="${q%Gi}"; echo $((nombre * 1024 * 1024)) ;;
30
+ *Ti) nombre="${q%Ti}"; echo $((nombre * 1024 * 1024 * 1024)) ;;
31
+ *K | *k) nombre="${q%[Kk]}"; echo $((nombre * 1000 / 1024)) ;;
32
+ *M) nombre="${q%M}"; echo $((nombre * 1000 * 1000 / 1024)) ;;
33
+ *G) nombre="${q%G}"; echo $((nombre * 1000 * 1000 * 1000 / 1024)) ;;
34
+ *)
35
+ case "$q" in
36
+ '' | *[!0-9]*) echo 0 ;;
37
+ *) echo $((q / 1024)) ;;
38
+ esac
39
+ ;;
40
+ esac
41
+ }
42
+
43
+ # Allocatable memory of the services cluster nodes, in Ki. Reading the nodes
44
+ # is reserved to the administrator (#430). One kubectl call gives, per node,
45
+ # its providerID and its allocatable memory on one "<providerID>|<memory>"
46
+ # line (#612). A kind cluster runs on a single Docker daemon: its nodes share
47
+ # the memory of one VM and each of them declares the whole VM, so adding them
48
+ # up lies. When every providerID starts with "kind://" the greatest node
49
+ # memory is returned (MEMOIRE_REGLE=maximum); as soon as one node has no such
50
+ # prefix or an empty providerID the sum is returned (MEMOIRE_REGLE=somme), as
51
+ # before. Known limit, documented: k3d and minikube in Docker mode share a VM
52
+ # too but are not kind, they stay on the sum. A line without the separator
53
+ # carries the memory alone, so it is a node without providerID (sum).
54
+ memoire_cluster_ki() {
55
+ local sortie ligne providerID memoire noeud total=0 max=0 n=0 tous_kind=1
56
+ MEMOIRE_KI=""
57
+ MEMOIRE_REGLE=""
58
+ sortie="$(compte_admin "$(compte_ctx)" get nodes \
59
+ -o jsonpath='{range .items[*]}{.spec.providerID}{"|"}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || return 1
60
+ [ -n "$sortie" ] || return 1
61
+ while IFS= read -r ligne; do
62
+ [ -n "$ligne" ] || continue
63
+ case "$ligne" in
64
+ *'|'*)
65
+ providerID="${ligne%%|*}"
66
+ memoire="${ligne#*|}"
67
+ ;;
68
+ *)
69
+ providerID=""
70
+ memoire="$ligne"
71
+ ;;
72
+ esac
73
+ noeud="$(quantite_ki "$memoire")"
74
+ total=$((total + noeud))
75
+ if [ "$noeud" -gt "$max" ]; then max="$noeud"; fi
76
+ case "$providerID" in
77
+ kind://*) ;;
78
+ *) tous_kind=0 ;;
79
+ esac
80
+ n=$((n + 1))
81
+ done <<<"$sortie"
82
+ if [ "$n" -gt 0 ] && [ "$tous_kind" -eq 1 ]; then
83
+ MEMOIRE_REGLE="maximum"
84
+ MEMOIRE_KI="$max"
85
+ else
86
+ MEMOIRE_REGLE="somme"
87
+ MEMOIRE_KI="$total"
88
+ fi
89
+ echo "$MEMOIRE_KI"
90
+ }
91
+
92
+ # Refuses the installation of <module> under <minimum_go> GiB of allocatable
93
+ # memory. The message says the minimum, the available memory and how to enlarge
94
+ # the cluster; [astuce] adds an optional hint (for example --preset light).
95
+ # On a kind cluster (#612) the available memory is the one of a single node
96
+ # and the message says so. Return 0 when the memory is enough, 2 when it is
97
+ # not or the cluster is unreachable.
98
+ verifier_memoire_module() {
99
+ local nom_module="$1" minimum_go="$2" astuce="${3:-}" memoire precision=""
100
+ if ! memoire_cluster_ki >/dev/null; then
101
+ echo "devzone : ${nom_module} : cluster des services injoignable : devzone cluster" >&2
102
+ return 2
103
+ fi
104
+ memoire="$MEMOIRE_KI"
105
+ if [ "$MEMOIRE_REGLE" = "maximum" ]; then
106
+ precision=" (mémoire d'un seul nœud : cluster kind, VM partagée)"
107
+ fi
108
+ if [ "$memoire" -lt "$((minimum_go * 1048576))" ]; then
109
+ echo "devzone : ${nom_module} : il faut au moins ${minimum_go} Go de mémoire allouable dans le cluster (disponible : $((memoire / 1048576)) Go)${precision} ; agrandir le cluster (Docker Desktop → Settings → Resources) puis relancer : devzone enable ${nom_module}${astuce:+ ; astuce : ${astuce}}" >&2
110
+ return 2
111
+ fi
112
+ return 0
113
+ }
package/README.md CHANGED
@@ -47,6 +47,26 @@ Dans les deux cas, rien n'est hébergé : tout tourne sur ta machine. `workspace
47
47
 
48
48
  Sous Windows : il est recommandé de cloner avec Git for Windows (les scripts restent en fins de ligne LF grâce à `.gitattributes`, et la commande npm trouve le `bash` qu'elle exige).
49
49
 
50
+ #### Mémoire minimale par module
51
+
52
+ Mesures du 16/11/2026. Le chiffre LLM vient des valeurs du chart (non mesuré en service).
53
+
54
+ | Module | Consommation mesurée | Mémoire allouable exigée par devzone |
55
+ |---|---|---|
56
+ | Cluster de base | ~4 Go | aucune |
57
+ | GitLab | ~3,6 Go | 8 Go |
58
+ | MySQL | ~0,5 Go | aucune |
59
+ | Argo CD | ~0,6 Go | 1 Go |
60
+ | LLM modèle 7B (7 milliards de paramètres, fichier Q4_K_M) | 6 Gi | 12 Go |
61
+ | LLM --preset light (modèle 3B) | 3 Gi demandés, 4 Gi en limite | 8 Go |
62
+
63
+ Sur Docker Desktop (kind), le contrôle compare le minimum à la mémoire d'un seul nœud, donc à la VM ; sur un cluster de vraies machines, à la somme des nœuds.
64
+
65
+ - **Réglage de la RAM** :
66
+ - **Mac** (Docker Desktop) : *Settings → Resources > Memory*. Autre méthode : modifier `MemoryMiB` dans le fichier `settings-store.json` de Docker Desktop (Docker totalement quitté sinon il réécrit la valeur).
67
+ - **Windows** : fichier `%UserProfile%\.wslconfig` avec `[wsl2]` et `memory=<N>GB`, puis `wsl --shutdown`. WSL2 prend 50 % de la RAM par défaut.
68
+ - **Linux** : rien à régler : pas de VM, la RAM de l'hôte sert.
69
+
50
70
  ### Lancer en une commande
51
71
 
52
72
  Deux façons via npm. Sans installation, à chaque usage :
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.45.1",
3
+ "version": "0.46.1",
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": {