devzone 0.42.1 → 0.44.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-local.sh +45 -0
- package/.devcontainer/agent-workspace.sh +2 -2
- package/.devcontainer/agent.sh +10 -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 +211 -0
- package/.devcontainer/catalogue/app.sh +7 -8
- package/.devcontainer/catalogue/mysql/installer.sh +9 -8
- package/.devcontainer/catalogue/mysql/mysql.sh +2 -2
- package/.devcontainer/catalogue.sh +1 -1
- package/.devcontainer/chart-direct.sh +49 -0
- package/.devcontainer/devzone +22 -16
- package/.devcontainer/etat-json.sh +3 -3
- package/.devcontainer/gitlab/argocd.sh +54 -0
- package/.devcontainer/gitlab/chart.sh +39 -0
- package/.devcontainer/gitlab/gitlab.sh +11 -168
- package/.devcontainer/gitlab/installation.sh +25 -38
- package/.devcontainer/gitlab/seed.sh +204 -0
- package/.devcontainer/help.sh +2 -0
- package/.devcontainer/llm/llm.sh +250 -0
- package/.devcontainer/llm/opencode.sh +56 -0
- package/.devcontainer/llm/presets.sh +43 -0
- package/.devcontainer/postgres/postgres.sh +5 -3
- package/.devcontainer/services-admin.sh +19 -6
- package/.devcontainer/versions.env +1 -1
- package/README.md +57 -23
- 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-llm/Chart.yaml +6 -0
- package/charts/devzone-llm/templates/deployment.yaml +97 -0
- package/charts/devzone-llm/templates/pvc.yaml +19 -0
- package/charts/devzone-llm/templates/service.yaml +18 -0
- package/charts/devzone-llm/values.yaml +46 -0
- package/charts/devzone-mysql/values.yaml +3 -3
- package/charts/devzone-postgres/values.yaml +2 -2
- package/manage/devzone +1 -1
- package/manage/scripts/check-charts.sh +67 -19
- package/manage/scripts/check-utf8-vars.sh +67 -0
- package/manage/scripts/services-workspace.sh +16 -6
- 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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Helm-direct installation of a devzone service (#559, step 7): the chart
|
|
3
|
+
# charts/devzone-<svc> of the code tree is the only definition, installed with
|
|
4
|
+
# helm on the devzone context as the release <svc> in <ns>. Objects already
|
|
5
|
+
# there (kubectl apply of an earlier version, or left by Argo CD when its module
|
|
6
|
+
# went away) are adopted first: the annotations and the label helm requires, so
|
|
7
|
+
# that the release takes them over without recreating them.
|
|
8
|
+
# chart_install <svc> <ns> [key=value ...] adoption, then helm upgrade --install
|
|
9
|
+
# bash 3.2 (macOS).
|
|
10
|
+
|
|
11
|
+
# The charts are code: read from the code tree (this file is in .devcontainer/),
|
|
12
|
+
# whatever the devzone folder (RACINE, the state) is
|
|
13
|
+
CHART_CODE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
14
|
+
|
|
15
|
+
# Adopts the objects of the rendered chart that already exist in <ns>: helm
|
|
16
|
+
# refuses an object it does not own, so the release annotations and the
|
|
17
|
+
# managed-by label are written on them (no object is recreated)
|
|
18
|
+
chart_adopt() {
|
|
19
|
+
local svc="$1" ns="$2" rendu="$3" objets o
|
|
20
|
+
objets="$(kubectl --context devzone -n "$ns" get -f "$rendu" -o name --ignore-not-found 2>/dev/null || true)"
|
|
21
|
+
for o in $objets; do
|
|
22
|
+
kubectl --context devzone -n "$ns" annotate "$o" \
|
|
23
|
+
"meta.helm.sh/release-name=$svc" "meta.helm.sh/release-namespace=$ns" --overwrite >/dev/null
|
|
24
|
+
kubectl --context devzone -n "$ns" label "$o" app.kubernetes.io/managed-by=Helm --overwrite >/dev/null
|
|
25
|
+
done
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Installs or upgrades the release <svc> from charts/devzone-<svc>; the
|
|
29
|
+
# key=value arguments become --set options (image, port, memory, size, claim)
|
|
30
|
+
chart_install() {
|
|
31
|
+
local svc="$1" ns="$2" chart rendu arg
|
|
32
|
+
local -a sets
|
|
33
|
+
shift 2
|
|
34
|
+
chart="$CHART_CODE/charts/devzone-$svc"
|
|
35
|
+
if [ ! -f "$chart/Chart.yaml" ]; then
|
|
36
|
+
echo "✖ $svc : chart charts/devzone-$svc missing (manage/docs/reference.md#charts-de-devzone)" >&2
|
|
37
|
+
return 2
|
|
38
|
+
fi
|
|
39
|
+
sets=()
|
|
40
|
+
for arg in "$@"; do sets+=(--set "$arg"); done
|
|
41
|
+
rendu="$(mktemp)"
|
|
42
|
+
if ! helm template "$svc" "$chart" -n "$ns" ${sets[@]+"${sets[@]}"} >"$rendu"; then
|
|
43
|
+
rm -f "$rendu"
|
|
44
|
+
return 1
|
|
45
|
+
fi
|
|
46
|
+
chart_adopt "$svc" "$ns" "$rendu"
|
|
47
|
+
rm -f "$rendu"
|
|
48
|
+
helm --kube-context devzone upgrade --install "$svc" "$chart" -n "$ns" ${sets[@]+"${sets[@]}"} >/dev/null
|
|
49
|
+
}
|
package/.devcontainer/devzone
CHANGED
|
@@ -28,7 +28,7 @@ VERSIONS="$ICI/../manage/scripts/versions.sh"
|
|
|
28
28
|
RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
29
29
|
# État par défaut de l'instance ; DEVZONE_ETAT garde la priorité (tests, CI)
|
|
30
30
|
ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
31
|
-
MODULES=(ia kubernetes gitlab postgres argocd mysql)
|
|
31
|
+
MODULES=(ia kubernetes gitlab postgres argocd mysql llm)
|
|
32
32
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
33
33
|
# shellcheck disable=SC1091
|
|
34
34
|
. "$ICI/cluster.sh"
|
|
@@ -78,6 +78,7 @@ description() {
|
|
|
78
78
|
postgres) echo "PostgreSQL partagé, une base par projet" ;;
|
|
79
79
|
argocd) echo "Argo CD, interface de déploiement du cluster des services" ;;
|
|
80
80
|
mysql) echo "MySQL partagé, une base par projet" ;;
|
|
81
|
+
llm) echo "modèle de code local (llama.cpp) dans le cluster des services" ;;
|
|
81
82
|
esac
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -301,18 +302,17 @@ fichier_echec() {
|
|
|
301
302
|
echo "$ETAT-echec-$1"
|
|
302
303
|
}
|
|
303
304
|
|
|
304
|
-
# Services in the Kubernetes workspace pod (#528): gitlab, postgres and
|
|
305
|
-
# live in the cluster
|
|
306
|
-
#
|
|
307
|
-
#
|
|
308
|
-
# like the catalogue (#515), never the failure marker of an installer.
|
|
305
|
+
# Services in the Kubernetes workspace pod (#528): gitlab, postgres, argocd and
|
|
306
|
+
# llm live in the cluster, installed from the workstation (devzone workspace
|
|
307
|
+
# services). The pod has no kubeconfig and a limited account (#430): their
|
|
308
|
+
# presence is the cluster DNS (like #515), never an installer failure marker.
|
|
309
309
|
dans_pod() {
|
|
310
310
|
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ]
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
service_module() {
|
|
314
314
|
case "$1" in
|
|
315
|
-
gitlab | postgres | argocd) return 0 ;;
|
|
315
|
+
gitlab | postgres | argocd | llm) return 0 ;;
|
|
316
316
|
esac
|
|
317
317
|
return 1
|
|
318
318
|
}
|
|
@@ -323,6 +323,7 @@ service_dns() {
|
|
|
323
323
|
gitlab) echo "gitlab-webservice-default.devzone-gitlab${INSTANCE_SUFFIX}.svc" ;;
|
|
324
324
|
postgres) echo "postgres.devzone-postgres.svc" ;;
|
|
325
325
|
argocd) echo "argocd-server.devzone-argocd.svc" ;;
|
|
326
|
+
llm) echo "llm.devzone-llm.svc" ;;
|
|
326
327
|
esac
|
|
327
328
|
}
|
|
328
329
|
|
|
@@ -421,8 +422,10 @@ appliquer_ia() {
|
|
|
421
422
|
rm -f "$(fichier_echec ia)"
|
|
422
423
|
# Garde-fou repowarden : retiré à la désactivation (symétrique de
|
|
423
424
|
# l'activation). repowarden le fait lui-même s'il est présent ; sinon
|
|
424
|
-
# retrait par jq
|
|
425
|
-
#
|
|
425
|
+
# retrait par jq des seules entrées PreToolUse qui appellent le garde-fou,
|
|
426
|
+
# le reste de settings.json intact. Le garde-fou s'appelle « repowarden
|
|
427
|
+
# guard » depuis repowarden 4.17.3 ; « repowarden garde » est son ancien
|
|
428
|
+
# nom, toujours alias côté repowarden et reconnu ici.
|
|
426
429
|
if command -v repowarden >/dev/null 2>&1; then
|
|
427
430
|
repowarden agents retirer --global >/dev/null 2>&1 || true
|
|
428
431
|
elif [ -f "$HOME/.claude/settings.json" ]; then
|
|
@@ -432,10 +435,10 @@ appliquer_ia() {
|
|
|
432
435
|
.hooks.PreToolUse = [
|
|
433
436
|
.hooks.PreToolUse[] |
|
|
434
437
|
if (.hooks // null) != null then
|
|
435
|
-
.hooks = [ .hooks[] | select(((.command // "") | contains("repowarden garde")) | not) ] |
|
|
438
|
+
.hooks = [ .hooks[] | select(((.command // "") | (contains("repowarden garde") or contains("repowarden guard"))) | not) ] |
|
|
436
439
|
select((.hooks | length) > 0)
|
|
437
440
|
else
|
|
438
|
-
select(((.command // "") | contains("repowarden garde")) | not)
|
|
441
|
+
select(((.command // "") | (contains("repowarden garde") or contains("repowarden guard"))) | not)
|
|
439
442
|
end
|
|
440
443
|
] |
|
|
441
444
|
if (.hooks.PreToolUse | length) == 0 then del(.hooks.PreToolUse) else . end |
|
|
@@ -563,6 +566,7 @@ appliquer_postgres() {
|
|
|
563
566
|
fi
|
|
564
567
|
}
|
|
565
568
|
|
|
569
|
+
appliquer_llm() { bash "$ICI/llm/llm.sh" apply "$@"; }
|
|
566
570
|
# Argo CD (#411) : installé dans le cluster des services, accès par le relais
|
|
567
571
|
# 127.0.0.1:8443 ; un échec est marqué dans l'état et repris par devzone apply
|
|
568
572
|
appliquer_argocd() {
|
|
@@ -940,7 +944,7 @@ appliquer_repowarden() {
|
|
|
940
944
|
ligne="$(bash "$VERSIONS" --installees 2>/dev/null | awk '$1 == "repowarden"' || true)"
|
|
941
945
|
[ -n "$ligne" ] || return 0
|
|
942
946
|
read -r _ figee installee <<<"$ligne"
|
|
943
|
-
echo "devzone : installation de repowarden $figee…"
|
|
947
|
+
echo "devzone : installation de repowarden ${figee}…"
|
|
944
948
|
npm install -g "$paquet@$figee" >/dev/null
|
|
945
949
|
repowarden install --global --lang fr
|
|
946
950
|
echo "devzone : repowarden $installee → $figee"
|
|
@@ -1233,8 +1237,8 @@ etat() {
|
|
|
1233
1237
|
elif [ "$(valeur "$m")" = on ] && [ "$m" = gitlab ]; then
|
|
1234
1238
|
# GitLab actif : son état réel (prêt, runner, en échec)
|
|
1235
1239
|
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/gitlab/gitlab.sh" status)"
|
|
1236
|
-
elif [ "$(valeur "$m")" = on ] && [ "$m" = postgres ]; then
|
|
1237
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI
|
|
1240
|
+
elif [ "$(valeur "$m")" = on ] && { [ "$m" = postgres ] || [ "$m" = llm ]; }; then
|
|
1241
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/$m/$m.sh" status)"
|
|
1238
1242
|
elif [ "$(valeur "$m")" = on ] && [ "$m" = argocd ]; then
|
|
1239
1243
|
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/argocd/argocd.sh" status)"
|
|
1240
1244
|
elif [ "$(valeur "$m")" = on ] && [ "$m" = mysql ]; then
|
|
@@ -1373,6 +1377,8 @@ changer() {
|
|
|
1373
1377
|
confirmer_suppression "$m" "${@:3}" || return 0
|
|
1374
1378
|
fi
|
|
1375
1379
|
ecrire "$m" "$1"
|
|
1380
|
+
# Services held by Argo CD (#559): 0 done, 3 helm direct as before, else failed
|
|
1381
|
+
if DEVZONE_ETAT="$ETAT" bash "$ICI/argocd/services-hook.sh" "$m" "$1" "${@:3}"; then return 0; elif [ $? -ne 3 ]; then return 1; fi
|
|
1376
1382
|
"appliquer_$m" "$1" "${@:3}"
|
|
1377
1383
|
}
|
|
1378
1384
|
|
|
@@ -1416,7 +1422,7 @@ case "${1:-}" in
|
|
|
1416
1422
|
# gitlab, postgres, argocd: installed from the workstation in the
|
|
1417
1423
|
# Kubernetes workspace pod (#528), by their installer elsewhere
|
|
1418
1424
|
[ "$(valeur gitlab)" = off ] || appliquer_service gitlab
|
|
1419
|
-
[ "$(valeur
|
|
1425
|
+
for m in postgres llm; do [ "$(valeur "$m")" = off ] || appliquer_service "$m"; done
|
|
1420
1426
|
[ "$(valeur mysql)" = off ] || appliquer_mysql on
|
|
1421
1427
|
[ "$(valeur argocd)" = off ] || appliquer_service argocd
|
|
1422
1428
|
;;
|
|
@@ -1439,7 +1445,7 @@ case "${1:-}" in
|
|
|
1439
1445
|
utiliser) utiliser "${@:2}" ;;
|
|
1440
1446
|
clusters) DEVZONE_ETAT="$ETAT" bash "$ICI/clusters.sh" "${@:2}" ;;
|
|
1441
1447
|
cluster) changer_cluster "${@:2}" ;;
|
|
1442
|
-
postgres) DEVZONE_ETAT="$ETAT" bash "$ICI
|
|
1448
|
+
postgres | llm) DEVZONE_ETAT="$ETAT" bash "$ICI/$1/$1.sh" "${@:2}" ;;
|
|
1443
1449
|
mysql) DEVZONE_ETAT="$ETAT" bash "$ICI/catalogue/mysql/mysql.sh" "${@:2}" ;;
|
|
1444
1450
|
gitlab) DEVZONE_ETAT="$ETAT" bash "$ICI/gitlab/gitlab.sh" "${@:2}" ;;
|
|
1445
1451
|
catalogue) DEVZONE_ETAT="$ETAT" bash "$ICI/catalogue.sh" list ;;
|
|
@@ -132,12 +132,12 @@ etat_json() {
|
|
|
132
132
|
etat_val=""
|
|
133
133
|
ajouter_erreur modules "gitlab.sh status indisponible"
|
|
134
134
|
fi
|
|
135
|
-
elif [ "$m" = postgres ]; then
|
|
136
|
-
if s="$(bash "$ICI
|
|
135
|
+
elif [ "$m" = postgres ] || [ "$m" = llm ]; then
|
|
136
|
+
if s="$(bash "$ICI/$m/$m.sh" status 2>/dev/null)"; then
|
|
137
137
|
etat_val="$s"
|
|
138
138
|
else
|
|
139
139
|
etat_val=""
|
|
140
|
-
ajouter_erreur modules "
|
|
140
|
+
ajouter_erreur modules "$m.sh etat indisponible"
|
|
141
141
|
fi
|
|
142
142
|
elif [ "$m" = argocd ]; then
|
|
143
143
|
if s="$(bash "$ICI/argocd/argocd.sh" status 2>/dev/null)"; then
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# GitLab held by Argo CD (#538): with the module argocd on and installed, the
|
|
3
|
+
# installation is the Application devzone-gitlab on the wrapper chart
|
|
4
|
+
# charts/devzone-gitlab at the revision, instead of a helm pass (chart.sh).
|
|
5
|
+
# The Rails secret is re-applied before it (installation.sh), the seed runs
|
|
6
|
+
# once GitLab answers (seed.sh); the runner token goes to the Secret
|
|
7
|
+
# gitlab-runner-secret written by the seed, out of Git.
|
|
8
|
+
# Sourced by installation.sh (through gitlab.sh). bash 3.2 (macOS).
|
|
9
|
+
# gitlab_argocd_active module argocd on, chart present, revision
|
|
10
|
+
# gitlab_release_adopter helm release of before Argo CD: its release
|
|
11
|
+
# secrets removed, the objects are adopted
|
|
12
|
+
# gitlab_application_apply the Application devzone-gitlab
|
|
13
|
+
# gitlab_application_retirer the Application removed (namespace kept)
|
|
14
|
+
|
|
15
|
+
# The catalogue side of Argo CD (module on, chart, revision, Application)
|
|
16
|
+
# shellcheck source=SCRIPTDIR/../argocd/catalogue-argocd.sh
|
|
17
|
+
# shellcheck disable=SC1091
|
|
18
|
+
. "$ICI/../argocd/catalogue-argocd.sh"
|
|
19
|
+
|
|
20
|
+
# The module argocd is on, the namespace devzone-argocd is installed, the chart
|
|
21
|
+
# is in the repository and the revision is known: a development clone (version
|
|
22
|
+
# 0.0.0) keeps the helm-direct path, like the catalogue applications
|
|
23
|
+
gitlab_argocd_active() {
|
|
24
|
+
catalogue_argocd_active gitlab
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Argo CD takes over the objects of a helm release gitlab: the release secrets
|
|
28
|
+
# (sh.helm.release.v1.gitlab.*) go, so that helm no longer owns the objects
|
|
29
|
+
gitlab_release_adopter() {
|
|
30
|
+
kubectl --context devzone -n "$GITLAB_NS" delete secret \
|
|
31
|
+
-l owner=helm,name=gitlab --ignore-not-found >/dev/null 2>&1 || true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# The Application on charts/devzone-gitlab at the revision, in the namespace of
|
|
35
|
+
# the instance; the internal URL of the webservice follows that namespace
|
|
36
|
+
# (chart value not templated, passed as a helm parameter, as in chart.sh)
|
|
37
|
+
gitlab_application_apply() {
|
|
38
|
+
catalogue_argocd_load
|
|
39
|
+
chart_require gitlab || return $?
|
|
40
|
+
echo "▶ Application devzone-gitlab (Argo CD, charts/devzone-gitlab at $(argocd_revision))…"
|
|
41
|
+
gitops_apply_application devzone-gitlab service "$GITLAB_NS" \
|
|
42
|
+
"$DEVZONE_REPO_URL" "$(argocd_revision)" "charts/devzone-gitlab" \
|
|
43
|
+
"gitlab-runner.gitlabUrl=http://gitlab-webservice-default.$GITLAB_NS.svc:8181" || return 1
|
|
44
|
+
# Argo CD reads Git every 3 min: an immediate refresh of the Application
|
|
45
|
+
kubectl --context devzone -n devzone-argocd annotate application.argoproj.io \
|
|
46
|
+
devzone-gitlab argocd.argoproj.io/refresh=normal --overwrite >/dev/null 2>&1 || true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# The Application removed when GitLab is uninstalled: its resources leave with
|
|
50
|
+
# it; nothing to do when the module argocd is off or the Application is absent
|
|
51
|
+
gitlab_application_retirer() {
|
|
52
|
+
catalogue_argocd_application_exists gitlab || return 0
|
|
53
|
+
catalogue_argocd_delete gitlab
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# GitLab installed from the wrapper chart charts/devzone-gitlab (#538): the
|
|
3
|
+
# official gitlab 9.11.16 and gitlab-runner 0.88.2 are dependencies pinned in
|
|
4
|
+
# the chart, its values.yaml holds the values of the GitLab of devzone
|
|
5
|
+
# (under the gitlab and gitlab-runner keys). This file is the helm-direct
|
|
6
|
+
# path, the Application of Argo CD is argocd.sh. Sourced by installation.sh.
|
|
7
|
+
# gitlab_chart_depend repository HTTP gitlab added, dependency build
|
|
8
|
+
# gitlab_helm_pass <replicas> upgrade --install of the chart, runner replicas
|
|
9
|
+
# gitlab_runner_ancien_retirer release gitlab-runner of before #538 removed
|
|
10
|
+
# The runner is held back (replicas 0) on the first pass: its Secret
|
|
11
|
+
# gitlab-runner-secret is written by the seed, and a runner pod waiting for it
|
|
12
|
+
# would hold --wait until the timeout.
|
|
13
|
+
|
|
14
|
+
# The dependencies come from https://charts.gitlab.io (no OCI repository is
|
|
15
|
+
# published): the repository is added before the build, idempotent
|
|
16
|
+
gitlab_chart_depend() {
|
|
17
|
+
helm repo add gitlab https://charts.gitlab.io --force-update >/dev/null 2>&1 || true
|
|
18
|
+
helm dependency build "$RACINE/charts/devzone-gitlab" >/dev/null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# One helm pass of the wrapper chart. The webservice URL of the runner follows
|
|
22
|
+
# the namespace of the instance: the chart value is not templated, its default
|
|
23
|
+
# is the main instance, so it is passed here
|
|
24
|
+
gitlab_helm_pass() {
|
|
25
|
+
local replicas="$1"
|
|
26
|
+
compte_helm "$(compte_ctx)" upgrade --install gitlab "$RACINE/charts/devzone-gitlab" \
|
|
27
|
+
--namespace "$GITLAB_NS" \
|
|
28
|
+
--create-namespace \
|
|
29
|
+
--timeout "${GITLAB_ATTENTE}s" \
|
|
30
|
+
--wait \
|
|
31
|
+
--set "gitlab-runner.gitlabUrl=http://gitlab-webservice-default.$GITLAB_NS.svc:8181" \
|
|
32
|
+
--set "gitlab-runner.replicas=$replicas"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Release gitlab-runner of the installations before the wrapper chart (#396):
|
|
36
|
+
# its runner now comes with the chart, the release leaves without touching data
|
|
37
|
+
gitlab_runner_ancien_retirer() {
|
|
38
|
+
compte_helm "$(compte_ctx)" uninstall gitlab-runner --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
39
|
+
}
|
|
@@ -61,173 +61,16 @@ GITLAB_HOTE_MARQUE="# devzone:gitlab"
|
|
|
61
61
|
# shellcheck source=SCRIPTDIR/installation.sh
|
|
62
62
|
# shellcheck disable=SC1091
|
|
63
63
|
. "$ICI/installation.sh"
|
|
64
|
-
|
|
65
|
-
#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
fi
|
|
75
|
-
sleep 5
|
|
76
|
-
done
|
|
77
|
-
echo "devzone : timeout attente GitLab." >&2
|
|
78
|
-
return 1
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
# ---- seed : peupler GitLab de données de base ----
|
|
82
|
-
gitlab_seed() {
|
|
83
|
-
echo "▶ Seed de GitLab…"
|
|
84
|
-
|
|
85
|
-
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
86
|
-
|
|
87
|
-
# Mot de passe root lu dans le secret gitlab-gitlab-initial-root-password
|
|
88
|
-
local mot_de_passe
|
|
89
|
-
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)"
|
|
90
|
-
if [ -z "$mot_de_passe" ]; then
|
|
91
|
-
echo "devzone : seed GitLab : secret root (gitlab-gitlab-initial-root-password) introuvable, arrêt du seed." >&2
|
|
92
|
-
return 1
|
|
93
|
-
fi
|
|
94
|
-
printf '%s' "$mot_de_passe" > "$GITLAB_SECRETS_DIR/root-password"
|
|
95
|
-
chmod 600 "$GITLAB_SECRETS_DIR/root-password"
|
|
96
|
-
|
|
97
|
-
# Token d'accès root créé par kubectl exec dans le pod toolbox avec gitlab-rails runner
|
|
98
|
-
local toolbox_pod root_token
|
|
99
|
-
toolbox_pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
|
|
100
|
-
if [ -z "$toolbox_pod" ]; then
|
|
101
|
-
echo "devzone : seed GitLab : pod toolbox (label app=toolbox) introuvable, arrêt du seed." >&2
|
|
102
|
-
return 1
|
|
103
|
-
fi
|
|
104
|
-
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)"
|
|
105
|
-
if [ -z "$root_token" ]; then
|
|
106
|
-
echo "devzone : seed GitLab : création du jeton root (gitlab-rails runner) échouée, arrêt du seed." >&2
|
|
107
|
-
return 1
|
|
108
|
-
fi
|
|
109
|
-
printf '%s' "$root_token" > "$GITLAB_SECRETS_DIR/root-token"
|
|
110
|
-
chmod 600 "$GITLAB_SECRETS_DIR/root-token"
|
|
111
|
-
|
|
112
|
-
# Via l'API curl avec le token (jamais affiché en clair)
|
|
113
|
-
local token groupe_id
|
|
114
|
-
token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
115
|
-
|
|
116
|
-
# Groupe devzone (testé avant création)
|
|
117
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" >/dev/null 2>&1; then
|
|
118
|
-
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
|
|
119
|
-
echo "devzone : seed GitLab : création du groupe devzone échouée, arrêt du seed." >&2
|
|
120
|
-
return 1
|
|
121
|
-
fi
|
|
122
|
-
fi
|
|
123
|
-
groupe_id="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" | jq -r '.id // empty')"
|
|
124
|
-
if [ -z "$groupe_id" ]; then
|
|
125
|
-
echo "devzone : seed GitLab : lecture de l'identifiant numérique du groupe devzone échouée, arrêt du seed." >&2
|
|
126
|
-
return 1
|
|
127
|
-
fi
|
|
128
|
-
|
|
129
|
-
# Projet devzone/demo (testé avant création, namespace_id = ID numérique du groupe)
|
|
130
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo" >/dev/null 2>&1; then
|
|
131
|
-
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
|
|
132
|
-
echo "devzone : seed GitLab : création du projet devzone/demo échouée, arrêt du seed." >&2
|
|
133
|
-
return 1
|
|
134
|
-
fi
|
|
135
|
-
fi
|
|
136
|
-
|
|
137
|
-
# Utilisateur dev (testé avant création, mot de passe généré aléatoirement) :
|
|
138
|
-
# un dev-password existant n'est réutilisé que si l'utilisateur dev existe
|
|
139
|
-
# encore (vérifié via l'API) ; sinon il est recréé avec un utilisateur nouveau.
|
|
140
|
-
local users_json devpass
|
|
141
|
-
users_json="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/users?username=dev")"
|
|
142
|
-
if [ "$(jq length <<<"$users_json")" -eq 0 ]; then
|
|
143
|
-
devpass="$(openssl rand -base64 18 | tr -d '\n')"
|
|
144
|
-
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
|
|
145
|
-
echo "devzone : seed GitLab : création de l'utilisateur dev échouée, arrêt du seed." >&2
|
|
146
|
-
return 1
|
|
147
|
-
fi
|
|
148
|
-
printf '%s' "$devpass" > "$GITLAB_SECRETS_DIR/dev-password"
|
|
149
|
-
chmod 600 "$GITLAB_SECRETS_DIR/dev-password"
|
|
150
|
-
fi
|
|
151
|
-
|
|
152
|
-
# Token de runner : vérifié via POST /api/v4/runners/verify ; un jeton valide
|
|
153
|
-
# est gardé, un jeton refusé (403/404) est recréé, GitLab injoignable arrête le seed.
|
|
154
|
-
local rt_jeton rt_code rt_token
|
|
155
|
-
if [ -f "$GITLAB_SECRETS_DIR/runner-token" ]; then
|
|
156
|
-
rt_jeton="$(cat "$GITLAB_SECRETS_DIR/runner-token")"
|
|
157
|
-
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)"
|
|
158
|
-
if [ "$rt_code" = "200" ]; then
|
|
159
|
-
echo "✔ Jeton de runner valide : gardé."
|
|
160
|
-
elif [ "$rt_code" = "403" ] || [ "$rt_code" = "404" ]; then
|
|
161
|
-
echo "devzone : jeton de runner d'une installation précédente refusé : recréé."
|
|
162
|
-
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)"
|
|
163
|
-
if [ -z "$rt_token" ]; then
|
|
164
|
-
echo "devzone : seed GitLab : création du jeton de runner (POST /api/v4/user/runners) échouée, arrêt du seed." >&2
|
|
165
|
-
return 1
|
|
166
|
-
fi
|
|
167
|
-
printf '%s' "$rt_token" > "$GITLAB_SECRETS_DIR/runner-token"
|
|
168
|
-
chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
|
|
169
|
-
else
|
|
170
|
-
echo "devzone : seed GitLab : vérification du jeton de runner impossible (code ${rt_code}), arrêt du seed." >&2
|
|
171
|
-
return 1
|
|
172
|
-
fi
|
|
173
|
-
else
|
|
174
|
-
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)"
|
|
175
|
-
if [ -z "$rt_token" ]; then
|
|
176
|
-
echo "devzone : seed GitLab : création du jeton de runner (POST /api/v4/user/runners) échouée, arrêt du seed." >&2
|
|
177
|
-
return 1
|
|
178
|
-
fi
|
|
179
|
-
printf '%s' "$rt_token" > "$GITLAB_SECRETS_DIR/runner-token"
|
|
180
|
-
chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
|
|
181
|
-
fi
|
|
182
|
-
|
|
183
|
-
# 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)
|
|
184
|
-
# Le push utilise le jeton root (write_repository) : le jeton de runner ne peut pas pousser.
|
|
185
|
-
local push_token=""
|
|
186
|
-
push_token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
187
|
-
if [ -z "$push_token" ]; then
|
|
188
|
-
echo "devzone : seed GitLab : jeton root introuvable, arrêt du seed." >&2
|
|
189
|
-
return 1
|
|
190
|
-
fi
|
|
191
|
-
# Déjà poussé (installation relancée) : rien à refaire
|
|
192
|
-
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
|
|
193
|
-
echo "✔ Seed GitLab terminé (projet demo déjà poussé)."
|
|
194
|
-
regenerer_identifiants
|
|
195
|
-
return 0
|
|
196
|
-
fi
|
|
197
|
-
if [ -d "$ICI/demo" ]; then
|
|
198
|
-
local tmpdir
|
|
199
|
-
tmpdir="$(mktemp -d)"
|
|
200
|
-
cp -r "$ICI/demo/." "$tmpdir/"
|
|
201
|
-
if (
|
|
202
|
-
cd "$tmpdir"
|
|
203
|
-
# Dépôt jetable du script : les hooks git globaux (repowarden) n'ont
|
|
204
|
-
# rien à vérifier ici et refuseraient le commit
|
|
205
|
-
export GIT_CONFIG_PARAMETERS="'core.hooksPath=/dev/null'"
|
|
206
|
-
git init -q -b main
|
|
207
|
-
git add -A
|
|
208
|
-
git -c user.email=dev@gitlab.localhost -c user.name=dev commit -q -m "chore: projet de démonstration"
|
|
209
|
-
# gitlab.localhost n'est pas toujours résolu par git : adresse
|
|
210
|
-
# locale, et l'hôte attendu par l'ingress passé en en-tête
|
|
211
|
-
git remote add origin "http://oauth2:${push_token}@127.0.0.1:8929/devzone/demo.git"
|
|
212
|
-
git -c http.extraHeader="Host: gitlab.localhost" push -q -u origin main >/dev/null 2>&1
|
|
213
|
-
); then
|
|
214
|
-
# Vérifie le push : la branche main existe bien sur le projet
|
|
215
|
-
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
|
|
216
|
-
echo "devzone : seed GitLab : push du projet demo sur /devzone/demo.git réussi mais branche main absente, arrêt du seed." >&2
|
|
217
|
-
rm -rf "$tmpdir"
|
|
218
|
-
return 1
|
|
219
|
-
fi
|
|
220
|
-
else
|
|
221
|
-
echo "devzone : seed GitLab : push du projet demo sur /devzone/demo.git échoué, arrêt du seed." >&2
|
|
222
|
-
rm -rf "$tmpdir"
|
|
223
|
-
return 1
|
|
224
|
-
fi
|
|
225
|
-
rm -rf "$tmpdir"
|
|
226
|
-
fi
|
|
227
|
-
|
|
228
|
-
echo "✔ Seed GitLab terminé."
|
|
229
|
-
regenerer_identifiants
|
|
230
|
-
}
|
|
64
|
+
# Chart enveloppe (helm direct, chart.sh), Argo CD (argocd.sh), seed (seed.sh) (#538)
|
|
65
|
+
# shellcheck source=SCRIPTDIR/chart.sh
|
|
66
|
+
# shellcheck disable=SC1091
|
|
67
|
+
. "$ICI/chart.sh"
|
|
68
|
+
# shellcheck source=SCRIPTDIR/argocd.sh
|
|
69
|
+
# shellcheck disable=SC1091
|
|
70
|
+
. "$ICI/argocd.sh"
|
|
71
|
+
# shellcheck source=SCRIPTDIR/seed.sh
|
|
72
|
+
# shellcheck disable=SC1091
|
|
73
|
+
. "$ICI/seed.sh"
|
|
231
74
|
|
|
232
75
|
# ---- hote-poser / hote-retirer : gitlab.localhost dans /etc/hosts ----
|
|
233
76
|
# Pourquoi : ssh (clone ssh://git@gitlab.localhost:2224/…), glab et getent
|
|
@@ -325,7 +168,7 @@ case "${1:-}" in
|
|
|
325
168
|
migrate) shift; gitlab_migrer "$@" ;;
|
|
326
169
|
installe) gitlab_installe ;;
|
|
327
170
|
status) gitlab_etat ;;
|
|
328
|
-
seed)
|
|
171
|
+
seed) gitlab_seed_commande ;;
|
|
329
172
|
new-password) gitlab_nouveau_mdp "${@:2}" ;;
|
|
330
173
|
relay-start) gitlab_relais_lancer ;;
|
|
331
174
|
relay-stop) gitlab_relais_arreter ;;
|
|
@@ -3,7 +3,8 @@
|
|
|
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}"
|
|
@@ -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
|
|
|
@@ -160,8 +145,10 @@ gitlab_desinstaller() {
|
|
|
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
|