devzone 1.1.0 → 3.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-erreurs.sh → agent-errors.sh} +6 -6
- 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} +5 -5
- package/.devcontainer/agent-pod-manifest.sh +4 -4
- package/.devcontainer/{agent-droits.sh → agent-rights.sh} +2 -2
- package/.devcontainer/agent-session.sh +3 -3
- package/.devcontainer/{agent-etat-json.sh → agent-state-json.sh} +6 -6
- package/.devcontainer/agent-workspace.sh +1 -1
- package/.devcontainer/agent.sh +14 -14
- package/.devcontainer/{ia/docker-garde.sh → ai/docker-guard.sh} +1 -1
- package/.devcontainer/{ia → ai}/host-models.sh +2 -2
- package/.devcontainer/{ia/plugins/devzone-garde-v2.js → ai/plugins/devzone-guard-v2.js} +7 -7
- package/.devcontainer/{ia/plugins/devzone-garde.js → ai/plugins/devzone-guard.js} +6 -6
- package/.devcontainer/argocd/argocd.sh +94 -93
- package/.devcontainer/argocd/{catalogue-argocd.sh → catalog-argocd.sh} +3 -3
- package/.devcontainer/argocd/services-hook.sh +8 -8
- package/.devcontainer/argocd/services.sh +1 -1
- package/.devcontainer/catalog/app.sh +209 -0
- package/.devcontainer/catalog/catalog-watcher.sh +130 -0
- package/.devcontainer/{catalogue → catalog}/mysql/app.conf +1 -1
- package/.devcontainer/catalog/mysql/install.sh +87 -0
- package/.devcontainer/catalog/mysql/mysql.sh +262 -0
- package/.devcontainer/catalog/mysql/volume.sh +71 -0
- package/.devcontainer/catalog.sh +231 -0
- package/.devcontainer/chart-direct.sh +1 -1
- package/.devcontainer/cluster.sh +222 -224
- package/.devcontainer/clusters.sh +41 -41
- package/.devcontainer/devcontainer.json +1 -1
- package/.devcontainer/devzone +103 -1506
- package/.devcontainer/devzone-ai-guard.sh +76 -0
- package/.devcontainer/devzone-ai.sh +201 -0
- package/.devcontainer/devzone-cluster.sh +210 -0
- package/.devcontainer/devzone-modules.sh +126 -0
- package/.devcontainer/devzone-platform.sh +189 -0
- package/.devcontainer/devzone-repair.sh +94 -0
- package/.devcontainer/devzone-services.sh +241 -0
- package/.devcontainer/devzone-skill.sh +97 -0
- package/.devcontainer/devzone-status.sh +140 -0
- package/.devcontainer/devzone-version.sh +78 -0
- package/.devcontainer/git-identity.sh +28 -0
- package/.devcontainer/gitlab/argocd.sh +2 -2
- package/.devcontainer/gitlab/chart.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +83 -84
- package/.devcontainer/gitlab/installation.sh +111 -111
- package/.devcontainer/gitlab/secrets.sh +47 -47
- package/.devcontainer/gitlab/seed.sh +77 -77
- package/.devcontainer/gitlab/test-gitlab.sh +242 -243
- package/.devcontainer/help.sh +1 -1
- package/.devcontainer/isolation.sh +65 -0
- package/.devcontainer/kind-wrapper.sh +45 -0
- package/.devcontainer/kube-account.sh +199 -0
- package/.devcontainer/kube-config.sh +45 -46
- package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
- package/.devcontainer/kube-reachable.sh +64 -0
- package/.devcontainer/{memoire.sh → memory.sh} +1 -1
- package/.devcontainer/metrics-server.sh +2 -2
- package/.devcontainer/opencode.jsonc +2 -2
- package/.devcontainer/packages.sh +228 -0
- package/.devcontainer/password.sh +1 -1
- package/.devcontainer/ports-auto.sh +152 -153
- package/.devcontainer/ports-json.sh +16 -15
- package/.devcontainer/ports.sh +127 -123
- package/.devcontainer/post-create.sh +52 -52
- package/.devcontainer/postgres/postgres.sh +176 -176
- package/.devcontainer/rename-legacy-files.sh +103 -0
- package/.devcontainer/services-admin.sh +5 -5
- package/.devcontainer/skills/devzone/SKILL.md +40 -41
- package/.devcontainer/startup.sh +65 -0
- package/.devcontainer/{etat-gitops.sh → state-gitops.sh} +1 -1
- package/.devcontainer/{etat-json.sh → state-json.sh} +39 -65
- package/.devcontainer/{etat-verrou.sh → state-lock.sh} +1 -1
- package/.devcontainer/{etat.sh → state.sh} +4 -4
- package/.devcontainer/workspace-init.sh +17 -3
- package/Makefile +8 -8
- package/README.md +195 -194
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +8 -10
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/check-go-layout.sh +40 -0
- package/manage/scripts/check-names.sh +61 -0
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +2 -2
- package/manage/scripts/devzone-create.sh +5 -5
- package/manage/scripts/devzone-manifest.sh +3 -3
- package/manage/scripts/devzone-update.sh +12 -8
- package/manage/scripts/docker-workstation.sh +2 -2
- package/manage/scripts/docker.sh +2 -2
- package/manage/scripts/{lancer.sh → launch.sh} +10 -51
- package/manage/scripts/{migrer-retour.sh → migrate-revert.sh} +4 -4
- package/manage/scripts/{migrer.sh → migrate.sh} +8 -14
- package/manage/scripts/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/{desinstaller.sh → uninstall.sh} +8 -8
- package/manage/scripts/workspace-egress.sh +2 -2
- package/manage/scripts/workspace-update.sh +5 -2
- package/manage/scripts/workspace-wait.sh +2 -2
- package/manage/workspace.sh +4 -4
- package/package.json +1 -1
- package/.devcontainer/catalogue/app.sh +0 -211
- package/.devcontainer/catalogue/catalogue-veilleur.sh +0 -130
- package/.devcontainer/catalogue/mysql/installer.sh +0 -87
- package/.devcontainer/catalogue/mysql/mysql.sh +0 -262
- package/.devcontainer/catalogue/mysql/volume.sh +0 -71
- package/.devcontainer/catalogue.sh +0 -231
- package/.devcontainer/demarrage.sh +0 -66
- package/.devcontainer/docker-relais.sh +0 -149
- package/.devcontainer/docker-sans-hote.sh +0 -12
- package/.devcontainer/git-identite.sh +0 -28
- package/.devcontainer/isolement.sh +0 -65
- package/.devcontainer/kind-enveloppe.sh +0 -45
- package/.devcontainer/kube-compte.sh +0 -200
- package/.devcontainer/kube-joignable.sh +0 -64
- package/.devcontainer/paquets.sh +0 -227
- /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
|
@@ -87,15 +87,18 @@ update_workspace() {
|
|
|
87
87
|
echo "✖ no terminal to confirm: run again with --yes (devzone workspace update --yes)" >&2
|
|
88
88
|
return 1
|
|
89
89
|
fi
|
|
90
|
-
read -r -p "Update the workspace to v$version? [
|
|
90
|
+
read -r -p "Update the workspace to v$version? [y/N] " answer || answer=""
|
|
91
91
|
case "$answer" in
|
|
92
|
-
|
|
92
|
+
y | Y | yes) ;;
|
|
93
93
|
*)
|
|
94
94
|
echo "✖ canceled, nothing changed" >&2
|
|
95
95
|
return 1
|
|
96
96
|
;;
|
|
97
97
|
esac
|
|
98
98
|
fi
|
|
99
|
+
# Former French names renamed once the update is confirmed (#733); the
|
|
100
|
+
# script comes from the package, the devzone folder is the current one
|
|
101
|
+
DEVZONE_ROOT="$PWD" bash "$ROOT/.devcontainer/rename-legacy-files.sh" || true
|
|
99
102
|
# Same path as workspace start, at the release: Argo CD revision and image tag
|
|
100
103
|
export DEVZONE_ARGOCD_REVISION="v$version"
|
|
101
104
|
workspace_deploy "$IMAGE_REPO" "$version" ""
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
# Waits for the workspace pod; missing image or slow pod are reported clearly.
|
|
7
7
|
wait_for_pod() {
|
|
8
8
|
local image="$1" timeout step start state events arch target_revision pod_revision
|
|
9
|
-
timeout="${
|
|
10
|
-
step="${
|
|
9
|
+
timeout="${DEVZONE_WORKSPACE_WAIT:-120}"
|
|
10
|
+
step="${DEVZONE_WORKSPACE_STEP:-2}"
|
|
11
11
|
start="$SECONDS"
|
|
12
12
|
while [ $((SECONDS - start)) -lt "$timeout" ]; do
|
|
13
13
|
# Why: after helm upgrade the pod is still the old one; judge only the revision the StatefulSet is updating to, within the same wait bound.
|
package/manage/workspace.sh
CHANGED
|
@@ -175,10 +175,10 @@ copy_from() {
|
|
|
175
175
|
. "$HERE/scripts/workspace-clone.sh"
|
|
176
176
|
# shellcheck source=manage/scripts/workspace-copies.sh
|
|
177
177
|
. "$HERE/scripts/workspace-copies.sh"
|
|
178
|
-
# shellcheck source=manage/scripts/
|
|
179
|
-
. "$HERE/scripts/
|
|
180
|
-
# shellcheck source=manage/scripts/
|
|
181
|
-
. "$HERE/scripts/
|
|
178
|
+
# shellcheck source=manage/scripts/migrate.sh
|
|
179
|
+
. "$HERE/scripts/migrate.sh"
|
|
180
|
+
# shellcheck source=manage/scripts/migrate-revert.sh
|
|
181
|
+
. "$HERE/scripts/migrate-revert.sh"
|
|
182
182
|
# shellcheck source=manage/scripts/ports-workspace.sh
|
|
183
183
|
. "$HERE/scripts/ports-workspace.sh"
|
|
184
184
|
# shellcheck source=manage/scripts/services-workspace.sh
|
package/package.json
CHANGED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Opérations d'installation du catalogue (#414) : sourcé par catalogue.sh.
|
|
3
|
-
# Le module argocd actif : l'application installée est une Application Argo CD
|
|
4
|
-
# devzone-<app> (chart charts/devzone-<app> du dépôt devzone, #538) au lieu du
|
|
5
|
-
# manifeste de la voie helm direct.
|
|
6
|
-
|
|
7
|
-
ATTENTE="${DEVZONE_CATALOGUE_ATTENTE:-300}"
|
|
8
|
-
|
|
9
|
-
# shellcheck source=SCRIPTDIR/argocd/catalogue-argocd.sh
|
|
10
|
-
# shellcheck disable=SC1091
|
|
11
|
-
. "$ICI/argocd/catalogue-argocd.sh"
|
|
12
|
-
# shellcheck source=SCRIPTDIR/chart-direct.sh
|
|
13
|
-
# shellcheck disable=SC1091
|
|
14
|
-
. "$ICI/chart-direct.sh"
|
|
15
|
-
|
|
16
|
-
# Attente du StatefulSet prêt : une seule commande rollout sur la voie
|
|
17
|
-
# manifeste, sondée sur la voie Argo CD (la synchronisation est en tâche de
|
|
18
|
-
# fond)
|
|
19
|
-
app_attendre() {
|
|
20
|
-
local app="$1" ns="$2" argo="$3" fin=$((SECONDS + ATTENTE))
|
|
21
|
-
if [ "$argo" = 1 ]; then
|
|
22
|
-
while [ "$SECONDS" -lt "$fin" ]; do
|
|
23
|
-
kubectl --context devzone -n "$ns" rollout status "statefulset/$app" --timeout=10s >/dev/null 2>&1 && return 0
|
|
24
|
-
sleep 5
|
|
25
|
-
done
|
|
26
|
-
echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
|
|
27
|
-
return 1
|
|
28
|
-
fi
|
|
29
|
-
if ! kubectl --context devzone -n "$ns" rollout status "statefulset/$app" \
|
|
30
|
-
--timeout="${ATTENTE}s" >/dev/null; then
|
|
31
|
-
echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
|
|
32
|
-
return 1
|
|
33
|
-
fi
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
# Secret de l'application : mot de passe généré une fois, miroir local
|
|
37
|
-
# (workspace/.$app/admin-password, 600, jamais affiché). Reprise : le mot de
|
|
38
|
-
# passe déjà là (secret cluster ou root.env) est conservé, jamais régénéré.
|
|
39
|
-
app_secret() {
|
|
40
|
-
local app="$1" ns="$2" mdp fichier
|
|
41
|
-
fichier="$RACINE/workspace/.$app/admin-password"
|
|
42
|
-
mkdir -p "$(dirname "$fichier")"
|
|
43
|
-
chmod 700 "$(dirname "$fichier")"
|
|
44
|
-
if kubectl --context devzone -n "$ns" get secret "$app-admin" >/dev/null 2>&1; then
|
|
45
|
-
mdp="$(kubectl --context devzone -n "$ns" get secret "$app-admin" \
|
|
46
|
-
-o jsonpath='{.data.password}' | tr -d '\n')"
|
|
47
|
-
(umask 077 && printf '%s' "$mdp" >"$fichier")
|
|
48
|
-
return 0
|
|
49
|
-
fi
|
|
50
|
-
mdp="$(sed -n 's/^\(MYSQL_\|\)PASSWORD=//p' "$RACINE/workspace/.$app/root.env" 2>/dev/null | tail -1 || true)"
|
|
51
|
-
if [ -z "$mdp" ] && [ -s "$fichier" ]; then mdp="$(cat "$fichier")"; fi
|
|
52
|
-
if [ -z "$mdp" ]; then
|
|
53
|
-
(umask 077 && openssl rand -hex 24 | tr -d '\n' >"$fichier")
|
|
54
|
-
elif [ ! -s "$fichier" ]; then
|
|
55
|
-
(umask 077 && printf '%s' "$mdp" >"$fichier")
|
|
56
|
-
fi
|
|
57
|
-
kubectl --context devzone -n "$ns" create secret generic "$app-admin" \
|
|
58
|
-
--from-file=password="$fichier" >/dev/null
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Vue regroupée des identifiants : un échec n'empêche jamais l'opération
|
|
62
|
-
regenerer_identifiants() {
|
|
63
|
-
password_regenerate ||
|
|
64
|
-
echo "devzone : catalogue : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
# Installe une application : contexte devzone posé (#396), namespace créé et
|
|
68
|
-
# isolé (#396), secret généré, puis Application Argo CD (module argocd actif,
|
|
69
|
-
# #538) ou manifeste, attente prête, relais lancé vers 127.0.0.1:<port> du
|
|
70
|
-
# conteneur ; rend non nul en échec
|
|
71
|
-
app_installer() {
|
|
72
|
-
local app="$1" ns port image CTX extra="" argo=0
|
|
73
|
-
ns="$(app_ns "$app")"
|
|
74
|
-
port="$(app_lire "$app" port)"
|
|
75
|
-
image="$(app_lire "$app" image)"
|
|
76
|
-
CTX="$(cluster_lu)"
|
|
77
|
-
[ -n "$CTX" ] || refuse "aucun cluster choisi : devzone enable $app"
|
|
78
|
-
if ! contexte_devzone_poser "$CTX"; then
|
|
79
|
-
echo "devzone : catalogue : impossible de poser le contexte devzone sur $CTX" >&2
|
|
80
|
-
return 1
|
|
81
|
-
fi
|
|
82
|
-
echo "▶ Application $app sur le cluster $CTX (namespace $ns)…"
|
|
83
|
-
# Namespace créé et étiqueté par l'administrateur (#430), puis compte
|
|
84
|
-
# limité autorisé dans le namespace
|
|
85
|
-
compte_admin "$CTX" create namespace "$ns" --dry-run=client -o yaml |
|
|
86
|
-
compte_admin "$CTX" apply -f - >/dev/null
|
|
87
|
-
compte_admin "$CTX" label namespace "$ns" "$CLUSTER_ETIQUETTE" --overwrite >/dev/null
|
|
88
|
-
compte_autoriser "$CTX" "$ns"
|
|
89
|
-
namespace_isoler "$ns" >/dev/null
|
|
90
|
-
app_secret "$app" "$ns"
|
|
91
|
-
local claim=donnees
|
|
92
|
-
if [ "$app" = mysql ]; then
|
|
93
|
-
# shellcheck source=SCRIPTDIR/mysql/volume.sh
|
|
94
|
-
# shellcheck disable=SC1091
|
|
95
|
-
. "$(dossier_catalogue)/mysql/volume.sh"
|
|
96
|
-
claim="$(mysql_claim_choisir "$ns")" || return 2
|
|
97
|
-
[ "$claim" = donnees ] || extra="claim=$claim"
|
|
98
|
-
fi
|
|
99
|
-
if catalogue_argocd_active "$app"; then
|
|
100
|
-
argo=1
|
|
101
|
-
echo "▶ Application $app par Argo CD (chart charts/devzone-$app)…"
|
|
102
|
-
catalogue_argocd_apply "$app" "$ns" "$image" "$port" \
|
|
103
|
-
"$(app_lire "$app" memoire)" "$(app_lire "$app" taille)" "$extra" || return 1
|
|
104
|
-
else
|
|
105
|
-
# Helm direct: the chart charts/devzone-<app>, the one definition (#559)
|
|
106
|
-
chart_install "$app" "$ns" "image=$image" "port=$port" \
|
|
107
|
-
"memory=$(app_lire "$app" memoire)" "size=$(app_lire "$app" taille)" "claim=$claim" || return 1
|
|
108
|
-
fi
|
|
109
|
-
app_attendre "$app" "$ns" "$argo" || return 1
|
|
110
|
-
relais_lancer "$app" "$CTX" "$ns" "svc/$app" "$port:$port"
|
|
111
|
-
echo "✔ $app prêt : 127.0.0.1:$port dans le conteneur"
|
|
112
|
-
regenerer_identifiants
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
# Désinstalle une application : relais coupé, Application Argo CD retirée
|
|
116
|
-
# (module argocd actif, #538) ou manifeste, marque oubliée ; le volume (PVC)
|
|
117
|
-
# et les données restent (#441) : la suppression des données est confirmée à
|
|
118
|
-
# part (devzone mysql delete-data)
|
|
119
|
-
app_desinstaller() {
|
|
120
|
-
local app="$1" ns claim pvc CTX
|
|
121
|
-
ns="$(app_ns "$app")"
|
|
122
|
-
relais_arreter "$app"
|
|
123
|
-
rm -f "$(fichier_echec "$app")"
|
|
124
|
-
# RoleBinding retiré par l'administrateur (#430) : le namespace et le
|
|
125
|
-
# volume restent, l'autorisation du compte ne doit pas traîner
|
|
126
|
-
CTX="$(cluster_lu)" || true
|
|
127
|
-
if [ -n "$CTX" ]; then
|
|
128
|
-
compte_retirer "$CTX" "$ns" >/dev/null 2>&1 || true
|
|
129
|
-
fi
|
|
130
|
-
claim="$(kubectl --context devzone -n "$ns" get statefulset "$app" \
|
|
131
|
-
-o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
|
|
132
|
-
if catalogue_argocd_application_exists "$app"; then
|
|
133
|
-
catalogue_argocd_delete "$app" >/dev/null 2>&1 || true
|
|
134
|
-
kubectl --context devzone -n "$ns" delete "secret/$app-admin" >/dev/null 2>&1 || true
|
|
135
|
-
pvc="${claim:-donnees}-$app-0"
|
|
136
|
-
echo "✔ $app retiré : Application supprimée ; volume $pvc et bases gardés : devzone $app volume"
|
|
137
|
-
regenerer_identifiants
|
|
138
|
-
return 0
|
|
139
|
-
fi
|
|
140
|
-
kubectl --context devzone -n "$ns" delete "statefulset/$app" "service/$app" \
|
|
141
|
-
"secret/$app-admin" >/dev/null 2>&1 || true
|
|
142
|
-
pvc="${claim:-donnees}-$app-0"
|
|
143
|
-
echo "✔ $app retiré du cluster ; volume $pvc et bases gardés : devzone $app volume"
|
|
144
|
-
regenerer_identifiants
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
# Marque d'échec d'une tentative : dernière ligne du message gardée et montrée
|
|
148
|
-
app_echec() {
|
|
149
|
-
printf '%s\n' "$2" | tail -1 >"$(fichier_echec "$1")"
|
|
150
|
-
printf '%s\n' "$2" >&2
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
# Avertit des PVC mysql non montés par le StatefulSet (#440). Lecture des
|
|
154
|
-
# namespaces réservée à l'administrateur (#430).
|
|
155
|
-
app_mysql_volumes_inutilises() {
|
|
156
|
-
local ctx ns monte pvc liste
|
|
157
|
-
ctx="$(cluster_lu)"
|
|
158
|
-
[ -n "$ctx" ] || return 0
|
|
159
|
-
ns="$(app_ns mysql)"
|
|
160
|
-
compte_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 || return 0
|
|
161
|
-
monte="$(kubectl --context devzone -n "$ns" get statefulset mysql -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
|
|
162
|
-
[ -n "$monte" ] || return 0
|
|
163
|
-
liste="$(kubectl --context devzone -n "$ns" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null | grep -E '\-mysql-0$' || true)"
|
|
164
|
-
while IFS= read -r pvc; do
|
|
165
|
-
[ -n "$pvc" ] || continue
|
|
166
|
-
[ "$pvc" != "${monte}-mysql-0" ] || continue
|
|
167
|
-
printf ' ⚠ volume %s non utilisé : devzone mysql volume\n' "$pvc"
|
|
168
|
-
done <<<"$liste"
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
# Comble l'écart entre le voulu et le réel : installe, retire, relance le
|
|
172
|
-
# relais permanent ; marque l'échec au premier problème puis passe à la suite
|
|
173
|
-
catalogue_appliquer() {
|
|
174
|
-
local app sortie code=0 port CTX ns
|
|
175
|
-
while IFS= read -r app; do
|
|
176
|
-
[ -n "$app" ] || continue
|
|
177
|
-
port="$(app_lire "$app" port)"
|
|
178
|
-
if [ "$(voulu "$app")" != on ] && presente "$app"; then
|
|
179
|
-
if ! sortie="$(app_desinstaller "$app" 2>&1)"; then
|
|
180
|
-
code=1; app_echec "$app" "$sortie"
|
|
181
|
-
else
|
|
182
|
-
printf '%s\n' "$sortie"
|
|
183
|
-
fi
|
|
184
|
-
elif [ "$(voulu "$app")" = on ] && presente "$app"; then
|
|
185
|
-
if ! app_prete "$app"; then
|
|
186
|
-
code=1
|
|
187
|
-
echo "devzone : catalogue : $app installé mais pas prêt : devzone apply" >&2
|
|
188
|
-
echo "pas prêt" >"$(fichier_echec "$app")"
|
|
189
|
-
else
|
|
190
|
-
rm -f "$(fichier_echec "$app")"
|
|
191
|
-
fi
|
|
192
|
-
# Relais permanent : relancé s'il est arrêté
|
|
193
|
-
CTX="$(cluster_lu)" || true
|
|
194
|
-
ns="$(app_ns "$app")"
|
|
195
|
-
if [ -n "$CTX" ]; then
|
|
196
|
-
if ! sortie="$(relais_lancer "$app" "$CTX" "$ns" "svc/$app" "$port:$port" 2>&1)"; then
|
|
197
|
-
code=1; app_echec "$app" "$sortie"
|
|
198
|
-
else
|
|
199
|
-
[ -n "$sortie" ] && printf '%s\n' "$sortie"
|
|
200
|
-
fi
|
|
201
|
-
fi
|
|
202
|
-
elif [ "$(voulu "$app")" = on ]; then
|
|
203
|
-
if ! sortie="$(app_installer "$app" 2>&1)"; then
|
|
204
|
-
code=1; app_echec "$app" "$sortie"
|
|
205
|
-
else
|
|
206
|
-
printf '%s\n' "$sortie"
|
|
207
|
-
fi
|
|
208
|
-
fi
|
|
209
|
-
done <<<"$(catalogue_apps)"
|
|
210
|
-
return "$code"
|
|
211
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Détection à chaud du catalogue (#414) : quand .devzone.modules change,
|
|
3
|
-
# catalogue.sh appliquer est lancé. Une seule instance (verrou, comme #394).
|
|
4
|
-
# catalogue-veilleur.sh demarrer | arreter | tour
|
|
5
|
-
set -euo pipefail
|
|
6
|
-
|
|
7
|
-
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
-
RACINE="${DEVZONE_RACINE:-$(cd "$ICI/../.." && pwd)}"
|
|
9
|
-
ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
10
|
-
# shellcheck source=SCRIPTDIR/etat.sh
|
|
11
|
-
# shellcheck disable=SC1091
|
|
12
|
-
. "$(dirname "$ICI")/etat.sh"
|
|
13
|
-
BASE="${DEVZONE_CATALOGUE_VEILLEUR_DIR:-$RACINE/.devzone.catalogue-veilleur}"
|
|
14
|
-
VERROU="$BASE/verrou"
|
|
15
|
-
DERNIER="$BASE/dernier"
|
|
16
|
-
|
|
17
|
-
refuse() { echo "devzone : catalogue-veilleur : $*" >&2; exit 2; }
|
|
18
|
-
|
|
19
|
-
# Garde-fou (#293) : jamais sous bats, seulement avec DEVZONE_CATALOGUE_REEL=oui
|
|
20
|
-
garde_veilleur() {
|
|
21
|
-
if [ "${DEVZONE_CATALOGUE_REEL:-}" != oui ]; then
|
|
22
|
-
echo "devzone : catalogue-veilleur : refusé ici (DEVZONE_CATALOGUE_REEL=oui)" >&2
|
|
23
|
-
return 2
|
|
24
|
-
fi
|
|
25
|
-
if [ -n "${BATS_TEST_TMPDIR:-}" ]; then
|
|
26
|
-
echo "devzone : catalogue-veilleur : refusé sous bats (tests)" >&2
|
|
27
|
-
return 2
|
|
28
|
-
fi
|
|
29
|
-
return 0
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
# Verrou exclusif (mkdir) avec pid ; une seule instance du veilleur
|
|
33
|
-
verrou_prendre() {
|
|
34
|
-
local debut now age pid
|
|
35
|
-
debut="$(date +%s)"
|
|
36
|
-
while true; do
|
|
37
|
-
if mkdir "$VERROU" 2>/dev/null; then echo "$$" >"$VERROU/pid"; return 0; fi
|
|
38
|
-
now="$(date +%s)"
|
|
39
|
-
age=""; [ -d "$VERROU" ] && age="$(stat -c %Y "$VERROU" 2>/dev/null || stat -f %m "$VERROU" 2>/dev/null || true)"
|
|
40
|
-
pid="$(cat "$VERROU/pid" 2>/dev/null || true)"
|
|
41
|
-
if [ -n "$age" ] && [ "$(( now - age ))" -gt 30 ]; then rm -rf "$VERROU"; continue; fi
|
|
42
|
-
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then rm -rf "$VERROU"; continue; fi
|
|
43
|
-
[ "$(( now - debut ))" -ge 5 ] && return 1
|
|
44
|
-
sleep 1
|
|
45
|
-
done
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
# Marque le verrou vivant (date et pid à jour)
|
|
49
|
-
verrou_rafraichir() { touch "$VERROU" 2>/dev/null || true; echo "$$" >"$VERROU/pid" 2>/dev/null || true; }
|
|
50
|
-
|
|
51
|
-
# Un tour : si .devzone.modules a changé depuis le dernier tour, on applique
|
|
52
|
-
tour() {
|
|
53
|
-
local maintenant ancien
|
|
54
|
-
[ -f "$ETAT" ] || return 0
|
|
55
|
-
# État restauré ou reconstruit : le veilleur ne suit pas un état douteux,
|
|
56
|
-
# et ne désinstalle jamais tant que devzone apply ne l'a pas confirmé
|
|
57
|
-
state_recovery_wait && return 0
|
|
58
|
-
state_recovery_pending && return 0
|
|
59
|
-
mkdir -p "$BASE"
|
|
60
|
-
maintenant="$(stat -c %Y "$ETAT" 2>/dev/null || stat -f %m "$ETAT" 2>/dev/null || true)"
|
|
61
|
-
[ -n "$maintenant" ] || return 0
|
|
62
|
-
ancien="$(cat "$DERNIER" 2>/dev/null || true)"
|
|
63
|
-
if [ "$maintenant" != "$ancien" ]; then
|
|
64
|
-
echo "$maintenant" >"$DERNIER"
|
|
65
|
-
echo "devzone : catalogue-veilleur : .devzone.modules modifié, application" >&2
|
|
66
|
-
bash "$ICI/../catalogue.sh" apply
|
|
67
|
-
fi
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
# Boucle : un tour toutes les 5 s, verrou rafraîchi à chaque tour
|
|
71
|
-
boucle() {
|
|
72
|
-
mkdir -p "$BASE"
|
|
73
|
-
if ! verrou_prendre; then return 0; fi
|
|
74
|
-
trap 'rm -rf "$VERROU"' EXIT INT TERM
|
|
75
|
-
while true; do
|
|
76
|
-
[ -f "$ETAT" ] || { rm -rf "$VERROU"; break; }
|
|
77
|
-
verrou_rafraichir
|
|
78
|
-
tour || true
|
|
79
|
-
sleep 5
|
|
80
|
-
done
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
# Lance la boucle détachée (#435) et vérifie que son verrou vit
|
|
84
|
-
lancer_detache() {
|
|
85
|
-
local i pid stable=0 detache=()
|
|
86
|
-
mkdir -p "$BASE"
|
|
87
|
-
# Même détachement que relais_lancer : setsid si présent, sinon nohup.
|
|
88
|
-
command -v setsid >/dev/null 2>&1 && detache=(setsid)
|
|
89
|
-
${detache[@]+"${detache[@]}"} nohup env DEVZONE_CATALOGUE_REEL=oui bash "$0" boucle >"$BASE/veilleur.log" 2>&1 &
|
|
90
|
-
i=0
|
|
91
|
-
while [ "$i" -lt 20 ]; do
|
|
92
|
-
pid="$(cat "$VERROU/pid" 2>/dev/null || true)"
|
|
93
|
-
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
|
|
94
|
-
stable=$((stable + 1))
|
|
95
|
-
[ "$stable" -ge 5 ] && { echo "lancé"; return 0; }
|
|
96
|
-
else
|
|
97
|
-
stable=0
|
|
98
|
-
fi
|
|
99
|
-
sleep 0.1
|
|
100
|
-
i=$((i + 1))
|
|
101
|
-
done
|
|
102
|
-
echo "devzone : catalogue-veilleur : démarrage impossible, voir $BASE/veilleur.log" >&2
|
|
103
|
-
return 1
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
# Arrête le veilleur et retire le verrou
|
|
107
|
-
arreter() {
|
|
108
|
-
local pid
|
|
109
|
-
pid="$(cat "$VERROU/pid" 2>/dev/null || true)"
|
|
110
|
-
if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
|
|
111
|
-
rm -rf "$VERROU"
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
case "${1:-}" in
|
|
115
|
-
boucle | loop) if ! garde_veilleur; then exit 2; fi; boucle ;;
|
|
116
|
-
demarrer | start | lancer)
|
|
117
|
-
if ! garde_veilleur; then exit 2; fi
|
|
118
|
-
if [ -f "$VERROU/pid" ] && kill -0 "$(cat "$VERROU/pid")" 2>/dev/null; then
|
|
119
|
-
echo "déjà lancé"
|
|
120
|
-
else
|
|
121
|
-
lancer_detache || exit 1
|
|
122
|
-
fi
|
|
123
|
-
;;
|
|
124
|
-
arreter | stop) arreter ; echo "arrêté" ;;
|
|
125
|
-
tour | un-tour) tour ;;
|
|
126
|
-
*)
|
|
127
|
-
echo "devzone : catalogue-veilleur : demarrer | arreter | tour" >&2
|
|
128
|
-
exit 2
|
|
129
|
-
;;
|
|
130
|
-
esac
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Installation MySQL (#440) : secret, chart et réinstallation sur un volume.
|
|
3
|
-
# shellcheck source=SCRIPTDIR/../../chart-direct.sh
|
|
4
|
-
# shellcheck disable=SC1091
|
|
5
|
-
. "$ICI/../../chart-direct.sh"
|
|
6
|
-
|
|
7
|
-
# Secret admin (mysql-admin) : root.env ou secret existant, jamais régénéré.
|
|
8
|
-
mysql_secret() {
|
|
9
|
-
local mdp fichier="$SECRETS/admin-password"
|
|
10
|
-
mkdir -p "$SECRETS"
|
|
11
|
-
chmod 700 "$SECRETS"
|
|
12
|
-
if k get secret mysql-admin >/dev/null 2>&1; then
|
|
13
|
-
mdp="$(k get secret mysql-admin -o jsonpath='{.data.password}' | base64 -d | tr -d '\n')"
|
|
14
|
-
(umask 077 && printf '%s' "$mdp" >"$fichier")
|
|
15
|
-
return 0
|
|
16
|
-
fi
|
|
17
|
-
mdp="$(sed -n 's/^MYSQL_PASSWORD=//p' "$SECRETS/root.env" 2>/dev/null | tail -1 || true)"
|
|
18
|
-
if [ -z "$mdp" ] && [ -s "$fichier" ]; then mdp="$(cat "$fichier")"; fi
|
|
19
|
-
if [ -z "$mdp" ]; then
|
|
20
|
-
(umask 077 && openssl rand -hex 24 | tr -d '\n' >"$fichier")
|
|
21
|
-
k create secret generic mysql-admin --from-file=password="$fichier" >/dev/null
|
|
22
|
-
elif [ ! -s "$fichier" ]; then
|
|
23
|
-
(umask 077 && printf '%s' "$mdp" >"$fichier")
|
|
24
|
-
fi
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
# Attente du StatefulSet posé par Argo CD (#538) : la synchronisation est en
|
|
28
|
-
# tâche de fond, le rollout est sondé jusqu'à MYSQL_ATTENTE
|
|
29
|
-
mysql_attendre() {
|
|
30
|
-
local fin=$((SECONDS + MYSQL_ATTENTE))
|
|
31
|
-
while [ "$SECONDS" -lt "$fin" ]; do
|
|
32
|
-
if k rollout status statefulset/mysql --timeout=10s >/dev/null 2>&1; then
|
|
33
|
-
return 0
|
|
34
|
-
fi
|
|
35
|
-
sleep 5
|
|
36
|
-
done
|
|
37
|
-
echo "devzone : catalogue mysql : pas prêt après ${MYSQL_ATTENTE}s : kubectl --context $1 -n $NS describe pod mysql-0" >&2
|
|
38
|
-
return 1
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# Installation MySQL par Argo CD (#538) : Application devzone-mysql (chart
|
|
42
|
-
# charts/devzone-mysql du dépôt devzone), namespace et secret créés à part ;
|
|
43
|
-
# le claim suit les volumes existants, comme le chemin manifeste
|
|
44
|
-
mysql_installer_argocd() {
|
|
45
|
-
local CTX="$1" claim extra=""
|
|
46
|
-
mysql_secret
|
|
47
|
-
claim="$(mysql_claim_choisir "$NS")" || return 2
|
|
48
|
-
[ "$claim" = donnees ] || extra="claim=$claim"
|
|
49
|
-
catalogue_argocd_apply mysql "$NS" "$MYSQL_IMAGE" "$MYSQL_PORT" \
|
|
50
|
-
"$MYSQL_MEMOIRE" "$MYSQL_TAILLE" "$extra" || return 1
|
|
51
|
-
mysql_attendre "$CTX" || return 1
|
|
52
|
-
mysql_secret
|
|
53
|
-
relais_lancer mysql "$CTX" "$NS" svc/mysql 3306:3306
|
|
54
|
-
echo "✔ MySQL prêt : 127.0.0.1:$MYSQL_PORT dans le conteneur"
|
|
55
|
-
regenerer_identifiants
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# Installe le chart charts/devzone-mysql avec le claim choisi (#440, #559)
|
|
59
|
-
mysql_appliquer_chart() {
|
|
60
|
-
local ns="$1" claim="$2"
|
|
61
|
-
chart_install mysql "$ns" "image=$MYSQL_IMAGE" "port=$MYSQL_PORT" \
|
|
62
|
-
"memory=$MYSQL_MEMOIRE" "size=$MYSQL_TAILLE" "claim=$claim"
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
# (Ré)installe MySQL sur le claim demandé, données du PVC gardées (#440)
|
|
66
|
-
mysql_installer_claim() {
|
|
67
|
-
local ns="$1" claim="$2" CTX
|
|
68
|
-
CTX="$(contexte)"
|
|
69
|
-
if ! contexte_devzone_poser "$CTX"; then
|
|
70
|
-
echo "devzone : catalogue mysql : impossible de poser le contexte devzone sur $CTX" >&2
|
|
71
|
-
return 1
|
|
72
|
-
fi
|
|
73
|
-
echo "▶ MySQL sur le cluster $CTX (namespace $ns, volume ${claim}-mysql-0)…"
|
|
74
|
-
compte_namespace "$CTX" "$ns"
|
|
75
|
-
namespace_isoler "$ns" >/dev/null
|
|
76
|
-
mysql_secret
|
|
77
|
-
k delete statefulset mysql --ignore-not-found >/dev/null 2>&1 || true
|
|
78
|
-
mysql_appliquer_chart "$ns" "$claim" || return 1
|
|
79
|
-
if ! k rollout status statefulset/mysql --timeout="${MYSQL_ATTENTE}s" >/dev/null; then
|
|
80
|
-
echo "devzone : catalogue mysql : pas prêt après ${MYSQL_ATTENTE}s : kubectl --context $CTX -n $ns describe pod mysql-0" >&2
|
|
81
|
-
return 1
|
|
82
|
-
fi
|
|
83
|
-
mysql_secret
|
|
84
|
-
relais_lancer mysql "$CTX" "$ns" svc/mysql 3306:3306
|
|
85
|
-
echo "✔ MySQL prêt : 127.0.0.1:$MYSQL_PORT dans le conteneur"
|
|
86
|
-
regenerer_identifiants
|
|
87
|
-
}
|