devzone 0.42.0 → 0.43.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 +1 -1
- package/.devcontainer/agent.sh +1 -1
- package/.devcontainer/argocd/apps.sh +2 -2
- package/.devcontainer/argocd/argocd.sh +22 -10
- package/.devcontainer/argocd/catalogue-argocd.sh +4 -0
- package/.devcontainer/argocd/gitops-gitlab.sh +127 -0
- package/.devcontainer/argocd/gitops.sh +12 -2
- package/.devcontainer/argocd/services-hook.sh +181 -0
- package/.devcontainer/catalogue/app.sh +29 -12
- package/.devcontainer/catalogue/catalogue-veilleur.sh +2 -2
- package/.devcontainer/catalogue/mysql/installer.sh +9 -8
- package/.devcontainer/catalogue/mysql/mysql.sh +42 -29
- package/.devcontainer/catalogue/mysql/volume.sh +5 -5
- package/.devcontainer/catalogue.sh +30 -36
- package/.devcontainer/chart-direct.sh +49 -0
- package/.devcontainer/cluster.sh +11 -11
- package/.devcontainer/clusters.sh +1 -1
- package/.devcontainer/command-aliases.sh +152 -2
- package/.devcontainer/demarrage.sh +18 -15
- package/.devcontainer/devcontainer.json +1 -1
- package/.devcontainer/devzone +114 -122
- package/.devcontainer/docker-relais.sh +2 -2
- package/.devcontainer/docker-sans-hote.sh +1 -1
- package/.devcontainer/etat-json.sh +16 -16
- package/.devcontainer/etat.sh +4 -4
- package/.devcontainer/gitlab/argocd.sh +54 -0
- package/.devcontainer/gitlab/chart.sh +39 -0
- package/.devcontainer/gitlab/gitlab.sh +35 -180
- package/.devcontainer/gitlab/installation.sh +34 -47
- package/.devcontainer/gitlab/secrets.sh +2 -2
- package/.devcontainer/gitlab/seed.sh +204 -0
- package/.devcontainer/gitlab/test-gitlab-restes.sh +16 -0
- package/.devcontainer/gitlab/test-gitlab.sh +14 -13
- package/.devcontainer/help.sh +40 -0
- package/.devcontainer/kube-compte.sh +2 -2
- package/.devcontainer/kube-config.sh +1 -1
- package/.devcontainer/kube-joignable.sh +2 -0
- package/.devcontainer/opencode.jsonc +1 -1
- package/.devcontainer/paquets.sh +31 -18
- package/.devcontainer/ports-auto.sh +6 -6
- package/.devcontainer/ports-json.sh +34 -0
- package/.devcontainer/ports.sh +34 -43
- package/.devcontainer/post-create.sh +3 -3
- package/.devcontainer/postgres/postgres.sh +46 -32
- package/.devcontainer/services-admin.sh +13 -3
- package/.devcontainer/skills/devzone/SKILL.md +16 -16
- package/.devcontainer/versions.env +1 -1
- package/README.md +72 -40
- package/charts/devzone-gitlab/Chart.lock +9 -0
- package/charts/devzone-gitlab/Chart.yaml +15 -0
- package/charts/devzone-gitlab/values.yaml +94 -0
- package/charts/devzone-mysql/values.yaml +3 -3
- package/charts/devzone-postgres/values.yaml +2 -2
- package/manage/scripts/check-charts.sh +67 -19
- package/manage/scripts/docker-workstation.sh +73 -0
- package/manage/scripts/lancer.sh +1 -1
- package/manage/scripts/migrer-retour.sh +1 -0
- package/manage/scripts/migrer.sh +6 -0
- package/manage/scripts/services-workspace.sh +11 -3
- package/package.json +1 -1
- package/.devcontainer/catalogue/mysql/manifeste.yaml +0 -81
- package/.devcontainer/gitlab/runner-values.yaml +0 -27
- package/.devcontainer/gitlab/values.yaml +0 -83
- package/.devcontainer/postgres/postgres.yaml +0 -84
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
# Sourcé par gitlab.sh : namespace devzone-gitlab (suffixé par instance),
|
|
4
4
|
# vérification de la mémoire allouable, Helm avec le contexte devzone,
|
|
5
5
|
# relais port-forward, runner et migration depuis l'ancien cluster kind.
|
|
6
|
-
#
|
|
6
|
+
# Le chart enveloppe charts/devzone-gitlab (#538) porte les dépendances et les
|
|
7
|
+
# valeurs ; chart.sh (helm direct) et argocd.sh (Application) l'installent.
|
|
7
8
|
|
|
8
9
|
# Namespace isolé du module : un par instance, comme postgres
|
|
9
10
|
GITLAB_NS="devzone-gitlab${INSTANCE_SUFFIX}"
|
|
10
|
-
# Ancien cluster kind de GitLab, supprimé par « devzone gitlab
|
|
11
|
+
# Ancien cluster kind de GitLab, supprimé par « devzone gitlab migrate »
|
|
11
12
|
GITLAB_ANCIEN_CLUSTER="gitlab${INSTANCE_SUFFIX}"
|
|
12
13
|
GITLAB_ANCIEN_CONTEXTE="kind-gitlab${INSTANCE_SUFFIX}"
|
|
13
14
|
|
|
@@ -55,7 +56,7 @@ gitlab_verifier_memoire_cluster() {
|
|
|
55
56
|
return 2
|
|
56
57
|
fi
|
|
57
58
|
if [ "$memoire" -lt 8388608 ]; then
|
|
58
|
-
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
|
|
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
|
|
59
60
|
return 2
|
|
60
61
|
fi
|
|
61
62
|
return 0
|
|
@@ -84,26 +85,23 @@ gitlab_installer() {
|
|
|
84
85
|
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
85
86
|
gitlab_namespace_preparer
|
|
86
87
|
|
|
87
|
-
# Dépôt Helm GitLab (idempotent)
|
|
88
|
-
echo "▶ Ajout du dépôt Helm GitLab…"
|
|
89
|
-
helm repo add gitlab https://charts.gitlab.io 2>/dev/null || true
|
|
90
|
-
helm repo update >/dev/null 2>&1 || true
|
|
91
|
-
|
|
92
|
-
# Installation des services en ClusterIP, sans exposition directe :
|
|
93
|
-
# l'accès passe uniquement par le relais port-forward du conteneur
|
|
94
|
-
echo "▶ Installation du chart GitLab dans $GITLAB_NS…"
|
|
95
88
|
# Secret Rails (#347) : réinstallation -> réappliquer le secret conservé avant
|
|
96
|
-
#
|
|
89
|
+
# l'installation (le chart le réutilise, sessions navigateur valides)
|
|
97
90
|
gitlab_secrets_appliquer
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
gitlab_runner_ancien_retirer
|
|
92
|
+
|
|
93
|
+
# Argo CD holds the chart when the module is on (#538): the Application
|
|
94
|
+
# syncs it and the seed runs once GitLab answers. Otherwise the wrapper chart
|
|
95
|
+
# is installed by helm, the runner held back until the seed wrote its Secret
|
|
96
|
+
local par_argocd=0
|
|
97
|
+
if gitlab_argocd_active; then
|
|
98
|
+
par_argocd=1
|
|
99
|
+
gitlab_release_adopter
|
|
100
|
+
gitlab_application_apply || return 1
|
|
101
|
+
else
|
|
102
|
+
echo "▶ Installation du chart GitLab dans $GITLAB_NS…"
|
|
103
|
+
gitlab_chart_depend
|
|
104
|
+
gitlab_helm_pass 0 || return 1
|
|
107
105
|
fi
|
|
108
106
|
|
|
109
107
|
# Relais avant l'attente : curl et git en HTTP résolvent *.localhost vers
|
|
@@ -116,26 +114,13 @@ gitlab_installer() {
|
|
|
116
114
|
|
|
117
115
|
gitlab_attendre_pret
|
|
118
116
|
gitlab_seed
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
# de l'instance (jamais le namespace fixe « gitlab » d'avant #396)
|
|
122
|
-
echo "▶ Installation de l'exécuteur GitLab Runner…"
|
|
123
|
-
local runner_token="" valeurs_runner
|
|
124
|
-
if [ -f "$GITLAB_SECRETS_DIR/runner-token" ]; then
|
|
125
|
-
runner_token="$(cat "$GITLAB_SECRETS_DIR/runner-token")"
|
|
117
|
+
if [ ! -f "$GITLAB_RAILS_FICHIER" ]; then
|
|
118
|
+
gitlab_secrets_copier
|
|
126
119
|
fi
|
|
127
|
-
if [
|
|
128
|
-
echo "
|
|
129
|
-
return 1
|
|
120
|
+
if [ "$par_argocd" = 0 ]; then
|
|
121
|
+
echo "▶ Exécuteur GitLab Runner…"
|
|
122
|
+
gitlab_helm_pass 1 || return 1
|
|
130
123
|
fi
|
|
131
|
-
valeurs_runner="$(mktemp)"
|
|
132
|
-
sed "s/__NAMESPACE__/$GITLAB_NS/g" "$ICI/runner-values.yaml" >"$valeurs_runner"
|
|
133
|
-
compte_helm "$(compte_ctx)" upgrade --install gitlab-runner gitlab/gitlab-runner \
|
|
134
|
-
--version 0.88.2 \
|
|
135
|
-
--namespace "$GITLAB_NS" \
|
|
136
|
-
-f "$valeurs_runner" \
|
|
137
|
-
--set "runnerToken=${runner_token}"
|
|
138
|
-
rm -f "$valeurs_runner"
|
|
139
124
|
|
|
140
125
|
gitlab_secrets_avertir
|
|
141
126
|
|
|
@@ -147,21 +132,23 @@ gitlab_installer() {
|
|
|
147
132
|
|
|
148
133
|
# Retire GitLab : relais, releases Helm et namespace de l'instance seulement.
|
|
149
134
|
# Le secret Rails est gardé (sessions du navigateur valides à la réinstallation),
|
|
150
|
-
# sauf désinstallation complète voulue (--
|
|
135
|
+
# sauf désinstallation complète voulue (--yes) : il part alors avec les données.
|
|
151
136
|
gitlab_desinstaller() {
|
|
152
137
|
local supprimer_secret="" arg
|
|
153
138
|
for arg in "$@"; do
|
|
154
139
|
case "$arg" in
|
|
155
|
-
--
|
|
156
|
-
*) echo "devzone : gitlab
|
|
140
|
+
--yes) supprimer_secret=1 ;;
|
|
141
|
+
*) echo "devzone : gitlab uninstall : argument inconnu : $arg" >&2; return 2 ;;
|
|
157
142
|
esac
|
|
158
143
|
done
|
|
159
144
|
echo "▶ Désinstallation de GitLab…"
|
|
160
145
|
gitlab_relais_arreter
|
|
161
146
|
rm -rf "$(relais_dossier gitlab-web)" "$(relais_dossier gitlab-ssh)" \
|
|
162
147
|
"$(relais_dossier gitlab-8929)" "$(relais_dossier gitlab-2224)"
|
|
148
|
+
# Application tenue par Argo CD (#538) : ses ressources partent avec elle
|
|
149
|
+
gitlab_application_retirer || true
|
|
163
150
|
compte_helm "$(compte_ctx)" uninstall gitlab --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
164
|
-
|
|
151
|
+
gitlab_runner_ancien_retirer
|
|
165
152
|
# RoleBinding retiré puis namespace supprimé par l'administrateur (#430)
|
|
166
153
|
compte_retirer "$(compte_ctx)" "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
167
154
|
compte_admin "$(compte_ctx)" delete namespace "$GITLAB_NS" --ignore-not-found >/dev/null 2>&1 || true
|
|
@@ -180,13 +167,13 @@ gitlab_desinstaller() {
|
|
|
180
167
|
}
|
|
181
168
|
|
|
182
169
|
# Migration : installe et seed dans le cluster des services, puis supprime
|
|
183
|
-
# l'ancien cluster kind-gitlab après confirmation (ou --
|
|
170
|
+
# l'ancien cluster kind-gitlab après confirmation (ou --yes).
|
|
184
171
|
gitlab_migrer() {
|
|
185
172
|
local oui="" arg reponse
|
|
186
173
|
for arg in "$@"; do
|
|
187
174
|
case "$arg" in
|
|
188
|
-
--
|
|
189
|
-
*) echo "devzone : gitlab
|
|
175
|
+
--yes) oui=1 ;;
|
|
176
|
+
*) echo "devzone : gitlab migrate : argument inconnu : $arg (devzone gitlab migrate [--yes])" >&2; return 2 ;;
|
|
190
177
|
esac
|
|
191
178
|
done
|
|
192
179
|
|
|
@@ -201,7 +188,7 @@ gitlab_migrer() {
|
|
|
201
188
|
|
|
202
189
|
if [ -z "$oui" ]; then
|
|
203
190
|
if ! cluster_interactif; then
|
|
204
|
-
echo "devzone : gitlab : confirmation impossible sans terminal : devzone gitlab
|
|
191
|
+
echo "devzone : gitlab : confirmation impossible sans terminal : devzone gitlab migrate --yes (ancien cluster $GITLAB_ANCIEN_CONTEXTE conservé)" >&2
|
|
205
192
|
return 2
|
|
206
193
|
fi
|
|
207
194
|
printf "Supprimer l'ancien cluster %s et ses données ? [o/N] " "$GITLAB_ANCIEN_CONTEXTE" >&2
|
|
@@ -62,7 +62,7 @@ gitlab_nouveau_mdp() {
|
|
|
62
62
|
case "$utilisateur" in
|
|
63
63
|
root | dev) ;;
|
|
64
64
|
*)
|
|
65
|
-
echo "devzone : gitlab : utilisateur inconnu : ${utilisateur:-(absent)} (devzone gitlab
|
|
65
|
+
echo "devzone : gitlab : utilisateur inconnu : ${utilisateur:-(absent)} (devzone gitlab new-password [root|dev])" >&2
|
|
66
66
|
return 2
|
|
67
67
|
;;
|
|
68
68
|
esac
|
|
@@ -90,6 +90,6 @@ puts \"OK\""
|
|
|
90
90
|
(umask 077 && printf '%s' "$mdp" >"$fichier") || return 1
|
|
91
91
|
chmod 600 "$fichier"
|
|
92
92
|
password_regenerer ||
|
|
93
|
-
echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone
|
|
93
|
+
echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
94
94
|
printf '%s\n' "$RACINE/.password"
|
|
95
95
|
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Seed of the GitLab of devzone (#396, #538): the data a fresh instance needs,
|
|
3
|
+
# group devzone, demo project, dev user, runner. Sourced by gitlab.sh. The
|
|
4
|
+
# installer starts the relays and waits for GitLab before the seed; the seed
|
|
5
|
+
# command (devzone gitlab seed, run in the pod by services-admin.sh when Argo
|
|
6
|
+
# CD holds the chart) does it itself (gitlab_seed_commande).
|
|
7
|
+
# gitlab_attendre_pret waits for the readiness of GitLab (GITLAB_ATTENTE)
|
|
8
|
+
# gitlab_seed group, project, user, runner token and its Secret
|
|
9
|
+
# gitlab_seed_commande devzone gitlab seed: relays, readiness, seed
|
|
10
|
+
|
|
11
|
+
# ---- Helper : attendre que GitLab soit prêt ----
|
|
12
|
+
gitlab_attendre_pret() {
|
|
13
|
+
local debut
|
|
14
|
+
debut=$(date +%s)
|
|
15
|
+
echo "▶ Attente de GitLab prêt (timeout ${GITLAB_ATTENTE}s)…"
|
|
16
|
+
while [ $(( $(date +%s) - debut )) -lt "$GITLAB_ATTENTE" ]; do
|
|
17
|
+
if curl -sf http://gitlab.localhost:8929/-/readiness >/dev/null 2>&1 || curl -sf http://gitlab.localhost:8929/users/sign_in >/dev/null 2>&1; then
|
|
18
|
+
echo "▶ GitLab prêt."
|
|
19
|
+
return 0
|
|
20
|
+
fi
|
|
21
|
+
sleep 5
|
|
22
|
+
done
|
|
23
|
+
echo "devzone : timeout attente GitLab." >&2
|
|
24
|
+
return 1
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# ---- seed : peupler GitLab de données de base ----
|
|
28
|
+
gitlab_seed() {
|
|
29
|
+
echo "▶ Seed de GitLab…"
|
|
30
|
+
|
|
31
|
+
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
32
|
+
|
|
33
|
+
# Mot de passe root lu dans le secret gitlab-gitlab-initial-root-password
|
|
34
|
+
local mot_de_passe
|
|
35
|
+
mot_de_passe="$(kubectl --context devzone get secret -n "$GITLAB_NS" gitlab-gitlab-initial-root-password -o jsonpath='{.data.password}' 2>/dev/null | base64 -d 2>/dev/null || true)"
|
|
36
|
+
if [ -z "$mot_de_passe" ]; then
|
|
37
|
+
echo "devzone : seed GitLab : secret root (gitlab-gitlab-initial-root-password) introuvable, arrêt du seed." >&2
|
|
38
|
+
return 1
|
|
39
|
+
fi
|
|
40
|
+
printf '%s' "$mot_de_passe" > "$GITLAB_SECRETS_DIR/root-password"
|
|
41
|
+
chmod 600 "$GITLAB_SECRETS_DIR/root-password"
|
|
42
|
+
|
|
43
|
+
# Token d'accès root créé par kubectl exec dans le pod toolbox avec gitlab-rails runner
|
|
44
|
+
local toolbox_pod root_token
|
|
45
|
+
toolbox_pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
|
|
46
|
+
if [ -z "$toolbox_pod" ]; then
|
|
47
|
+
echo "devzone : seed GitLab : pod toolbox (label app=toolbox) introuvable, arrêt du seed." >&2
|
|
48
|
+
return 1
|
|
49
|
+
fi
|
|
50
|
+
root_token="$(kubectl --context devzone exec -n "$GITLAB_NS" "$toolbox_pod" -- gitlab-rails runner 'puts User.find_by_username("root").personal_access_tokens.create(name: "devzone", scopes: ["api", "write_repository"], expires_at: 30.days.from_now).token' 2>/dev/null | tail -n 1 || true)"
|
|
51
|
+
if [ -z "$root_token" ]; then
|
|
52
|
+
echo "devzone : seed GitLab : création du jeton root (gitlab-rails runner) échouée, arrêt du seed." >&2
|
|
53
|
+
return 1
|
|
54
|
+
fi
|
|
55
|
+
printf '%s' "$root_token" > "$GITLAB_SECRETS_DIR/root-token"
|
|
56
|
+
chmod 600 "$GITLAB_SECRETS_DIR/root-token"
|
|
57
|
+
|
|
58
|
+
# Via l'API curl avec le token (jamais affiché en clair)
|
|
59
|
+
local token groupe_id
|
|
60
|
+
token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
61
|
+
|
|
62
|
+
# Groupe devzone (testé avant création)
|
|
63
|
+
if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" >/dev/null 2>&1; then
|
|
64
|
+
if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/groups" --data "name=devzone&path=devzone&visibility=private" >/dev/null 2>&1; then
|
|
65
|
+
echo "devzone : seed GitLab : création du groupe devzone échouée, arrêt du seed." >&2
|
|
66
|
+
return 1
|
|
67
|
+
fi
|
|
68
|
+
fi
|
|
69
|
+
groupe_id="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" | jq -r '.id // empty')"
|
|
70
|
+
if [ -z "$groupe_id" ]; then
|
|
71
|
+
echo "devzone : seed GitLab : lecture de l'identifiant numérique du groupe devzone échouée, arrêt du seed." >&2
|
|
72
|
+
return 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Projet devzone/demo (testé avant création, namespace_id = ID numérique du groupe)
|
|
76
|
+
if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo" >/dev/null 2>&1; then
|
|
77
|
+
if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/projects" --data "name=demo&namespace_id=$groupe_id" >/dev/null 2>&1; then
|
|
78
|
+
echo "devzone : seed GitLab : création du projet devzone/demo échouée, arrêt du seed." >&2
|
|
79
|
+
return 1
|
|
80
|
+
fi
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
# Utilisateur dev (testé avant création, mot de passe généré aléatoirement) :
|
|
84
|
+
# un dev-password existant n'est réutilisé que si l'utilisateur dev existe
|
|
85
|
+
# encore (vérifié via l'API) ; sinon il est recréé avec un utilisateur nouveau.
|
|
86
|
+
local users_json devpass
|
|
87
|
+
users_json="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/users?username=dev")"
|
|
88
|
+
if [ "$(jq length <<<"$users_json")" -eq 0 ]; then
|
|
89
|
+
devpass="$(openssl rand -base64 18 | tr -d '\n')"
|
|
90
|
+
if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/users" --data "email=dev@gitlab.localhost&username=dev&name=dev&skip_confirmation=true" --data-urlencode "password=$devpass" >/dev/null 2>&1; then
|
|
91
|
+
echo "devzone : seed GitLab : création de l'utilisateur dev échouée, arrêt du seed." >&2
|
|
92
|
+
return 1
|
|
93
|
+
fi
|
|
94
|
+
printf '%s' "$devpass" > "$GITLAB_SECRETS_DIR/dev-password"
|
|
95
|
+
chmod 600 "$GITLAB_SECRETS_DIR/dev-password"
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# Token de runner : vérifié via POST /api/v4/runners/verify ; un jeton valide
|
|
99
|
+
# est gardé, un jeton refusé (403/404) est recréé, GitLab injoignable arrête le seed.
|
|
100
|
+
local rt_jeton rt_code rt_token
|
|
101
|
+
if [ -f "$GITLAB_SECRETS_DIR/runner-token" ]; then
|
|
102
|
+
rt_jeton="$(cat "$GITLAB_SECRETS_DIR/runner-token")"
|
|
103
|
+
rt_code="$(curl -s -o /dev/null -w '%{http_code}' --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/runners/verify" --data "token=${rt_jeton}" || true)"
|
|
104
|
+
if [ "$rt_code" = "200" ]; then
|
|
105
|
+
echo "✔ Jeton de runner valide : gardé."
|
|
106
|
+
elif [ "$rt_code" = "403" ] || [ "$rt_code" = "404" ]; then
|
|
107
|
+
echo "devzone : jeton de runner d'une installation précédente refusé : recréé."
|
|
108
|
+
rt_token="$(curl -s --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/user/runners" --data "runner_type=instance_type" 2>/dev/null | jq -r '.token // empty' || true)"
|
|
109
|
+
if [ -z "$rt_token" ]; then
|
|
110
|
+
echo "devzone : seed GitLab : création du jeton de runner (POST /api/v4/user/runners) échouée, arrêt du seed." >&2
|
|
111
|
+
return 1
|
|
112
|
+
fi
|
|
113
|
+
printf '%s' "$rt_token" > "$GITLAB_SECRETS_DIR/runner-token"
|
|
114
|
+
chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
|
|
115
|
+
else
|
|
116
|
+
echo "devzone : seed GitLab : vérification du jeton de runner impossible (code ${rt_code}), arrêt du seed." >&2
|
|
117
|
+
return 1
|
|
118
|
+
fi
|
|
119
|
+
else
|
|
120
|
+
rt_token="$(curl -s --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/user/runners" --data "runner_type=instance_type" 2>/dev/null | jq -r '.token // empty' || true)"
|
|
121
|
+
if [ -z "$rt_token" ]; then
|
|
122
|
+
echo "devzone : seed GitLab : création du jeton de runner (POST /api/v4/user/runners) échouée, arrêt du seed." >&2
|
|
123
|
+
return 1
|
|
124
|
+
fi
|
|
125
|
+
printf '%s' "$rt_token" > "$GITLAB_SECRETS_DIR/runner-token"
|
|
126
|
+
chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
# Secret of the runner of the chart (runners.secret, #538): created apart, out
|
|
130
|
+
# of Git; the token is read from its file, never on a command line
|
|
131
|
+
if ! kubectl --context devzone -n "$GITLAB_NS" create secret generic gitlab-runner-secret \
|
|
132
|
+
--from-file=runner-token="$GITLAB_SECRETS_DIR/runner-token" \
|
|
133
|
+
--from-literal=runner-registration-token= \
|
|
134
|
+
--dry-run=client -o yaml |
|
|
135
|
+
kubectl --context devzone -n "$GITLAB_NS" apply -f - >/dev/null 2>&1; then
|
|
136
|
+
echo "devzone : seed GitLab : secret gitlab-runner-secret non créé, arrêt du seed." >&2
|
|
137
|
+
return 1
|
|
138
|
+
fi
|
|
139
|
+
# A runner already running may hold the previous token: restarted on the
|
|
140
|
+
# one just written (no runner yet: nothing to restart)
|
|
141
|
+
kubectl --context devzone -n "$GITLAB_NS" rollout restart deployment \
|
|
142
|
+
--selector=app=gitlab-gitlab-runner >/dev/null 2>&1 || true
|
|
143
|
+
|
|
144
|
+
# Push du contenu de demo/ dans devzone/demo (dépôt git temporaire, remote http avec le jeton dans l'URL, jamais affiché ; branche main)
|
|
145
|
+
# Le push utilise le jeton root (write_repository) : le jeton de runner ne peut pas pousser.
|
|
146
|
+
local push_token=""
|
|
147
|
+
push_token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
148
|
+
if [ -z "$push_token" ]; then
|
|
149
|
+
echo "devzone : seed GitLab : jeton root introuvable, arrêt du seed." >&2
|
|
150
|
+
return 1
|
|
151
|
+
fi
|
|
152
|
+
# Déjà poussé (installation relancée) : rien à refaire
|
|
153
|
+
if curl -sf --header "PRIVATE-TOKEN: $push_token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo/repository/branches/main" >/dev/null 2>&1; then
|
|
154
|
+
echo "✔ Seed GitLab terminé (projet demo déjà poussé)."
|
|
155
|
+
regenerer_identifiants
|
|
156
|
+
return 0
|
|
157
|
+
fi
|
|
158
|
+
if [ -d "$ICI/demo" ]; then
|
|
159
|
+
local tmpdir
|
|
160
|
+
tmpdir="$(mktemp -d)"
|
|
161
|
+
cp -r "$ICI/demo/." "$tmpdir/"
|
|
162
|
+
if (
|
|
163
|
+
cd "$tmpdir"
|
|
164
|
+
# Dépôt jetable du script : les hooks git globaux (repowarden) n'ont
|
|
165
|
+
# rien à vérifier ici et refuseraient le commit
|
|
166
|
+
export GIT_CONFIG_PARAMETERS="'core.hooksPath=/dev/null'"
|
|
167
|
+
git init -q -b main
|
|
168
|
+
git add -A
|
|
169
|
+
git -c user.email=dev@gitlab.localhost -c user.name=dev commit -q -m "chore: projet de démonstration"
|
|
170
|
+
# gitlab.localhost n'est pas toujours résolu par git : adresse
|
|
171
|
+
# locale, et l'hôte attendu par l'ingress passé en en-tête
|
|
172
|
+
git remote add origin "http://oauth2:${push_token}@127.0.0.1:8929/devzone/demo.git"
|
|
173
|
+
git -c http.extraHeader="Host: gitlab.localhost" push -q -u origin main >/dev/null 2>&1
|
|
174
|
+
); then
|
|
175
|
+
# Vérifie le push : la branche main existe bien sur le projet
|
|
176
|
+
if ! curl -sf --header "PRIVATE-TOKEN: $push_token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo/repository/branches/main" >/dev/null 2>&1; then
|
|
177
|
+
echo "devzone : seed GitLab : push du projet demo sur /devzone/demo.git réussi mais branche main absente, arrêt du seed." >&2
|
|
178
|
+
rm -rf "$tmpdir"
|
|
179
|
+
return 1
|
|
180
|
+
fi
|
|
181
|
+
else
|
|
182
|
+
echo "devzone : seed GitLab : push du projet demo sur /devzone/demo.git échoué, arrêt du seed." >&2
|
|
183
|
+
rm -rf "$tmpdir"
|
|
184
|
+
return 1
|
|
185
|
+
fi
|
|
186
|
+
rm -rf "$tmpdir"
|
|
187
|
+
fi
|
|
188
|
+
|
|
189
|
+
echo "✔ Seed GitLab terminé."
|
|
190
|
+
regenerer_identifiants
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# devzone gitlab seed: the seed alone, when Argo CD holds the chart (the
|
|
194
|
+
# workstation runs it in the pod, services-admin.sh seed gitlab). The API and
|
|
195
|
+
# the push go through the relays: they start, GitLab is awaited, then the seed.
|
|
196
|
+
# The Rails secret of the pod is mirrored when it is not kept yet.
|
|
197
|
+
gitlab_seed_commande() {
|
|
198
|
+
gitlab_relais_lancer || return 1
|
|
199
|
+
gitlab_attendre_pret || return 1
|
|
200
|
+
gitlab_seed || return 1
|
|
201
|
+
if [ ! -f "$GITLAB_RAILS_FICHIER" ]; then
|
|
202
|
+
gitlab_secrets_copier
|
|
203
|
+
fi
|
|
204
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Leftovers of the gitlab instance after disable (test-gitlab.sh --complet, #517).
|
|
3
|
+
# Sourced by test-gitlab.sh. Docker workstation: containers labelled with the
|
|
4
|
+
# instance, from docker ps. Kubernetes workspace (DEVZONE_WORKSPACE=kubernetes):
|
|
5
|
+
# pods labelled with the instance, from kubectl get pods. Read-only commands.
|
|
6
|
+
|
|
7
|
+
# Prints the leftovers of instance $1, one per line (nothing when clean).
|
|
8
|
+
gitlab_restes_conteneurs() {
|
|
9
|
+
local instance="$1"
|
|
10
|
+
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
|
|
11
|
+
kubectl --context devzone get pods --all-namespaces \
|
|
12
|
+
-l "devzone.instance=$instance" -o name 2>/dev/null || true
|
|
13
|
+
else
|
|
14
|
+
docker ps -aq --filter "label=devzone.instance=$instance" 2>/dev/null || true
|
|
15
|
+
fi
|
|
16
|
+
}
|
|
@@ -27,6 +27,9 @@ HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
|
|
|
27
27
|
# shellcheck source=SCRIPTDIR/../cluster.sh
|
|
28
28
|
# shellcheck disable=SC1091
|
|
29
29
|
. "$ICI/../cluster.sh"
|
|
30
|
+
# shellcheck source=SCRIPTDIR/test-gitlab-restes.sh
|
|
31
|
+
# shellcheck disable=SC1091
|
|
32
|
+
. "$ICI/test-gitlab-restes.sh"
|
|
30
33
|
URL="${GITLAB_TEST_URL:-http://gitlab.localhost:8929}"
|
|
31
34
|
# Délai d'attente du pipeline : 600 s par défaut, court dans les tests
|
|
32
35
|
DELAI_PIPELINE="${GITLAB_TEST_PIPELINE:-600}"
|
|
@@ -105,9 +108,9 @@ lire_jeton() {
|
|
|
105
108
|
# plateforme de l'utilisateur changée.
|
|
106
109
|
restaurer_plateforme() {
|
|
107
110
|
if [ "$PLATEFORME_AVANT" = gitlab ] && [ -n "$URL_AVANT" ]; then
|
|
108
|
-
"$DEVZONE_BIN"
|
|
111
|
+
"$DEVZONE_BIN" platform gitlab --url "$URL_AVANT" >/dev/null 2>&1
|
|
109
112
|
else
|
|
110
|
-
"$DEVZONE_BIN"
|
|
113
|
+
"$DEVZONE_BIN" platform github >/dev/null 2>&1
|
|
111
114
|
fi
|
|
112
115
|
}
|
|
113
116
|
|
|
@@ -133,11 +136,11 @@ trap nettoyer EXIT
|
|
|
133
136
|
|
|
134
137
|
# 1. Module : actif, sinon activé (l'activation installe aussi si besoin).
|
|
135
138
|
etape_module() {
|
|
136
|
-
if "$DEVZONE_BIN"
|
|
139
|
+
if "$DEVZONE_BIN" is-enabled gitlab >/dev/null 2>&1; then
|
|
137
140
|
return 0
|
|
138
141
|
fi
|
|
139
|
-
if ! "$DEVZONE_BIN"
|
|
140
|
-
RAISON="devzone
|
|
142
|
+
if ! "$DEVZONE_BIN" enable gitlab >/dev/null 2>&1; then
|
|
143
|
+
RAISON="devzone enable gitlab a échoué"
|
|
141
144
|
return 1
|
|
142
145
|
fi
|
|
143
146
|
return 0
|
|
@@ -162,7 +165,7 @@ etape_etat() {
|
|
|
162
165
|
# 3. Nom et relais : ssh et glab passent par le résolveur système ; curl et
|
|
163
166
|
# git en HTTP résolvent *.localhost vers la boucle locale sans lire /etc/hosts.
|
|
164
167
|
# gitlab.localhost doit donc pointer vers 127.0.0.1 ET les relais 8929/2224
|
|
165
|
-
# doivent tourner dans le conteneur (gitlab.sh hote-poser,
|
|
168
|
+
# doivent tourner dans le conteneur (gitlab.sh hote-poser, relay-start).
|
|
166
169
|
etape_nom() {
|
|
167
170
|
local hote ip_nom relais
|
|
168
171
|
hote="$(getent hosts gitlab.localhost 2>/dev/null || true)"
|
|
@@ -175,7 +178,7 @@ etape_nom() {
|
|
|
175
178
|
RAISON="gitlab.localhost résolu vers $ip_nom, attendu 127.0.0.1"
|
|
176
179
|
return 1
|
|
177
180
|
fi
|
|
178
|
-
if ! relais="$(bash "$GITLAB"
|
|
181
|
+
if ! relais="$(bash "$GITLAB" relay-status 2>&1)"; then
|
|
179
182
|
RAISON="gitlab.localhost pointe vers 127.0.0.1, mais ${relais:-relais gitlab arrêté}"
|
|
180
183
|
return 1
|
|
181
184
|
fi
|
|
@@ -273,8 +276,8 @@ etape_plateforme() {
|
|
|
273
276
|
}
|
|
274
277
|
TMP_DIRS+=("$d")
|
|
275
278
|
PLATEFORME_CHANGEE=1
|
|
276
|
-
if ! "$DEVZONE_BIN"
|
|
277
|
-
RAISON="devzone
|
|
279
|
+
if ! "$DEVZONE_BIN" platform gitlab >/dev/null 2>&1; then
|
|
280
|
+
RAISON="devzone platform gitlab a échoué"
|
|
278
281
|
return 1
|
|
279
282
|
fi
|
|
280
283
|
if ! "$GLAB" repo clone devzone/demo "$d/demo" >/dev/null 2>&1; then
|
|
@@ -341,15 +344,13 @@ etape_complet() {
|
|
|
341
344
|
local restes="" instance namespace conteneurs
|
|
342
345
|
instance="${DEVZONE_INSTANCE:-devzone}"
|
|
343
346
|
namespace="devzone-gitlab${INSTANCE_SUFFIX}"
|
|
344
|
-
if ! "$DEVZONE_BIN"
|
|
347
|
+
if ! "$DEVZONE_BIN" disable gitlab >/dev/null 2>&1; then
|
|
345
348
|
restes="$restes désactivation en échec;"
|
|
346
349
|
fi
|
|
347
350
|
if kubectl --context devzone get namespace "$namespace" >/dev/null 2>&1; then
|
|
348
351
|
restes="$restes namespace $namespace;"
|
|
349
352
|
fi
|
|
350
|
-
conteneurs="$(
|
|
351
|
-
--filter "label=devzone.instance=$instance" \
|
|
352
|
-
2>/dev/null || true)"
|
|
353
|
+
conteneurs="$(gitlab_restes_conteneurs "$instance")"
|
|
353
354
|
if [ -n "$conteneurs" ]; then
|
|
354
355
|
restes="$restes conteneur(s) étiqueté(s) devzone.instance=$instance;"
|
|
355
356
|
fi
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Help of devzone (devzone --help, #557), sourced by devzone : English command
|
|
3
|
+
# names first ; the French names are still accepted and warn (deprecated).
|
|
4
|
+
# devzone_aide prints the list, indented like the other usage texts.
|
|
5
|
+
devzone_aide() {
|
|
6
|
+
cat <<'AIDE'
|
|
7
|
+
Optional modules of devzone, enabled on demand, without rebuild:
|
|
8
|
+
devzone state of the modules
|
|
9
|
+
devzone platform GitHub (default) or GitLab
|
|
10
|
+
devzone platform github back to GitHub: glab and config removed
|
|
11
|
+
devzone platform gitlab GitLab, [--url URL] (default: gitlab module)
|
|
12
|
+
devzone enable <module> enable and apply at once
|
|
13
|
+
devzone disable <module> [--yes] disable and apply at once (--yes: also deletes the data)
|
|
14
|
+
devzone apply install what is enabled (post-create.sh)
|
|
15
|
+
devzone repair repair Docker relay, gitlab, postgres, ports, passwords
|
|
16
|
+
devzone start full start (startup scripts and summary)
|
|
17
|
+
devzone metrics [context…] install metrics-server (kubectl top, k9s)
|
|
18
|
+
devzone use CTX [--confirm CTX] switch the kubectl working cluster
|
|
19
|
+
devzone clusters view of the connected clusters (work and services)
|
|
20
|
+
devzone is-enabled <module> code 0 if enabled (startup scripts)
|
|
21
|
+
devzone test-bash32 run the bats tests under bash 3.2 (Docker container)
|
|
22
|
+
devzone test-gitlab end-to-end test of the GitLab module and platform
|
|
23
|
+
devzone agent <folder> <instructions> drive opencode with the instructions file
|
|
24
|
+
devzone ticket <n> [--repo devzone|repowarden] ticket worktree (ticket done <n> removes it)
|
|
25
|
+
devzone build <folder> [--tag <name>] build an image in the Kubernetes workspace (BuildKit)
|
|
26
|
+
devzone enable postgres [--context CTX] [--confirm CTX] shared PostgreSQL, cluster of choice
|
|
27
|
+
devzone postgres create <project> database and user of a project (also: list, psql, delete)
|
|
28
|
+
devzone mysql create <project> database and user of a MySQL project (also: list, delete)
|
|
29
|
+
devzone gitlab migrate [--yes] GitLab in the services cluster, then the old kind cluster deleted
|
|
30
|
+
devzone gitlab new-password [root|dev] random password (root or dev) regenerated
|
|
31
|
+
devzone enable argocd Argo CD in the services cluster, access https://127.0.0.1:8443
|
|
32
|
+
devzone argocd status|relay-start|relay-stop Argo CD (argocd module)
|
|
33
|
+
devzone argocd app add <repo url> [path]|list|remove <N> projects deployed by Argo CD (#516)
|
|
34
|
+
devzone cluster [CTX] [--yes] [--confirm CTX] services cluster of devzone, or change it
|
|
35
|
+
devzone port [<n>|--close <n>] relay of a container port to the workstation
|
|
36
|
+
devzone passwords regenerate .password and print its path
|
|
37
|
+
devzone packages [add|remove|apply] … system packages kept after a rebuild
|
|
38
|
+
Old French names are still accepted (deprecated).
|
|
39
|
+
AIDE
|
|
40
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
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
6
|
# avec un jeton TokenRequest de 24 h renouvelé au démarrage (demarrage.sh) et
|
|
7
|
-
# par « devzone
|
|
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 :
|
|
@@ -180,7 +180,7 @@ compte_jeton() {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
# Exécution directe : jeton du compte renouvelé au démarrage (demarrage.sh) et
|
|
183
|
-
# par « devzone
|
|
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
|
|
186
186
|
if [ "${1:-}" != jeton ]; then
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# tls-server-name garde le nom attendu par le certificat
|
|
7
7
|
# - ~/.kube/config : clusters kind du conteneur, jamais touché ici
|
|
8
8
|
# KUBECONFIG (devcontainer.json) combine les deux.
|
|
9
|
-
# Module kubernetes (devzone
|
|
9
|
+
# Module kubernetes (devzone enable kubernetes) : connexion au cluster de
|
|
10
10
|
# l'hôte et metrics-server seulement s'il est actif ; les contextes kind sont
|
|
11
11
|
# toujours remis (un cluster créé à la main reste utilisable).
|
|
12
12
|
set -euo pipefail
|
|
@@ -33,6 +33,8 @@ kube_rejoindre_reseau() {
|
|
|
33
33
|
kube_joignable_depuis_conteneur() {
|
|
34
34
|
local fichier="${1:-}" nom serveur hote port noeud
|
|
35
35
|
[ -n "$fichier" ] || return 0
|
|
36
|
+
# Kubernetes workspace (#517): the pod reaches the API through the cluster service, no docker call
|
|
37
|
+
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then return 0; fi
|
|
36
38
|
KUBECONFIG="$fichier" kubectl config view \
|
|
37
39
|
-o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}' 2>/dev/null |
|
|
38
40
|
while IFS=$'\t' read -r nom serveur; do
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// devzone : configuration opencode par défaut (devzone
|
|
1
|
+
// devzone : configuration opencode par défaut (devzone enable ia la tient à jour ; retirer cette ligne pour la personnaliser)
|
|
2
2
|
{
|
|
3
3
|
"$schema": "https://opencode.ai/config.json",
|
|
4
4
|
// Modèles gratuits de la version d'opencode fixée par devzone.
|