devzone 0.14.0 → 0.14.2
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# À chaque démarrage, dans l'ordre : identité git (déduite du compte gh),
|
|
3
|
-
# clusters Kubernetes,
|
|
3
|
+
# clusters Kubernetes, nom gitlab.localhost si le module gitlab est actif,
|
|
4
|
+
# puis récapitulatif de ce qui reste à faire (devzone).
|
|
4
5
|
# Séquentiel : le récapitulatif voit l'identité tout juste posée ; l'échec
|
|
5
6
|
# d'une étape n'empêche pas les suivantes.
|
|
6
7
|
# Jamais de question (gh, kubectl et ses plugins d'authentification) : sortie
|
|
@@ -9,5 +10,11 @@ exec </dev/null
|
|
|
9
10
|
ICI="$(dirname "$0")"
|
|
10
11
|
bash "$ICI/git-identite.sh" || echo "démarrage : identité git non traitée (bash $ICI/git-identite.sh)"
|
|
11
12
|
bash "$ICI/kube-config.sh" || echo "démarrage : clusters non traités (bash $ICI/kube-config.sh)"
|
|
13
|
+
# Module gitlab actif : /etc/hosts est un montage Docker régénéré à chaque
|
|
14
|
+
# démarrage, gitlab.localhost doit être re-pose (ssh, glab et getent passent
|
|
15
|
+
# par le résolveur système) ; hote-poser n'échoue jamais (avertissement seul)
|
|
16
|
+
if bash "$ICI/devzone" actif gitlab; then
|
|
17
|
+
bash "$ICI/gitlab/gitlab.sh" hote-poser || echo "démarrage : nom gitlab.localhost non posé (bash $ICI/gitlab/gitlab.sh hote-poser)"
|
|
18
|
+
fi
|
|
12
19
|
echo
|
|
13
20
|
bash "$ICI/devzone"
|
package/.devcontainer/devzone
CHANGED
|
@@ -312,6 +312,8 @@ appliquer_gitlab() {
|
|
|
312
312
|
etat_courant="$(bash "$ICI/gitlab/gitlab.sh" etat)"
|
|
313
313
|
if [[ "$etat_courant" == *"prêt"* && "$etat_courant" == *"runner en ligne"* ]]; then
|
|
314
314
|
echo "devzone : gitlab déjà actif, rien à faire."
|
|
315
|
+
# /etc/hosts régénéré par Docker : gitlab.localhost re-pose ici aussi
|
|
316
|
+
bash "$ICI/gitlab/gitlab.sh" hote-poser
|
|
315
317
|
else
|
|
316
318
|
echo "devzone : gitlab activation via installer…"
|
|
317
319
|
if ! bash "$ICI/gitlab/gitlab.sh" installer; then
|
|
@@ -17,6 +17,11 @@ GITLAB_ATTENTE="${GITLAB_ATTENTE:-1200}"
|
|
|
17
17
|
# Secrets stockés dans $RACINE/workspace/.gitlab/ (chmod 600), jamais affichés.
|
|
18
18
|
GITLAB_SECRETS_DIR="$RACINE/workspace/.gitlab"
|
|
19
19
|
|
|
20
|
+
# ---- /etc/hosts du conteneur ----
|
|
21
|
+
# DEVZONE_HOSTS pour les tests (jamais le /etc/hosts réel)
|
|
22
|
+
HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
|
|
23
|
+
GITLAB_HOTE_MARQUE="# devzone:gitlab"
|
|
24
|
+
|
|
20
25
|
# ---- Helper : vérifier la RAM libre (refus < 8 Go) ----
|
|
21
26
|
gitlab_verifier_ram() {
|
|
22
27
|
local ram_kb
|
|
@@ -174,6 +179,48 @@ gitlab_seed() {
|
|
|
174
179
|
echo "✔ Seed GitLab terminé."
|
|
175
180
|
}
|
|
176
181
|
|
|
182
|
+
# ---- hote-poser / hote-retirer : gitlab.localhost dans /etc/hosts ----
|
|
183
|
+
# Pourquoi : ssh (clone ssh://git@gitlab.localhost:2224/…), glab et getent
|
|
184
|
+
# passent par le résolveur système, qui ne connaît pas gitlab.localhost ;
|
|
185
|
+
# seul curl résout les noms en .localhost lui-même. /etc/hosts est un
|
|
186
|
+
# montage Docker que Docker régénère au démarrage du conteneur, d'où le
|
|
187
|
+
# re-pose à chaque démarrage (demarrage.sh) et à chaque activation.
|
|
188
|
+
# Jamais de sed -i ni de mv : le montage ne peut pas être renommé
|
|
189
|
+
# (l'écriture en place seulement) ; directe si le fichier est inscriptible,
|
|
190
|
+
# sinon sudo -n. Un échec n'échoue jamais : avertissement sur stderr et
|
|
191
|
+
# code 0, pour ne pas faire échouer l'installation pour un nom d'hôte.
|
|
192
|
+
gitlab_hote_poser() {
|
|
193
|
+
# Déjà posée : rien (idempotent)
|
|
194
|
+
if grep -q "$GITLAB_HOTE_MARQUE" "$HOSTS" 2>/dev/null; then
|
|
195
|
+
return 0
|
|
196
|
+
fi
|
|
197
|
+
if [ -w "$HOSTS" ]; then
|
|
198
|
+
printf '127.0.0.1\tgitlab.localhost %s\n' "$GITLAB_HOTE_MARQUE" >>"$HOSTS" 2>/dev/null ||
|
|
199
|
+
echo "devzone : gitlab : nom gitlab.localhost non posé dans $HOSTS (droits d'écriture insuffisants)" >&2
|
|
200
|
+
elif ! printf '127.0.0.1\tgitlab.localhost %s\n' "$GITLAB_HOTE_MARQUE" | sudo -n tee -a "$HOSTS" >/dev/null 2>&1; then
|
|
201
|
+
echo "devzone : gitlab : nom gitlab.localhost non posé dans $HOSTS (sudo -n indisponible ou refusé)" >&2
|
|
202
|
+
fi
|
|
203
|
+
return 0
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
gitlab_hote_retirer() {
|
|
207
|
+
# Aucune ligne repérée : rien (y compris fichier illisible)
|
|
208
|
+
if ! grep -q "$GITLAB_HOTE_MARQUE" "$HOSTS" 2>/dev/null; then
|
|
209
|
+
return 0
|
|
210
|
+
fi
|
|
211
|
+
local tmp
|
|
212
|
+
tmp="$(mktemp)"
|
|
213
|
+
grep -v "$GITLAB_HOTE_MARQUE" "$HOSTS" >"$tmp" 2>/dev/null || true
|
|
214
|
+
if [ -w "$HOSTS" ]; then
|
|
215
|
+
cp "$tmp" "$HOSTS" 2>/dev/null ||
|
|
216
|
+
echo "devzone : gitlab : ligne gitlab.localhost non retirée de $HOSTS (droits d'écriture insuffisants)" >&2
|
|
217
|
+
elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
|
|
218
|
+
echo "devzone : gitlab : ligne gitlab.localhost non retirée de $HOSTS (sudo -n indisponible ou refusé)" >&2
|
|
219
|
+
fi
|
|
220
|
+
rm -f "$tmp"
|
|
221
|
+
return 0
|
|
222
|
+
}
|
|
223
|
+
|
|
177
224
|
# ---- installer : installer GitLab dans kind ----
|
|
178
225
|
gitlab_installer() {
|
|
179
226
|
# RAM libre (refus < 8 Go) : seulement avant de créer le cluster ; une
|
|
@@ -195,9 +242,22 @@ gitlab_installer() {
|
|
|
195
242
|
|
|
196
243
|
# S'assurer que le cluster kind gitlab existe
|
|
197
244
|
echo "▶ Vérification/création du cluster kind gitlab…"
|
|
245
|
+
local cree=false
|
|
198
246
|
if ! kind get clusters 2>/dev/null | grep -qx 'gitlab'; then
|
|
199
247
|
echo "▶ Création du cluster kind gitlab…"
|
|
200
248
|
kind create cluster --name gitlab --config "$ICI/kind.yaml" --wait 120s
|
|
249
|
+
cree=true
|
|
250
|
+
fi
|
|
251
|
+
|
|
252
|
+
# SSH : un cluster gitlab préexistant (créé avant ce réglage) n'a pas le
|
|
253
|
+
# mapping nodePort 32022 → hostPort 2224 : le clone SSH (port 2224) est
|
|
254
|
+
# alors impossible. Avertissement seulement, l'installation continue.
|
|
255
|
+
if [ "$cree" = false ]; then
|
|
256
|
+
local sortie_ssh
|
|
257
|
+
sortie_ssh="$(docker port gitlab-control-plane 32022/tcp 2>/dev/null || true)"
|
|
258
|
+
if [ -z "$sortie_ssh" ]; then
|
|
259
|
+
echo "devzone : gitlab : clone SSH (port 2224) indisponible sur ce cluster, créé avant ce réglage ; pour l'activer : devzone desactiver gitlab puis devzone activer gitlab (données GitLab recréées)" >&2
|
|
260
|
+
fi
|
|
201
261
|
fi
|
|
202
262
|
|
|
203
263
|
# Ajouter le dépôt GitLab Helm (idempotent)
|
|
@@ -215,6 +275,10 @@ gitlab_installer() {
|
|
|
215
275
|
--timeout "${GITLAB_ATTENTE}s" \
|
|
216
276
|
--wait
|
|
217
277
|
|
|
278
|
+
# Nom gitlab.localhost dans /etc/hosts avant l'attente : ssh, glab et
|
|
279
|
+
# getent en ont besoin dès que le service monte (curl, lui, résout seul)
|
|
280
|
+
gitlab_hote_poser
|
|
281
|
+
|
|
218
282
|
# Attendre que GitLab soit prêt
|
|
219
283
|
gitlab_attendre_pret
|
|
220
284
|
|
|
@@ -269,6 +333,9 @@ gitlab_desinstaller() {
|
|
|
269
333
|
# Supprimer $RACINE/workspace/.gitlab/
|
|
270
334
|
rm -rf "$GITLAB_SECRETS_DIR"
|
|
271
335
|
|
|
336
|
+
# Nom gitlab.localhost retiré : la configuration suit le service
|
|
337
|
+
gitlab_hote_retirer
|
|
338
|
+
|
|
272
339
|
echo "✔ GitLab désinstallé."
|
|
273
340
|
}
|
|
274
341
|
|
|
@@ -302,11 +369,13 @@ gitlab_etat() {
|
|
|
302
369
|
|
|
303
370
|
# Gestion des sous-commandes
|
|
304
371
|
case "${1:-}" in
|
|
305
|
-
installer)
|
|
372
|
+
installer) gitlab_installer ;;
|
|
306
373
|
desinstaller) gitlab_desinstaller ;;
|
|
307
|
-
etat)
|
|
308
|
-
seed)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
374
|
+
etat) gitlab_etat ;;
|
|
375
|
+
seed) gitlab_seed ;;
|
|
376
|
+
hote-poser) gitlab_hote_poser ;;
|
|
377
|
+
hote-retirer) gitlab_hote_retirer ;;
|
|
378
|
+
*) echo "devzone : commande inconnue : ${1:-} (devzone gitlab --help)" >&2
|
|
379
|
+
exit 1
|
|
380
|
+
;;
|
|
312
381
|
esac
|
|
@@ -22,6 +22,8 @@ global:
|
|
|
22
22
|
install: false # prometheus non installé (top-level aussi)
|
|
23
23
|
registry:
|
|
24
24
|
enabled: false # registry non activé
|
|
25
|
+
shell:
|
|
26
|
+
port: 2224 # port SSH annoncé par GitLab pour le clone (ssh://git@gitlab.localhost:2224/...)
|
|
25
27
|
|
|
26
28
|
# cert-manager : désactivé
|
|
27
29
|
installCertmanager: false
|
|
@@ -47,6 +49,8 @@ nginx-ingress:
|
|
|
47
49
|
minAvailable: 0
|
|
48
50
|
service:
|
|
49
51
|
type: NodePort
|
|
52
|
+
nodePorts:
|
|
53
|
+
gitlab-shell: 32022 # nodePort fixe (plage 30000-32767) pour le clone SSH, port annoncé : 2224
|
|
50
54
|
|
|
51
55
|
# Réplicas à 1 et ressources réduites
|
|
52
56
|
gitlab:
|
package/package.json
CHANGED