devzone 1.0.0 → 2.0.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/Dockerfile +4 -4
- package/.devcontainer/agent-errors.sh +154 -0
- package/.devcontainer/agent-local.sh +2 -2
- package/.devcontainer/{agent-modele.messages → agent-model.messages} +1 -1
- package/.devcontainer/{agent-modele.sh → agent-model.sh} +8 -8
- package/.devcontainer/{agent-droits.sh → agent-rights.sh} +2 -2
- package/.devcontainer/agent-session.sh +122 -125
- package/.devcontainer/agent-state-json.sh +117 -0
- package/.devcontainer/agent-workspace.sh +53 -53
- package/.devcontainer/agent.sh +113 -115
- package/.devcontainer/{ia/docker-garde.sh → ai/docker-guard.sh} +1 -1
- package/.devcontainer/{ia/plugins/devzone-garde-v2.js → ai/plugins/devzone-guard-v2.js} +4 -4
- package/.devcontainer/{ia/plugins/devzone-garde.js → ai/plugins/devzone-guard.js} +3 -3
- package/.devcontainer/argocd/argocd.sh +8 -8
- package/.devcontainer/argocd/{catalogue-argocd.sh → catalog-argocd.sh} +1 -1
- package/.devcontainer/argocd/services-hook.sh +5 -5
- package/.devcontainer/{catalogue → catalog}/app.sh +4 -4
- package/.devcontainer/{catalogue/catalogue-veilleur.sh → catalog/catalog-watcher.sh} +7 -7
- package/.devcontainer/{catalogue → catalog}/mysql/mysql.sh +7 -7
- package/.devcontainer/{catalogue.sh → catalog.sh} +13 -13
- package/.devcontainer/cluster.sh +8 -8
- package/.devcontainer/devcontainer.json +1 -1
- package/.devcontainer/devzone +55 -54
- package/.devcontainer/{docker-relais.sh → docker-relay.sh} +2 -2
- package/.devcontainer/gitlab/argocd.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +4 -4
- package/.devcontainer/gitlab/installation.sh +5 -5
- package/.devcontainer/gitlab/secrets.sh +1 -1
- package/.devcontainer/help.sh +1 -0
- package/.devcontainer/{kind-enveloppe.sh → kind-wrapper.sh} +5 -5
- package/.devcontainer/{kube-compte.sh → kube-account.sh} +3 -3
- package/.devcontainer/{kube-joignable.sh → kube-reachable.sh} +1 -1
- package/.devcontainer/memory.sh +113 -0
- package/.devcontainer/metrics-server.sh +52 -51
- package/.devcontainer/{paquets.sh → packages.sh} +4 -4
- package/.devcontainer/password.sh +88 -87
- package/.devcontainer/ports-auto.sh +7 -7
- package/.devcontainer/ports.sh +4 -4
- package/.devcontainer/post-create.sh +2 -2
- package/.devcontainer/postgres/postgres.sh +3 -3
- package/.devcontainer/services-admin.sh +5 -5
- package/.devcontainer/skills/devzone/SKILL.md +1 -1
- package/.devcontainer/{demarrage.sh → startup.sh} +5 -5
- package/.devcontainer/state-json.sh +308 -0
- package/.devcontainer/state-lock.sh +53 -0
- package/.devcontainer/state.sh +219 -0
- package/.devcontainer/workspace-init.sh +1 -1
- package/Makefile +7 -7
- package/README.md +2 -2
- package/charts/devzone-workspace/templates/statefulset.yaml +3 -0
- package/manage/devzone +3 -3
- package/manage/scripts/check-go-layout.sh +40 -0
- package/manage/scripts/check-names.sh +60 -0
- package/manage/scripts/devzone-create.sh +2 -2
- package/manage/scripts/devzone-manifest.sh +2 -2
- package/manage/scripts/docker-workstation.sh +2 -2
- package/manage/scripts/docker.sh +2 -2
- package/manage/scripts/{lancer.sh → launch.sh} +3 -3
- package/manage/scripts/{migrer-retour.sh → migrate-revert.sh} +1 -1
- package/manage/scripts/{migrer.sh → migrate.sh} +1 -1
- package/manage/workspace.sh +4 -4
- package/package.json +1 -1
- package/.devcontainer/agent-erreurs.sh +0 -138
- package/.devcontainer/agent-etat-json.sh +0 -115
- package/.devcontainer/etat-json.sh +0 -308
- package/.devcontainer/etat-verrou.sh +0 -52
- package/.devcontainer/etat.sh +0 -220
- package/.devcontainer/memoire.sh +0 -113
- /package/.devcontainer/{ia/docker-garde.message → ai/docker-guard.message} +0 -0
- /package/.devcontainer/{ia → ai}/host-check.message +0 -0
- /package/.devcontainer/{ia → ai}/host-check.sh +0 -0
- /package/.devcontainer/{ia → ai}/host-models.sh +0 -0
- /package/.devcontainer/{catalogue → catalog}/mysql/app.conf +0 -0
- /package/.devcontainer/{catalogue/mysql/installer.sh → catalog/mysql/install.sh} +0 -0
- /package/.devcontainer/{catalogue → catalog}/mysql/volume.sh +0 -0
- /package/.devcontainer/{docker-sans-hote.sh → docker-without-host.sh} +0 -0
- /package/.devcontainer/{isolement.sh → isolation.sh} +0 -0
- /package/.devcontainer/{etat-gitops.sh → state-gitops.sh} +0 -0
- /package/manage/scripts/{desinstaller.sh → uninstall.sh} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Relais du socket Docker (#293), lancé en premier par
|
|
2
|
+
# Relais du socket Docker (#293), lancé en premier par startup.sh.
|
|
3
3
|
#
|
|
4
4
|
# Pourquoi : la feature docker-outside-of-docker relaie le socket de l'hôte
|
|
5
5
|
# par « socat UNIX-LISTEN:/var/run/docker.sock,… UNIX-CONNECT:… » sans
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
#
|
|
19
19
|
# Sûr par construction : chemins et commandes réglables (tests : tout sous un
|
|
20
20
|
# dossier temporaire), et refus de toucher au vrai socket sans
|
|
21
|
-
# DEVZONE_RELAIS_REEL=oui, que seuls
|
|
21
|
+
# DEVZONE_RELAIS_REEL=oui, que seuls startup.sh et devzone repair posent.
|
|
22
22
|
# Code : 0 contrôle réussi, 1 contrôle en échec (marque écrite pour le
|
|
23
23
|
# récapitulatif devzone), 2 refus de la garde. Compatible bash 3.2.
|
|
24
24
|
set -euo pipefail
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
# gitlab_application_retirer the Application removed (namespace kept)
|
|
14
14
|
|
|
15
15
|
# The catalogue side of Argo CD (module on, chart, revision, Application)
|
|
16
|
-
# shellcheck source=SCRIPTDIR/../argocd/
|
|
16
|
+
# shellcheck source=SCRIPTDIR/../argocd/catalog-argocd.sh
|
|
17
17
|
# shellcheck disable=SC1091
|
|
18
|
-
. "$ICI/../argocd/
|
|
18
|
+
. "$ICI/../argocd/catalog-argocd.sh"
|
|
19
19
|
|
|
20
20
|
# The module argocd is on, the namespace devzone-argocd is installed, the chart
|
|
21
21
|
# is in the repository and the revision is known: a development clone (version
|
|
@@ -14,9 +14,9 @@ RACINE="${DEVZONE_RACINE:-$(dirname "$(dirname "$ICI")")}"
|
|
|
14
14
|
# shellcheck disable=SC1091
|
|
15
15
|
. "$ICI/../password.sh"
|
|
16
16
|
# Isolation réseau : namespace_isoler, posée avec le namespace devzone-gitlab
|
|
17
|
-
# shellcheck source=SCRIPTDIR/../
|
|
17
|
+
# shellcheck source=SCRIPTDIR/../isolation.sh
|
|
18
18
|
# shellcheck disable=SC1091
|
|
19
|
-
. "$ICI/../
|
|
19
|
+
. "$ICI/../isolation.sh"
|
|
20
20
|
|
|
21
21
|
# ---- Variables de délai (secondes) ----
|
|
22
22
|
# GITLAB_ATTENTE : attente globale d'installation (défaut 1200)
|
|
@@ -28,7 +28,7 @@ GITLAB_SECRETS_DIR="$RACINE/workspace/.gitlab"
|
|
|
28
28
|
|
|
29
29
|
# Vue regroupée des identifiants : un échec n'empêche jamais l'opération
|
|
30
30
|
regenerer_identifiants() {
|
|
31
|
-
|
|
31
|
+
password_regenerate ||
|
|
32
32
|
echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -67,7 +67,7 @@ GITLAB_HOTE_MARQUE="# devzone:gitlab"
|
|
|
67
67
|
# qui écoute sur 127.0.0.1. Le nom pointe donc vers 127.0.0.1 pour que ssh et
|
|
68
68
|
# glab empruntent le même chemin. /etc/hosts est un montage Docker que Docker
|
|
69
69
|
# régénère au démarrage du conteneur, d'où le re-pose à chaque démarrage
|
|
70
|
-
# (
|
|
70
|
+
# (startup.sh) et à chaque activation. Jamais de sed -i ni de mv : le
|
|
71
71
|
# montage ne peut pas être renommé (écriture en place seulement) ; directe si
|
|
72
72
|
# le fichier est inscriptible, sinon sudo -n. Un échec n'échoue jamais :
|
|
73
73
|
# avertissement sur stderr et code 0, pour ne pas faire échouer l'installation
|
|
@@ -6,11 +6,11 @@
|
|
|
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):
|
|
10
|
-
#
|
|
11
|
-
# shellcheck source=SCRIPTDIR/../
|
|
9
|
+
# Shared memory check of the services cluster (#608): quantity_ki,
|
|
10
|
+
# memory_cluster_ki and check_module_memory.
|
|
11
|
+
# shellcheck source=SCRIPTDIR/../memory.sh
|
|
12
12
|
# shellcheck disable=SC1091
|
|
13
|
-
. "$ICI/../
|
|
13
|
+
. "$ICI/../memory.sh"
|
|
14
14
|
|
|
15
15
|
# Namespace isolé du module : un par instance, comme postgres
|
|
16
16
|
GITLAB_NS="devzone-gitlab${INSTANCE_SUFFIX}"
|
|
@@ -36,7 +36,7 @@ gitlab_namespace_preparer() {
|
|
|
36
36
|
# l'accès (relais web/SSH, /etc/hosts) et le seed des données de test.
|
|
37
37
|
gitlab_installer() {
|
|
38
38
|
echo "▶ Vérification de la mémoire allouable du cluster des services…"
|
|
39
|
-
|
|
39
|
+
check_module_memory gitlab 8 || return 2
|
|
40
40
|
|
|
41
41
|
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
42
42
|
gitlab_namespace_preparer
|
|
@@ -89,7 +89,7 @@ puts \"OK\""
|
|
|
89
89
|
mkdir -p "$GITLAB_SECRETS_DIR" || return 1
|
|
90
90
|
(umask 077 && printf '%s' "$mdp" >"$fichier") || return 1
|
|
91
91
|
chmod 600 "$fichier"
|
|
92
|
-
|
|
92
|
+
password_regenerate ||
|
|
93
93
|
echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
94
94
|
printf '%s\n' "$RACINE/.password"
|
|
95
95
|
}
|
package/.devcontainer/help.sh
CHANGED
|
@@ -6,6 +6,7 @@ devzone_aide() {
|
|
|
6
6
|
cat <<'AIDE'
|
|
7
7
|
Optional modules of devzone, enabled on demand, without rebuild:
|
|
8
8
|
devzone state of the modules
|
|
9
|
+
devzone --version version of the workspace image (DEVZONE_VERSION)
|
|
9
10
|
devzone platform GitHub (default) or GitLab
|
|
10
11
|
devzone platform github back to GitHub: glab and config removed
|
|
11
12
|
devzone platform gitlab GitLab, [--url URL] (default: gitlab module)
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
# binaire est kind-reel. Avec le Docker de l'hôte, un cluster créé par
|
|
4
4
|
# « kind create cluster » écrit server: https://127.0.0.1:<port> : injoignable
|
|
5
5
|
# depuis le conteneur. Après une création ou un export de kubeconfig réussis,
|
|
6
|
-
# l'adresse est rendue joignable (kube-
|
|
6
|
+
# l'adresse est rendue joignable (kube-reachable.sh). Tout le reste passe tel quel.
|
|
7
7
|
set -uo pipefail
|
|
8
8
|
|
|
9
9
|
KIND_REEL="${DEVZONE_KIND_REEL:-/usr/local/bin/kind-reel}"
|
|
10
10
|
ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
-
if [ -f "$ICI/kube-
|
|
12
|
-
# shellcheck source=SCRIPTDIR/kube-
|
|
13
|
-
. "$ICI/kube-
|
|
11
|
+
if [ -f "$ICI/kube-reachable.sh" ]; then
|
|
12
|
+
# shellcheck source=SCRIPTDIR/kube-reachable.sh
|
|
13
|
+
. "$ICI/kube-reachable.sh"
|
|
14
14
|
else
|
|
15
15
|
# shellcheck source=/dev/null
|
|
16
|
-
. /usr/local/lib/devzone/kube-
|
|
16
|
+
. /usr/local/lib/devzone/kube-reachable.sh
|
|
17
17
|
fi
|
|
18
18
|
|
|
19
19
|
"$KIND_REEL" "$@"
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
# agents) ne peut agir que dans les namespaces devzone-*. Le compte est le
|
|
4
4
|
# ServiceAccount devzone-agent du namespace devzone-system, lié au ClusterRole
|
|
5
5
|
# edit (ni RBAC ni quotas) dans chaque namespace de devzone par un RoleBinding,
|
|
6
|
-
# avec un jeton TokenRequest de 24 h renouvelé au démarrage (
|
|
6
|
+
# avec un jeton TokenRequest de 24 h renouvelé au démarrage (startup.sh) et
|
|
7
7
|
# par « devzone repair ». Les installeurs utilisent seuls le contexte
|
|
8
8
|
# administrateur (contexte de l hôte dans ~/.kube/hote.config, cluster kind
|
|
9
9
|
# dans ~/.kube/config) ; les shells et les agents n'ont que ~/.kube/config.
|
|
10
10
|
# Bibliothèque sourcée par cluster.sh ; exécutable pour le jeton :
|
|
11
|
-
# kube-
|
|
11
|
+
# kube-account.sh jeton
|
|
12
12
|
|
|
13
13
|
COMPTES_NS=devzone-system
|
|
14
14
|
COMPTES_SA=devzone-agent
|
|
@@ -179,7 +179,7 @@ compte_jeton() {
|
|
|
179
179
|
--cluster="$cluster" --user="$COMPTES_SA" >/dev/null
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
# Exécution directe : jeton du compte renouvelé au démarrage (
|
|
182
|
+
# Exécution directe : jeton du compte renouvelé au démarrage (startup.sh) et
|
|
183
183
|
# par « devzone repair ». Sans cluster des services choisi : rien à faire.
|
|
184
184
|
# Quand le fichier est sourcé, $0 diffère de BASH_SOURCE : rien ne s'exécute.
|
|
185
185
|
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# la vérification TLS (--tls-server-name) ; suffit avec Docker Desktop, où
|
|
12
12
|
# host.docker.internal mène au 127.0.0.1 du poste.
|
|
13
13
|
# Bibliothèque sourcée (cluster.sh, enveloppe kind) ; exécutée directement :
|
|
14
|
-
# kube-
|
|
14
|
+
# kube-reachable.sh FICHIER
|
|
15
15
|
# kube_joignable_depuis_conteneur FICHIER réécrit 127.0.0.1/localhost, idempotent
|
|
16
16
|
|
|
17
17
|
# Nœud kind de plan de contrôle qui publie ce port sur le poste (vide sinon)
|
|
@@ -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
|
+
# quantity_ki <quantity> Kubernetes quantity in Ki
|
|
6
|
+
# memory_cluster_ki allocatable memory of the cluster, in Ki
|
|
7
|
+
# check_module_memory <module> <minimum_gi> [hint]
|
|
8
|
+
# Messages in English. Return 0 when the memory is enough, 2 when it is not or
|
|
9
|
+
# when the cluster is unreachable.
|
|
10
|
+
|
|
11
|
+
# Globals written by memory_cluster_ki (#612) and read by
|
|
12
|
+
# check_module_memory, which calls the function directly: a call written
|
|
13
|
+
# memory="$(memory_cluster_ki)" would run it in a subshell and lose them.
|
|
14
|
+
# Callers that only need the number keep using $(memory_cluster_ki): the
|
|
15
|
+
# value is still printed on stdout (argocd, gitlab, llm are unaffected).
|
|
16
|
+
# MEMORY_KI same value as on stdout, in Ki
|
|
17
|
+
# MEMORY_RULE "maximum" when every node is a kind node (the nodes share
|
|
18
|
+
# one VM), "sum" otherwise
|
|
19
|
+
MEMORY_KI=""
|
|
20
|
+
MEMORY_RULE=""
|
|
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
|
+
quantity_ki() {
|
|
25
|
+
local q="${1:-}" number
|
|
26
|
+
case "$q" in
|
|
27
|
+
*Ki) number="${q%Ki}"; echo $((number)) ;;
|
|
28
|
+
*Mi) number="${q%Mi}"; echo $((number * 1024)) ;;
|
|
29
|
+
*Gi) number="${q%Gi}"; echo $((number * 1024 * 1024)) ;;
|
|
30
|
+
*Ti) number="${q%Ti}"; echo $((number * 1024 * 1024 * 1024)) ;;
|
|
31
|
+
*K | *k) number="${q%[Kk]}"; echo $((number * 1000 / 1024)) ;;
|
|
32
|
+
*M) number="${q%M}"; echo $((number * 1000 * 1000 / 1024)) ;;
|
|
33
|
+
*G) number="${q%G}"; echo $((number * 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 (MEMORY_RULE=maximum); as soon as one node has no such
|
|
50
|
+
# prefix or an empty providerID the sum is returned (MEMORY_RULE=sum), 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
|
+
memory_cluster_ki() {
|
|
55
|
+
local output line providerID memory node total=0 max=0 n=0 all_kind=1
|
|
56
|
+
MEMORY_KI=""
|
|
57
|
+
MEMORY_RULE=""
|
|
58
|
+
output="$(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 "$output" ] || return 1
|
|
61
|
+
while IFS= read -r line; do
|
|
62
|
+
[ -n "$line" ] || continue
|
|
63
|
+
case "$line" in
|
|
64
|
+
*'|'*)
|
|
65
|
+
providerID="${line%%|*}"
|
|
66
|
+
memory="${line#*|}"
|
|
67
|
+
;;
|
|
68
|
+
*)
|
|
69
|
+
providerID=""
|
|
70
|
+
memory="$line"
|
|
71
|
+
;;
|
|
72
|
+
esac
|
|
73
|
+
node="$(quantity_ki "$memory")"
|
|
74
|
+
total=$((total + node))
|
|
75
|
+
if [ "$node" -gt "$max" ]; then max="$node"; fi
|
|
76
|
+
case "$providerID" in
|
|
77
|
+
kind://*) ;;
|
|
78
|
+
*) all_kind=0 ;;
|
|
79
|
+
esac
|
|
80
|
+
n=$((n + 1))
|
|
81
|
+
done <<<"$output"
|
|
82
|
+
if [ "$n" -gt 0 ] && [ "$all_kind" -eq 1 ]; then
|
|
83
|
+
MEMORY_RULE="maximum"
|
|
84
|
+
MEMORY_KI="$max"
|
|
85
|
+
else
|
|
86
|
+
MEMORY_RULE="sum"
|
|
87
|
+
MEMORY_KI="$total"
|
|
88
|
+
fi
|
|
89
|
+
echo "$MEMORY_KI"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Refuses the installation of <module> under <minimum_gi> GiB of allocatable
|
|
93
|
+
# memory. The message says the minimum, the available memory and how to enlarge
|
|
94
|
+
# the cluster; [hint] 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
|
+
check_module_memory() {
|
|
99
|
+
local module_name="$1" minimum_gi="$2" hint="${3:-}" memory precision=""
|
|
100
|
+
if ! memory_cluster_ki >/dev/null; then
|
|
101
|
+
echo "devzone : ${module_name} : services cluster unreachable: devzone cluster" >&2
|
|
102
|
+
return 2
|
|
103
|
+
fi
|
|
104
|
+
memory="$MEMORY_KI"
|
|
105
|
+
if [ "$MEMORY_RULE" = "maximum" ]; then
|
|
106
|
+
precision=" (memory of a single node: kind cluster, shared VM)"
|
|
107
|
+
fi
|
|
108
|
+
if [ "$memory" -lt "$((minimum_gi * 1048576))" ]; then
|
|
109
|
+
echo "devzone : ${module_name} : at least ${minimum_gi} GiB of allocatable memory is needed in the cluster (available: $((memory / 1048576)) GiB)${precision} ; enlarge the cluster (Docker Desktop → Settings → Resources) then retry: devzone enable ${module_name}${hint:+ ; hint: ${hint}}" >&2
|
|
110
|
+
return 2
|
|
111
|
+
fi
|
|
112
|
+
return 0
|
|
113
|
+
}
|
|
@@ -1,99 +1,100 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Usage
|
|
5
|
-
# (
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
2
|
+
# Installs metrics-server (CPU/RAM in k9s, kubectl top) on the clusters that
|
|
3
|
+
# have no Metrics API. Docker Desktop and kind do not have it by default.
|
|
4
|
+
# Usage: metrics-server.sh [context...] | metrics-server.sh retirer [context...]
|
|
5
|
+
# (default: reachable local clusters; retirer, the public subcommand
|
|
6
|
+
# name kept as is: removal from the clusters where devzone installed it)
|
|
7
|
+
# --kubelet-insecure-tls: the kubelet of Docker Desktop and kind has a
|
|
8
|
+
# self-signed certificate, without this option the pod never becomes Ready.
|
|
9
|
+
# Exits in error if a requested context is unknown or unreachable, or if an
|
|
10
|
+
# installation fails (kube-config.sh calls it with || true).
|
|
10
11
|
set -euo pipefail
|
|
11
12
|
|
|
12
13
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
13
14
|
. "$(dirname "$0")/cluster.sh"
|
|
14
15
|
|
|
15
16
|
VERSION=v0.9.0
|
|
16
|
-
|
|
17
|
+
MANIFEST="https://github.com/kubernetes-sigs/metrics-server/releases/download/${VERSION}/components.yaml"
|
|
17
18
|
|
|
18
|
-
mapfile -t
|
|
19
|
+
mapfile -t known < <(kubectl config get-contexts -o name 2>/dev/null || true)
|
|
19
20
|
|
|
20
21
|
if [ "${1:-}" = retirer ]; then
|
|
21
22
|
shift
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
if [ "$
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
mapfile -t
|
|
23
|
+
# Removal (kubernetes module disabled): only the contexts where devzone
|
|
24
|
+
# installed metrics-server (devzone=installe mark) are removed
|
|
25
|
+
requested=$#
|
|
26
|
+
if [ "$requested" -eq 0 ]; then
|
|
27
|
+
# Local clusters only: removal on a remote cluster has nothing to remove
|
|
28
|
+
# (devzone never installs there)
|
|
29
|
+
mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
|
|
29
30
|
while IFS= read -r c; do cluster_est_local "$c" && echo "$c"; done || true)
|
|
30
|
-
set -- ${
|
|
31
|
+
set -- ${contexts[@]+"${contexts[@]}"}
|
|
31
32
|
fi
|
|
32
33
|
code=0
|
|
33
|
-
for
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
|
|
34
|
+
for context in "$@"; do
|
|
35
|
+
# Mark read on the deployment by its name: kubectl refuses a name with
|
|
36
|
+
# a selector (-l), the test would always be false (#255)
|
|
37
|
+
mark="$(kubectl --context "$context" -n kube-system get deployment metrics-server \
|
|
37
38
|
-o jsonpath='{.metadata.labels.devzone}' 2>/dev/null || true)"
|
|
38
|
-
if [ "$
|
|
39
|
-
if kubectl --context "$
|
|
40
|
-
echo "metrics-server
|
|
39
|
+
if [ "$mark" = installe ]; then
|
|
40
|
+
if kubectl --context "$context" delete -f "$MANIFEST" --ignore-not-found >/dev/null 2>&1; then
|
|
41
|
+
echo "metrics-server removed ($VERSION) : $context"
|
|
41
42
|
else
|
|
42
|
-
echo "metrics-server :
|
|
43
|
+
echo "metrics-server : removal failed: $context" >&2
|
|
43
44
|
code=1
|
|
44
45
|
fi
|
|
45
|
-
elif kubectl --context "$
|
|
46
|
-
#
|
|
47
|
-
echo "metrics-server
|
|
46
|
+
elif kubectl --context "$context" -n kube-system get deployment metrics-server >/dev/null 2>&1; then
|
|
47
|
+
# Installed by someone else: not up to devzone to remove it
|
|
48
|
+
echo "metrics-server present without a devzone mark, left: $context" >&2
|
|
48
49
|
fi
|
|
49
50
|
done
|
|
50
51
|
exit "$code"
|
|
51
52
|
fi
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
if [ "$
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
mapfile -t
|
|
54
|
+
requested=$#
|
|
55
|
+
if [ "$requested" -eq 0 ]; then
|
|
56
|
+
# Local clusters only: never an automatic installation on a remote cluster
|
|
57
|
+
# of the host (prod, staging…); for another one, name it as an argument
|
|
58
|
+
mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
|
|
58
59
|
while IFS= read -r c; do cluster_est_local "$c" && echo "$c"; done || true)
|
|
59
|
-
set -- ${
|
|
60
|
+
set -- ${contexts[@]+"${contexts[@]}"}
|
|
60
61
|
fi
|
|
61
62
|
|
|
62
63
|
code=0
|
|
63
|
-
|
|
64
|
-
for
|
|
65
|
-
if [ "$
|
|
66
|
-
echo "metrics-server :
|
|
64
|
+
reachable=0
|
|
65
|
+
for context in "$@"; do
|
|
66
|
+
if [ "$requested" -gt 0 ] && ! printf '%s\n' ${known[@]+"${known[@]}"} | grep -qxF -- "$context"; then
|
|
67
|
+
echo "metrics-server : unknown context: $context (see kubectl config get-contexts)" >&2
|
|
67
68
|
code=1
|
|
68
69
|
continue
|
|
69
70
|
fi
|
|
70
|
-
k=(kubectl --context "$
|
|
71
|
+
k=(kubectl --context "$context" --request-timeout=5s)
|
|
71
72
|
if ! "${k[@]}" get --raw /readyz >/dev/null 2>&1; then
|
|
72
|
-
#
|
|
73
|
-
if [ "$
|
|
74
|
-
echo "metrics-server : cluster
|
|
73
|
+
# Without argument: kind may still be starting, ignored
|
|
74
|
+
if [ "$requested" -gt 0 ]; then
|
|
75
|
+
echo "metrics-server : cluster unreachable: $context" >&2
|
|
75
76
|
code=1
|
|
76
77
|
fi
|
|
77
78
|
continue
|
|
78
79
|
fi
|
|
79
|
-
|
|
80
|
+
reachable=$((reachable + 1))
|
|
80
81
|
if "${k[@]}" get apiservice v1beta1.metrics.k8s.io >/dev/null 2>&1; then
|
|
81
|
-
echo "metrics-server :
|
|
82
|
+
echo "metrics-server : already present: $context"
|
|
82
83
|
continue
|
|
83
84
|
fi
|
|
84
|
-
if "${k[@]}" apply -f "$
|
|
85
|
+
if "${k[@]}" apply -f "$MANIFEST" >/dev/null &&
|
|
85
86
|
"${k[@]}" -n kube-system patch deployment metrics-server --type=json \
|
|
86
87
|
-p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]' >/dev/null &&
|
|
87
|
-
#
|
|
88
|
+
# Mark: make desinstaller only removes what devzone installed
|
|
88
89
|
"${k[@]}" -n kube-system label deployment metrics-server devzone=installe app.kubernetes.io/managed-by=devzone --overwrite >/dev/null; then
|
|
89
|
-
echo "metrics-server :
|
|
90
|
+
echo "metrics-server : installed ($VERSION): $context (metrics within ~1 min)"
|
|
90
91
|
else
|
|
91
|
-
echo "metrics-server :
|
|
92
|
+
echo "metrics-server : installation failed: $context" >&2
|
|
92
93
|
code=1
|
|
93
94
|
fi
|
|
94
95
|
done
|
|
95
96
|
|
|
96
|
-
if [ "$
|
|
97
|
-
echo "metrics-server :
|
|
97
|
+
if [ "$requested" -eq 0 ] && [ "$reachable" -eq 0 ]; then
|
|
98
|
+
echo "metrics-server : no reachable local cluster; after kind create cluster: bash .devcontainer/metrics-server.sh"
|
|
98
99
|
fi
|
|
99
100
|
exit "$code"
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
# par ligne, triés, sans doublon), réinstallée à chaque création du conteneur
|
|
5
5
|
# (post-create.sh). Un paquet installé à la main est perdu par un rebuild, sauf
|
|
6
6
|
# s'il est dans cette liste.
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# packages.sh ou packages.sh list liste avec l'état de chaque paquet
|
|
8
|
+
# packages.sh add <nom>… valide, installe, ajoute à la liste
|
|
9
|
+
# packages.sh remove <nom>… retire de la liste et désinstalle (sauf paquet de l'image)
|
|
10
|
+
# packages.sh apply installe tout ce qui manque (post-create.sh)
|
|
11
11
|
# L'état d'un paquet vient de dpkg-query -W -f='${Status}' ; les commandes
|
|
12
12
|
# système passent par des variables surchargeables pour les tests (sudo, apt-get,
|
|
13
13
|
# apt-cache, dpkg-query, marque, horodatage). Compatible bash 3.2 (macOS).
|