devzone 0.37.0 → 0.38.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.
Files changed (36) hide show
  1. package/.devcontainer/.dockerignore +1 -1
  2. package/.devcontainer/argocd/argocd.sh +6 -7
  3. package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
  4. package/.devcontainer/argocd/services.sh +138 -0
  5. package/.devcontainer/catalogue/app.sh +58 -17
  6. package/.devcontainer/catalogue/mysql/installer.sh +31 -0
  7. package/.devcontainer/catalogue/mysql/mysql.sh +12 -0
  8. package/.devcontainer/devzone +1 -1
  9. package/.devcontainer/password.sh +8 -0
  10. package/README.md +1 -1
  11. package/charts/devzone-argocd/Chart.lock +6 -0
  12. package/charts/devzone-argocd/Chart.yaml +13 -0
  13. package/charts/devzone-argocd/values.yaml +28 -0
  14. package/charts/devzone-mysql/Chart.yaml +6 -0
  15. package/charts/devzone-mysql/templates/service.yaml +15 -0
  16. package/charts/devzone-mysql/templates/statefulset.yaml +55 -0
  17. package/charts/devzone-mysql/values.yaml +19 -0
  18. package/manage/devzone +2 -1
  19. package/manage/scripts/argocd-services-svc.sh +110 -0
  20. package/manage/scripts/argocd-services.sh +21 -85
  21. package/manage/scripts/argocd-workspace.sh +8 -6
  22. package/manage/scripts/ci-dns.sh +10 -10
  23. package/manage/scripts/desinstaller.sh +137 -135
  24. package/manage/scripts/docker.sh +26 -22
  25. package/manage/scripts/lancer.sh +103 -103
  26. package/manage/scripts/migrer-retour.sh +37 -34
  27. package/manage/scripts/migrer.sh +154 -138
  28. package/manage/scripts/ports-workspace.sh +87 -82
  29. package/manage/scripts/poste.sh +48 -49
  30. package/manage/scripts/services-workspace.sh +15 -10
  31. package/manage/scripts/versions.sh +88 -88
  32. package/manage/scripts/workspace-aliases.sh +47 -0
  33. package/manage/scripts/workspace-wait.sh +26 -23
  34. package/manage/workspace.sh +124 -111
  35. package/package.json +1 -1
  36. package/.devcontainer/argocd/values.yaml +0 -25
@@ -1,5 +1,5 @@
1
1
  *.password
2
2
  *.env.local
3
3
  root.env
4
- sans-docker-hote/
4
+ without-host-docker/
5
5
  **/.password
@@ -139,15 +139,14 @@ installer() {
139
139
  echo "▶ Vérification de la mémoire allouable du cluster des services…"
140
140
  verifier_memoire || return 2
141
141
  preparer_namespace
142
- echo "▶ Ajout du dépôt Helm Argo…"
143
- helm repo add argo https://argoproj.github.io/argo-helm >/dev/null 2>&1 || true
144
- helm repo update >/dev/null 2>&1 || true
145
- echo "▶ Installation d'Argo CD $ARGOCD_VERSION dans $NS…"
146
- compte_helm "$(compte_ctx)" upgrade --install argocd argo/argo-cd \
147
- --version "$ARGOCD_VERSION" \
142
+ echo "▶ Installation d'Argo CD $ARGOCD_VERSION dans $NS (chart charts/devzone-argocd)…"
143
+ # Wrapper chart: the dependency argo-cd (pinned in Chart.yaml) is built
144
+ # first, then installed from the local chart (#538)
145
+ helm dependency build "$RACINE/charts/devzone-argocd" >/dev/null
146
+ compte_helm "$(compte_ctx)" upgrade --install argocd \
147
+ "$RACINE/charts/devzone-argocd" \
148
148
  --namespace "$NS" \
149
149
  --create-namespace \
150
- -f "$ICI/values.yaml" \
151
150
  --timeout "${ARGOCD_ATTENTE}s" \
152
151
  --wait
153
152
  enregistrer_admin
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env bash
2
+ # Argo CD for the catalogue applications in the container (#538): the module
3
+ # mysql and the catalogue install their application as the Application
4
+ # devzone-<app> (services.sh) when the module argocd is active, instead of
5
+ # the manifest applied by hand. The namespace (compte_namespace of
6
+ # cluster.sh, isolement.sh) and the secret <app>-admin (mirror
7
+ # workspace/.<app>/) stay created apart, out of Git; Argo CD holds the chart
8
+ # charts/devzone-<app> of the devzone repository at the revision.
9
+ # catalogue_argocd_active <app> on, installed, chart and revision
10
+ # catalogue_argocd_apply <app> <ns> ... the Application, then refreshed
11
+ # catalogue_argocd_application_exists <app>
12
+ # catalogue_argocd_delete <app> Application deleted (namespace
13
+ # and volumes stay)
14
+ # argocd_revision: DEVZONE_ARGOCD_REVISION, else v<package.json version>;
15
+ # empty on a development clone (0.0.0): the local chart is not in Git, the
16
+ # manifest path keeps serving. The includer defines RACINE and ETAT (the
17
+ # devzone modules file), and the secret hook services_secret_<app> (mirrored,
18
+ # never printed). bash 3.2 (macOS).
19
+
20
+ CATALOGUE_ARGOCD_WIRED="${CATALOGUE_ARGOCD_WIRED:-}"
21
+
22
+ # Line argocd=on of .devzone.modules of the container
23
+ catalogue_argocd_module_on() {
24
+ grep -E '^argocd=' "${ETAT:-}" 2>/dev/null | tail -1 | cut -d= -f2- | grep -qx on
25
+ }
26
+
27
+ # Git revision for the Applications: DEVZONE_ARGOCD_REVISION, else the tag of
28
+ # the package version of the image; empty on a development clone
29
+ argocd_revision() {
30
+ local version
31
+ if [ -n "${DEVZONE_ARGOCD_REVISION:-}" ]; then
32
+ printf '%s' "$DEVZONE_ARGOCD_REVISION"
33
+ return 0
34
+ fi
35
+ version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$RACINE/package.json" | head -1)"
36
+ case "$version" in
37
+ '' | 0.0.0) ;;
38
+ *) printf 'v%s' "$version" ;;
39
+ esac
40
+ }
41
+
42
+ # Sources the shared pieces once: conf.sh and gitops.sh with the
43
+ # .argocd.conf of the devzone folder, services.sh with the hooks of the
44
+ # container (limited devzone context)
45
+ catalogue_argocd_load() {
46
+ [ -n "$CATALOGUE_ARGOCD_WIRED" ] && return 0
47
+ # shellcheck disable=SC2034 # read by apps.sh
48
+ APPS_CMD="devzone argocd app"
49
+ # shellcheck disable=SC2034 # read by apps.sh and services.sh
50
+ APPS_GENERATOR="$RACINE/.devcontainer/argocd/application.sh"
51
+ # shellcheck disable=SC2034 # read by gitops.sh
52
+ GITOPS_CMD="devzone argocd init"
53
+ # shellcheck disable=SC2034 # read by conf.sh and apps.sh
54
+ ARGOCD_CONF_DIR="$RACINE"
55
+ # shellcheck disable=SC2034
56
+ ARGOCD_CONF="${DEVZONE_ARGOCD_CONF:-$RACINE/.argocd.conf}"
57
+ # shellcheck source=SCRIPTDIR/conf.sh
58
+ # shellcheck disable=SC1091
59
+ . "$RACINE/.devcontainer/argocd/conf.sh"
60
+ # shellcheck source=SCRIPTDIR/gitops.sh
61
+ # shellcheck disable=SC1091
62
+ . "$RACINE/.devcontainer/argocd/gitops.sh"
63
+ # shellcheck source=SCRIPTDIR/services.sh
64
+ # shellcheck disable=SC1091
65
+ . "$RACINE/.devcontainer/argocd/services.sh"
66
+ # shellcheck disable=SC2034 # read by services.sh
67
+ DEVZONE_REPO_URL="${DEVZONE_REPO_URL:-https://github.com/SimBienvenueHoulBoumi/devzone.git}"
68
+ CATALOGUE_ARGOCD_WIRED=1
69
+ }
70
+
71
+ # The catalogue application <app> can be an Argo CD Application: the module
72
+ # argocd is on and installed, the chart exists in charts/, the revision is
73
+ # known (a development clone keeps the manifest path)
74
+ catalogue_argocd_active() {
75
+ local app="$1"
76
+ catalogue_argocd_module_on || return 1
77
+ [ -d "$RACINE/charts/devzone-$app" ] || return 1
78
+ compte_admin "$(compte_ctx)" get namespace devzone-argocd >/dev/null 2>&1 || return 1
79
+ catalogue_argocd_load
80
+ [ -n "$(argocd_revision)" ]
81
+ }
82
+
83
+ # Applies the Application devzone-<app> (kind service) with the chart
84
+ # charts/devzone-<app> at the revision; image, port, memory and size are the
85
+ # values of app.conf passed as helm parameters, <extra> holds the ones of the
86
+ # application itself (claim). In the GitOps repository when one is designated
87
+ # (.argocd.conf), applied directly otherwise (gitops.sh)
88
+ catalogue_argocd_apply() {
89
+ local app="$1" ns="$2" image="$3" port="$4" memory="$5" size="$6" params extra="${7:-}"
90
+ catalogue_argocd_load
91
+ params="image=$image port=$port memory=$memory size=$size"
92
+ [ -n "$extra" ] && params="$params $extra"
93
+ # shellcheck disable=SC2086
94
+ gitops_apply_application "devzone-$app" service "$ns" "$DEVZONE_REPO_URL" \
95
+ "$(argocd_revision)" "charts/devzone-$app" $params || return 1
96
+ # Argo CD reads Git every 3 min: an immediate refresh of the Application
97
+ kubectl --context devzone -n devzone-argocd annotate application.argoproj.io \
98
+ "devzone-$app" argocd.argoproj.io/refresh=normal --overwrite >/dev/null 2>&1 || true
99
+ }
100
+
101
+ # The Application devzone-<app> exists in devzone-argocd
102
+ catalogue_argocd_application_exists() {
103
+ catalogue_argocd_module_on || return 1
104
+ kubectl --context devzone -n devzone-argocd get application.argoproj.io "devzone-$1" >/dev/null 2>&1
105
+ }
106
+
107
+ # Deletes the Application devzone-<app>: its resources go with it, the
108
+ # namespace and the volumes stay (the explicit removal of the data keeps its
109
+ # own command); nothing to delete when the Application is absent
110
+ catalogue_argocd_delete() {
111
+ catalogue_argocd_application_exists "$1" || return 0
112
+ catalogue_argocd_load
113
+ gitops_delete_application "devzone-$1"
114
+ }
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env bash
2
+ # The services of devzone held by Argo CD (#538): postgres, mysql, gitlab,
3
+ # declared in the [services] section of .argocd.conf (conf.sh):
4
+ # [services]
5
+ # postgres = on
6
+ # mysql = off
7
+ # One Application devzone-<svc> per service on: the chart charts/devzone-<svc>
8
+ # of the devzone repository at the revision (gitops.sh). Before it, the
9
+ # namespace devzone-<svc> (labelled, isolated by a NetworkPolicy) and the
10
+ # secret of the service (superuser password generated or re-read, mirrored in
11
+ # workspace/.<svc>/ and .password) are created apart, out of Git.
12
+ # A service off: the Application leaves with its resources, the namespace and
13
+ # the volumes stay; the data removal stays the explicit command
14
+ # devzone workspace services disable <svc> --yes
15
+ # The lines <svc>=on|off of .devzone.modules are read in compatibility when
16
+ # the [services] section does not hold the service yet.
17
+ # services_reconcile every service applied or released
18
+ # services_state_of <svc> on | off | empty (not declared)
19
+ # services_note <svc> on|off writes the [services] section
20
+ # Sourced after conf.sh and gitops.sh by the workstation
21
+ # (manage/scripts/argocd-services.sh) and by the container (argocd.sh). The
22
+ # includer defines argocd_kubectl, APPS_GENERATOR, ARGOCD_CONF and
23
+ # ARGOCD_CONF_DIR (the devzone folder: relative paths there), DEVZONE_REPO_URL
24
+ # and argocd_revision, the secret hook of each service
25
+ # services_secret_<svc> secret created apart, mirrored, never printed
26
+ # and may extend SERVICES_LIST (default: postgres) and define the parameters
27
+ # hook services_chart_<svc> (helm parameters on stdout). bash 3.2 (macOS).
28
+
29
+ : "${SERVICES_LIST:=postgres}"
30
+
31
+ # Names of the Application and of the namespace of a service
32
+ services_app_of() { printf 'devzone-%s' "$1"; }
33
+ #
34
+ # Returns the namespace name devzone-<svc> for a given service name.
35
+ # Used by services_namespace_prepare and services_application_apply.
36
+ services_ns_of() { printf 'devzone-%s' "$1"; }
37
+
38
+ # State of a service: [services] of .argocd.conf first, then the line
39
+ # <svc>=on|off of .devzone.modules (compatibility, #538); empty when neither
40
+ # holds the service
41
+ services_state_of() {
42
+ local svc="$1" v line
43
+ v="$(conf_get services "$svc")"
44
+ case "$v" in on | off) printf '%s' "$v"; return 0 ;; esac
45
+ [ -f "$ARGOCD_CONF_DIR/.devzone.modules" ] || return 0
46
+ while IFS= read -r line || [ -n "$line" ]; do
47
+ line="$(conf_trim "$line")"
48
+ case "$line" in
49
+ "$svc=on" | "$svc=off") printf '%s' "${line#*=}"; return 0 ;;
50
+ esac
51
+ done <"$ARGOCD_CONF_DIR/.devzone.modules"
52
+ return 0
53
+ }
54
+
55
+ # The [services] section rewritten with the new state of <svc>, the keys of
56
+ # the other services kept
57
+ services_note() {
58
+ local svc="$1" state="$2" s k v
59
+ set --
60
+ while IFS="$(printf '\t')" read -r s k v; do
61
+ [ "$s" = services ] || continue
62
+ [ "$k" = "$svc" ] && continue
63
+ set -- "$@" "$k=$v"
64
+ done <<<"$(conf_entries)"
65
+ set -- "$@" "$svc=$state"
66
+ conf_set services "$@"
67
+ }
68
+
69
+ # Namespace devzone-<svc>: labelled and isolated like the other devzone-*
70
+ # namespaces (same rule as the helm-direct installers)
71
+ services_namespace_prepare() {
72
+ local ns
73
+ ns="$(services_ns_of "$1")"
74
+ argocd_kubectl create namespace "$ns" --dry-run=client -o yaml | argocd_kubectl apply -f - >/dev/null
75
+ argocd_kubectl label namespace "$ns" app.kubernetes.io/managed-by=devzone --overwrite >/dev/null
76
+ argocd_kubectl -n "$ns" apply -f - >/dev/null <<'EOF'
77
+ apiVersion: networking.k8s.io/v1
78
+ kind: NetworkPolicy
79
+ metadata:
80
+ name: devzone-meme-namespace
81
+ labels:
82
+ app.kubernetes.io/managed-by: devzone
83
+ spec:
84
+ podSelector: {}
85
+ ingress:
86
+ - from:
87
+ - podSelector: {}
88
+ EOF
89
+ }
90
+
91
+ # The Application devzone-<svc>: chart charts/devzone-<svc> of the devzone
92
+ # repository at the revision; the parameters hook adds helm parameters
93
+ services_application_apply() {
94
+ local svc="$1" extra=""
95
+ set -- "$(services_app_of "$svc")" service "$(services_ns_of "$svc")" \
96
+ "$DEVZONE_REPO_URL" "$(argocd_revision)" "charts/devzone-$svc"
97
+ if command -v "services_chart_$svc" >/dev/null 2>&1; then
98
+ # A failing hook (several volumes to choose from…) stops the apply
99
+ extra="$("services_chart_$svc")" || return $?
100
+ # shellcheck disable=SC2086
101
+ set -- "$@" $extra
102
+ fi
103
+ gitops_apply_application "$@"
104
+ }
105
+
106
+ # A service off: the Application leaves with its resources, the namespace and
107
+ # the volumes stay (--yes of the disable command removes the data)
108
+ services_application_delete() {
109
+ gitops_delete_application "$(services_app_of "$1")"
110
+ }
111
+
112
+ # Every service of the list applied or released: on → namespace, secret and
113
+ # Application; off → Application removed (namespace and volumes kept); not
114
+ # declared: untouched. One failing service does not stop the others
115
+ services_reconcile() {
116
+ local svc state code=0
117
+ for svc in $SERVICES_LIST; do
118
+ state="$(services_state_of "$svc")"
119
+ case "$state" in
120
+ on)
121
+ services_namespace_prepare "$svc" || code=1
122
+ if command -v "services_secret_$svc" >/dev/null 2>&1; then
123
+ "services_secret_$svc" || code=1
124
+ else
125
+ echo "✖ no secret hook for $svc (services_secret_$svc): the sync will fail" >&2
126
+ code=1
127
+ fi
128
+ services_application_apply "$svc" || code=1
129
+ echo "✔ Application $(services_app_of "$svc") declared (chart charts/devzone-$svc)"
130
+ ;;
131
+ off)
132
+ services_application_delete "$svc" || code=1
133
+ echo "✔ Application $(services_app_of "$svc") removed (namespace and volumes kept)"
134
+ ;;
135
+ esac
136
+ done
137
+ return "$code"
138
+ }
@@ -1,8 +1,35 @@
1
1
  #!/usr/bin/env bash
2
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.
3
6
 
4
7
  ATTENTE="${DEVZONE_CATALOGUE_ATTENTE:-300}"
5
8
 
9
+ # shellcheck source=SCRIPTDIR/argocd/catalogue-argocd.sh
10
+ # shellcheck disable=SC1091
11
+ . "$ICI/argocd/catalogue-argocd.sh"
12
+
13
+ # Attente du StatefulSet prêt : une seule commande rollout sur la voie
14
+ # manifeste, sondée sur la voie Argo CD (la synchronisation est en tâche de
15
+ # fond)
16
+ app_attendre() {
17
+ local app="$1" ns="$2" argo="$3" fin=$((SECONDS + ATTENTE))
18
+ if [ "$argo" = 1 ]; then
19
+ while [ "$SECONDS" -lt "$fin" ]; do
20
+ kubectl --context devzone -n "$ns" rollout status "statefulset/$app" --timeout=10s >/dev/null 2>&1 && return 0
21
+ sleep 5
22
+ done
23
+ echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
24
+ return 1
25
+ fi
26
+ if ! kubectl --context devzone -n "$ns" rollout status "statefulset/$app" \
27
+ --timeout="${ATTENTE}s" >/dev/null; then
28
+ echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
29
+ return 1
30
+ fi
31
+ }
32
+
6
33
  # Secret de l'application : mot de passe généré une fois, miroir local
7
34
  # (workspace/.$app/admin-password, 600, jamais affiché). Reprise : le mot de
8
35
  # passe déjà là (secret cluster ou root.env) est conservé, jamais régénéré.
@@ -35,10 +62,11 @@ regenerer_identifiants() {
35
62
  }
36
63
 
37
64
  # Installe une application : contexte devzone posé (#396), namespace créé et
38
- # isolé (#396), secret généré, manifeste appliqué, attente prête, relais lancé
39
- # vers 127.0.0.1:<port> du conteneur ; rend non nul en échec
65
+ # isolé (#396), secret généré, puis Application Argo CD (module argocd actif,
66
+ # #538) ou manifeste, attente prête, relais lancé vers 127.0.0.1:<port> du
67
+ # conteneur ; rend non nul en échec
40
68
  app_installer() {
41
- local app="$1" ns port image CTX man
69
+ local app="$1" ns port image CTX man extra="" argo=0
42
70
  ns="$(app_ns "$app")"
43
71
  port="$(app_lire "$app" port)"
44
72
  image="$(app_lire "$app" image)"
@@ -63,27 +91,32 @@ app_installer() {
63
91
  # shellcheck disable=SC1091
64
92
  . "$(dossier_catalogue)/mysql/volume.sh"
65
93
  claim="$(mysql_claim_choisir "$ns")" || return 2
94
+ [ "$claim" = donnees ] || extra="claim=$claim"
66
95
  fi
67
- man="$(mktemp)"
68
- sed -e "s|__APP__|$app|g" -e "s|__NS__|$ns|g" -e "s|__IMAGE__|$image|g" \
69
- -e "s|__PORT__|$port|g" -e "s|__MEMOIRE__|$(app_lire "$app" memoire)|g" \
70
- -e "s|__TAILLE__|$(app_lire "$app" taille)|g" -e "s|__CLAIM__|$claim|g" \
71
- "$(dossier_catalogue)/$app/manifeste.yaml" >"$man" &&
72
- kubectl --context devzone -n "$ns" apply -f "$man" >/dev/null
73
- rm -f "$man"
74
- if ! kubectl --context devzone -n "$ns" rollout status "statefulset/$app" \
75
- --timeout="${ATTENTE}s" >/dev/null; then
76
- echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
77
- return 1
96
+ if catalogue_argocd_active "$app"; then
97
+ argo=1
98
+ echo "▶ Application $app par Argo CD (chart charts/devzone-$app)…"
99
+ catalogue_argocd_apply "$app" "$ns" "$image" "$port" \
100
+ "$(app_lire "$app" memoire)" "$(app_lire "$app" taille)" "$extra" || return 1
101
+ else
102
+ man="$(mktemp)"
103
+ sed -e "s|__APP__|$app|g" -e "s|__NS__|$ns|g" -e "s|__IMAGE__|$image|g" \
104
+ -e "s|__PORT__|$port|g" -e "s|__MEMOIRE__|$(app_lire "$app" memoire)|g" \
105
+ -e "s|__TAILLE__|$(app_lire "$app" taille)|g" -e "s|__CLAIM__|$claim|g" \
106
+ "$(dossier_catalogue)/$app/manifeste.yaml" >"$man" &&
107
+ kubectl --context devzone -n "$ns" apply -f "$man" >/dev/null
108
+ rm -f "$man"
78
109
  fi
110
+ app_attendre "$app" "$ns" "$argo" || return 1
79
111
  relais_lancer "$app" "$CTX" "$ns" "svc/$app" "$port:$port"
80
112
  echo "✔ $app prêt : 127.0.0.1:$port dans le conteneur"
81
113
  regenerer_identifiants
82
114
  }
83
115
 
84
- # Désinstalle une application : relais coupé, manifeste retiré, marque oubliée ;
85
- # le volume (PVC) et les données restent (#441) : la suppression des données est
86
- # confirmée à part (devzone mysql supprimer-donnees)
116
+ # Désinstalle une application : relais coupé, Application Argo CD retirée
117
+ # (module argocd actif, #538) ou manifeste, marque oubliée ; le volume (PVC)
118
+ # et les données restent (#441) : la suppression des données est confirmée à
119
+ # part (devzone mysql supprimer-donnees)
87
120
  app_desinstaller() {
88
121
  local app="$1" ns claim pvc CTX
89
122
  ns="$(app_ns "$app")"
@@ -97,6 +130,14 @@ app_desinstaller() {
97
130
  fi
98
131
  claim="$(kubectl --context devzone -n "$ns" get statefulset "$app" \
99
132
  -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
133
+ if catalogue_argocd_application_exists "$app"; then
134
+ catalogue_argocd_delete "$app" >/dev/null 2>&1 || true
135
+ kubectl --context devzone -n "$ns" delete "secret/$app-admin" >/dev/null 2>&1 || true
136
+ pvc="${claim:-donnees}-$app-0"
137
+ echo "✔ $app retiré : Application supprimée ; volume $pvc et bases gardés : devzone $app volume"
138
+ regenerer_identifiants
139
+ return 0
140
+ fi
100
141
  kubectl --context devzone -n "$ns" delete "statefulset/$app" "service/$app" \
101
142
  "secret/$app-admin" >/dev/null 2>&1 || true
102
143
  pvc="${claim:-donnees}-$app-0"
@@ -21,6 +21,37 @@ mysql_secret() {
21
21
  fi
22
22
  }
23
23
 
24
+ # Attente du StatefulSet posé par Argo CD (#538) : la synchronisation est en
25
+ # tâche de fond, le rollout est sondé jusqu'à MYSQL_ATTENTE
26
+ mysql_attendre() {
27
+ local fin=$((SECONDS + MYSQL_ATTENTE))
28
+ while [ "$SECONDS" -lt "$fin" ]; do
29
+ if k rollout status statefulset/mysql --timeout=10s >/dev/null 2>&1; then
30
+ return 0
31
+ fi
32
+ sleep 5
33
+ done
34
+ echo "devzone : catalogue mysql : pas prêt après ${MYSQL_ATTENTE}s : kubectl --context $1 -n $NS describe pod mysql-0" >&2
35
+ return 1
36
+ }
37
+
38
+ # Installation MySQL par Argo CD (#538) : Application devzone-mysql (chart
39
+ # charts/devzone-mysql du dépôt devzone), namespace et secret créés à part ;
40
+ # le claim suit les volumes existants, comme le chemin manifeste
41
+ mysql_installer_argocd() {
42
+ local CTX="$1" claim extra=""
43
+ mysql_secret
44
+ claim="$(mysql_claim_choisir "$NS")" || return 2
45
+ [ "$claim" = donnees ] || extra="claim=$claim"
46
+ catalogue_argocd_apply mysql "$NS" "$MYSQL_IMAGE" "$MYSQL_PORT" \
47
+ "$MYSQL_MEMOIRE" "$MYSQL_TAILLE" "$extra" || return 1
48
+ mysql_attendre "$CTX" || return 1
49
+ mysql_secret
50
+ relais_lancer mysql "$CTX" "$NS" svc/mysql 3306:3306
51
+ echo "✔ MySQL prêt : 127.0.0.1:$MYSQL_PORT dans le conteneur"
52
+ regenerer_identifiants
53
+ }
54
+
24
55
  # Applique le manifeste avec le préfixe de claim choisi (#440)
25
56
  mysql_appliquer_manifeste() {
26
57
  local ns="$1" claim="$2"
@@ -19,6 +19,10 @@ ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
19
19
  # shellcheck source=SCRIPTDIR/installer.sh
20
20
  # shellcheck disable=SC1091
21
21
  . "$ICI/installer.sh"
22
+ # Le module argocd actif : MySQL installé par une Application (#538)
23
+ # shellcheck source=SCRIPTDIR/../../argocd/catalogue-argocd.sh
24
+ # shellcheck disable=SC1091
25
+ . "$ICI/../../argocd/catalogue-argocd.sh"
22
26
  NS=devzone-mysql
23
27
  SECRETS="$RACINE/workspace/.mysql"
24
28
  MYSQL_PORT="${MYSQL_PORT:-3306}"
@@ -28,6 +32,8 @@ MYSQL_TAILLE="${MYSQL_TAILLE:-5Gi}"
28
32
  MYSQL_ATTENTE="${MYSQL_ATTENTE:-300}"
29
33
  # Refus standard avec message et code 2
30
34
  refuse() { echo "devzone : catalogue mysql : $*" >&2; exit 2; }
35
+ # Secret mysql-admin du hook services.sh : le même que l'installation directe
36
+ services_secret_mysql() { mysql_secret; }
31
37
  # Régénère la vue .password (échec non bloquant)
32
38
  regenerer_identifiants() {
33
39
  password_regenerer ||
@@ -82,6 +88,10 @@ installer() {
82
88
  return 1
83
89
  fi
84
90
  echo "▶ MySQL sur le cluster $CTX (namespace $NS)…"
91
+ if catalogue_argocd_active mysql; then
92
+ mysql_installer_argocd "$CTX"
93
+ return
94
+ fi
85
95
  compte_namespace "$CTX" "$NS"
86
96
  namespace_isoler "$NS" >/dev/null
87
97
  if k get statefulset mysql >/dev/null 2>&1; then
@@ -123,6 +133,8 @@ supprimer_donnees() {
123
133
  [ -n "$CTX" ] || refuse "aucun cluster choisi : devzone activer mysql"
124
134
  installe || refuse "module inactif : devzone activer mysql"
125
135
  echo "▶ Suppression de MySQL et de ses volumes sur $CTX…"
136
+ # L'Application part d'abord (#538) : sinon Argo CD recrée le namespace
137
+ catalogue_argocd_delete mysql >/dev/null 2>&1 || true
126
138
  # RoleBinding retiré puis namespace supprimé par l'administrateur (#430)
127
139
  compte_retirer "$CTX" "$NS" >/dev/null 2>&1 || true
128
140
  compte_admin "$CTX" delete namespace "$NS" --wait=true >/dev/null
@@ -69,7 +69,7 @@ fi
69
69
  # change pas : deux montées simultanées (workflow versions) se fusionnent sans
70
70
  # conflit, git n'en signalant qu'entre lignes voisines modifiées.
71
71
  # Claude Code
72
- IA_CLAUDE=@anthropic-ai/claude-code@2.1.322
72
+ IA_CLAUDE=@anthropic-ai/claude-code@2.1.325
73
73
  # opencode
74
74
  IA_OPENCODE=opencode-ai@1.19.5
75
75
  IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
@@ -18,6 +18,7 @@ password_regenerer() (
18
18
  local cible="$PASSWORD_CIBLE" racine="$PASSWORD_RACINE"
19
19
  local gl="$racine/workspace/.gitlab" pg="$racine/workspace/.postgres"
20
20
  local ar="$racine/workspace/.argocd"
21
+ local my="$racine/workspace/.mysql"
21
22
  local tab entrees tmp fichier nom service adresse utilisateur mdp
22
23
  tab="$(printf '\t')"
23
24
  entrees="$(mktemp "$racine/.password.entrees.XXXXXX")" || return 1
@@ -41,6 +42,13 @@ password_regenerer() (
41
42
  printf 'postgres\t%s\tpostgres\t%s\n' "127.0.0.1:5432" "$mdp" >>"$entrees"
42
43
  fi
43
44
  fi
45
+ # MySQL root du catalogue (helm direct ou Argo CD, #538) : miroir du poste
46
+ if [ -s "$my/admin-password" ]; then
47
+ mdp="$(cat "$my/admin-password")"
48
+ if [ -n "$mdp" ]; then
49
+ printf 'mysql\t%s\troot\t%s\n' "127.0.0.1:3306" "$mdp" >>"$entrees"
50
+ fi
51
+ fi
44
52
  if [ -s "$ar/admin.env" ]; then
45
53
  utilisateur="$(sed -n 's/^ARGOCD_USER=//p' "$ar/admin.env" 2>/dev/null | tail -1 || true)"
46
54
  mdp="$(sed -n 's/^ARGOCD_PASSWORD=//p' "$ar/admin.env" 2>/dev/null | tail -1 || true)"
package/README.md CHANGED
@@ -325,7 +325,7 @@ Spring Boot écoute sur `0.0.0.0` par défaut : ne fixe pas `server.address` à
325
325
  make desinstaller
326
326
  ```
327
327
 
328
- Cette commande supprime le conteneur, l'image `vsc-devzone-…`, les volumes `devzone-*`, les events du Docker de l'hôte et les clusters kind créés sur l'hôte, les namespaces `devzone-postgres` et les étiquettes `app.kubernetes.io/managed-by=devzone` sur les clusters de l'hôte, ainsi que les éventuels metrics-server installés par devzone. Les ressources sont filtrées par l'étiquette `devzone.instance` pour ne cibler que l'instance courante. Elle **ne touche jamais** à `workspace/` (tes projets). Pour garder tes connexions (GitHub, git, Claude Code, opencode et modules) : `make desinstaller GARDER=connexions`.
328
+ Cette commande supprime le conteneur, l'image `vsc-devzone-…`, les volumes `devzone-*`, les events du Docker de l'hôte et les clusters kind créés sur l'hôte, les namespaces `devzone-postgres` et les étiquettes `app.kubernetes.io/managed-by=devzone` sur les clusters de l'hôte, ainsi que les éventuels metrics-server installés par devzone. Les ressources sont filtrées par l'étiquette `devzone.instance` pour ne cibler que l'instance courante. Elle **ne touche jamais** à `workspace/` (tes projets). Pour garder tes connexions (GitHub, git, Claude Code, opencode et modules) : `make desinstaller KEEP=logins` (ancien `GARDER=connexions` accepté).
329
329
 
330
330
  Avec la commande installée globalement (`npm install -g devzone`), tu peux aussi lancer, dans le dossier du devzone :
331
331
 
@@ -0,0 +1,6 @@
1
+ dependencies:
2
+ - name: argo-cd
3
+ repository: oci://ghcr.io/argoproj/argo-helm
4
+ version: 10.14.0
5
+ digest: sha256:7d0625740caf57b26bbb56b2266f860e469111c09b9da38376a118b60b54a2a0
6
+ generated: "2026-11-14T00:24:00.563528835Z"
@@ -0,0 +1,13 @@
1
+ apiVersion: v2
2
+ name: devzone-argocd
3
+ description: Argo CD of devzone, minimal and pinned (#411, #538): a wrapper of the official chart argo-cd
4
+ type: application
5
+ version: 0.1.0
6
+ appVersion: "3.3.0"
7
+ dependencies:
8
+ # Version pinned (10.14.0): the Application and the helm-direct install both
9
+ # take this chart, and devzone-argocd manages itself once self-hosted (#538).
10
+ # Run `helm dependency build` before the installation.
11
+ - name: argo-cd
12
+ version: 10.14.0
13
+ repository: oci://ghcr.io/argoproj/argo-helm
@@ -0,0 +1,28 @@
1
+ # Values of the Argo CD of devzone (#411), once the content of
2
+ # .devcontainer/argocd/values.yaml, moved under the argo-cd key of the
3
+ # wrapper (#538). Argo CD minimal: one replica per component, without Dex nor
4
+ # notifications, server in ClusterIP (no Ingress, no LoadBalancer). The access
5
+ # goes through the kubectl port-forward relay of the container (8443:443).
6
+ argo-cd:
7
+ global:
8
+ domain: ""
9
+ # Aggregate ClusterRoles (#516): the Application resources join the edit role,
10
+ # so the limited devzone account (#430) manages the Applications of the
11
+ # projects in devzone-argocd (devzone argocd app ...)
12
+ createAggregateRoles: true
13
+ dex:
14
+ enabled: false
15
+ notifications:
16
+ enabled: false
17
+ server:
18
+ replicas: 1
19
+ service:
20
+ type: ClusterIP
21
+ ingress:
22
+ enabled: false
23
+ controller:
24
+ replicas: 1
25
+ repoServer:
26
+ replicas: 1
27
+ applicationSet:
28
+ replicas: 1
@@ -0,0 +1,6 @@
1
+ apiVersion: v2
2
+ name: devzone-mysql
3
+ description: Shared MySQL of devzone, one database per project (#414), deployed by Argo CD (#538)
4
+ type: application
5
+ version: 0.1.0
6
+ appVersion: "8.4"
@@ -0,0 +1,15 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: {{ .Values.name }}
5
+ namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app: {{ .Values.name }}
8
+ app.kubernetes.io/managed-by: devzone
9
+ spec:
10
+ selector:
11
+ app: {{ .Values.name }}
12
+ ports:
13
+ - name: {{ .Values.name }}
14
+ port: {{ .Values.port }}
15
+ targetPort: 3306
@@ -0,0 +1,55 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: {{ .Values.name }}
5
+ namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app: {{ .Values.name }}
8
+ app.kubernetes.io/managed-by: devzone
9
+ spec:
10
+ serviceName: {{ .Values.name }}
11
+ replicas: 1
12
+ selector:
13
+ matchLabels:
14
+ app: {{ .Values.name }}
15
+ template:
16
+ metadata:
17
+ labels:
18
+ app: {{ .Values.name }}
19
+ app.kubernetes.io/managed-by: devzone
20
+ spec:
21
+ containers:
22
+ - name: {{ .Values.name }}
23
+ # Pinned version: update it here (same major: data kept)
24
+ image: {{ .Values.image }}
25
+ env:
26
+ - name: MYSQL_ROOT_PASSWORD
27
+ valueFrom:
28
+ secretKeyRef:
29
+ name: {{ .Values.name }}-admin
30
+ key: password
31
+ ports:
32
+ - containerPort: 3306
33
+ name: {{ .Values.name }}
34
+ readinessProbe:
35
+ exec:
36
+ command: ["/bin/sh", "-c", "mysql -uroot -p\"$MYSQL_ROOT_PASSWORD\" -e 'SELECT 1'"]
37
+ initialDelaySeconds: 10
38
+ periodSeconds: 5
39
+ resources:
40
+ requests:
41
+ cpu: {{ .Values.resources.requests.cpu }}
42
+ memory: {{ .Values.memory }}
43
+ volumeMounts:
44
+ - name: {{ .Values.claim }}
45
+ mountPath: /var/lib/mysql
46
+ volumeClaimTemplates:
47
+ - metadata:
48
+ name: {{ .Values.claim }}
49
+ labels:
50
+ app.kubernetes.io/managed-by: devzone
51
+ spec:
52
+ accessModes: ["ReadWriteOnce"]
53
+ resources:
54
+ requests:
55
+ storage: {{ .Values.size }}