devzone 0.37.0 → 0.39.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/.dockerignore +1 -1
- package/.devcontainer/argocd/argocd.sh +6 -7
- package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
- package/.devcontainer/argocd/gitops.sh +18 -0
- package/.devcontainer/argocd/services.sh +138 -0
- package/.devcontainer/catalogue/app.sh +58 -17
- package/.devcontainer/catalogue/mysql/installer.sh +31 -0
- package/.devcontainer/catalogue/mysql/mysql.sh +12 -0
- package/.devcontainer/devzone +17 -2
- package/.devcontainer/etat-json.sh +5 -1
- package/.devcontainer/password.sh +8 -0
- package/README.md +7 -1
- package/charts/devzone-argocd/Chart.lock +6 -0
- package/charts/devzone-argocd/Chart.yaml +13 -0
- package/charts/devzone-argocd/values.yaml +28 -0
- package/charts/devzone-mysql/Chart.yaml +6 -0
- package/charts/devzone-mysql/templates/service.yaml +15 -0
- package/charts/devzone-mysql/templates/statefulset.yaml +55 -0
- package/charts/devzone-mysql/values.yaml +19 -0
- package/manage/devzone +83 -4
- package/manage/scripts/argocd-services-svc.sh +110 -0
- package/manage/scripts/argocd-services.sh +21 -85
- package/manage/scripts/argocd-workspace.sh +8 -6
- package/manage/scripts/ci-dns.sh +10 -10
- package/manage/scripts/desinstaller.sh +150 -136
- package/manage/scripts/docker.sh +26 -22
- package/manage/scripts/lancer.sh +103 -103
- package/manage/scripts/migrer-retour.sh +37 -34
- package/manage/scripts/migrer.sh +154 -138
- package/manage/scripts/ports-workspace.sh +87 -82
- package/manage/scripts/poste.sh +48 -49
- package/manage/scripts/services-workspace.sh +15 -10
- package/manage/scripts/versions.sh +88 -88
- package/manage/scripts/workspace-aliases.sh +47 -0
- package/manage/scripts/workspace-wait.sh +26 -23
- package/manage/workspace.sh +124 -111
- package/package.json +1 -1
- package/.devcontainer/argocd/values.yaml +0 -25
|
@@ -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 "▶
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
compte_helm "$(compte_ctx)" upgrade --install argocd
|
|
147
|
-
|
|
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
|
+
}
|
|
@@ -67,6 +67,24 @@ gitops_init() {
|
|
|
67
67
|
https://github.com/*/*) ;;
|
|
68
68
|
*) echo "✖ GitHub repository URL expected (https://github.com/<owner>/<name>.git): $repo" >&2; return 2 ;;
|
|
69
69
|
esac
|
|
70
|
+
slug="${repo#https://github.com/}"
|
|
71
|
+
slug="${slug%.git}"
|
|
72
|
+
if gh auth status >/dev/null 2>&1 && ! gh repo view "$slug" --json name >/dev/null 2>&1; then
|
|
73
|
+
# The designated GitHub repository does not exist yet: create it,
|
|
74
|
+
# then write the files of a creation
|
|
75
|
+
if ! gh repo create "$slug" --private --description "GitOps repository of devzone: the Applications Argo CD holds (workspace, services, projects)" >/dev/null; then
|
|
76
|
+
echo "✖ cannot create the GitOps repository $slug" >&2
|
|
77
|
+
return 1
|
|
78
|
+
fi
|
|
79
|
+
echo "✔ GitOps repository created: https://github.com/$slug (private)"
|
|
80
|
+
gitops_repo_note "$repo"
|
|
81
|
+
gitops_put_text README.md "# devzone-argocd
|
|
82
|
+
|
|
83
|
+
GitOps repository of devzone, written by the devzone commands (never by hand): the Argo CD of devzone follows the apps/ folder, one Application per file (the workspace, the services, the projects added with argocd app add). Removing a file removes the Application and its resources.
|
|
84
|
+
" "devzone: GitOps repository"
|
|
85
|
+
gitops_put_text apps/.gitkeep "" "devzone: apps folder"
|
|
86
|
+
return 0
|
|
87
|
+
fi
|
|
70
88
|
gitops_repo_note "$repo"
|
|
71
89
|
echo "✔ GitOps repository: $repo ($ARGOCD_CONF)"
|
|
72
90
|
return 0
|
|
@@ -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é,
|
|
39
|
-
# vers 127.0.0.1:<port> du
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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é,
|
|
85
|
-
#
|
|
86
|
-
#
|
|
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
|
package/.devcontainer/devzone
CHANGED
|
@@ -63,13 +63,21 @@ MODULES=(ia kubernetes gitlab postgres argocd mysql)
|
|
|
63
63
|
if [ -f "$ICI/command-aliases.sh" ]; then
|
|
64
64
|
. "$ICI/command-aliases.sh"
|
|
65
65
|
fi
|
|
66
|
+
# .argocd.conf of the instance: the GitOps repository designation (#539)
|
|
67
|
+
# shellcheck source=SCRIPTDIR/argocd/conf.sh
|
|
68
|
+
# shellcheck disable=SC1091
|
|
69
|
+
# shellcheck disable=SC2034 # read by conf.sh
|
|
70
|
+
if [ -f "$ICI/argocd/conf.sh" ]; then
|
|
71
|
+
ARGOCD_CONF="$RACINE/.argocd.conf"
|
|
72
|
+
. "$ICI/argocd/conf.sh"
|
|
73
|
+
fi
|
|
66
74
|
|
|
67
75
|
# Assistants IA, versions figées : mettre à jour ici, puis devzone appliquer
|
|
68
76
|
# (ou Rebuild Container). Une ligne par paquet, séparées par une ligne qui ne
|
|
69
77
|
# change pas : deux montées simultanées (workflow versions) se fusionnent sans
|
|
70
78
|
# conflit, git n'en signalant qu'entre lignes voisines modifiées.
|
|
71
79
|
# Claude Code
|
|
72
|
-
IA_CLAUDE=@anthropic-ai/claude-code@2.1.
|
|
80
|
+
IA_CLAUDE=@anthropic-ai/claude-code@2.1.325
|
|
73
81
|
# opencode
|
|
74
82
|
IA_OPENCODE=opencode-ai@1.19.5
|
|
75
83
|
IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
|
|
@@ -1189,7 +1197,7 @@ utiliser() {
|
|
|
1189
1197
|
# État complet : ✔ prêt, ✖ nécessaire, ○ facultatif, ⚠ à corriger ; chaque
|
|
1190
1198
|
# point à faire avec sa commande (affiché à chaque démarrage)
|
|
1191
1199
|
etat() {
|
|
1192
|
-
local nom email statut m retards chemin ports_etat relais_marque ctx_travail ctx_hote paquets_marque paquets_noms
|
|
1200
|
+
local nom email statut m retards chemin ports_etat relais_marque ctx_travail ctx_hote paquets_marque paquets_noms argocd_repo
|
|
1193
1201
|
echo "devzone : état (devzone pour le réafficher)"
|
|
1194
1202
|
ligne_version_disponible
|
|
1195
1203
|
nom="$(git config --get user.name || true)"
|
|
@@ -1258,6 +1266,13 @@ etat() {
|
|
|
1258
1266
|
printf ' ○ module %-10s facultatif, %s : devzone activer %s\n' "$m" "$(description "$m")" "$m"
|
|
1259
1267
|
fi
|
|
1260
1268
|
done
|
|
1269
|
+
# GitOps repository of the instance (#539): the designation of .argocd.conf
|
|
1270
|
+
argocd_repo="$(conf_get argocd repo)"
|
|
1271
|
+
if [ -n "$argocd_repo" ] && [ "$argocd_repo" != none ]; then
|
|
1272
|
+
printf ' ○ argocd GitOps repository: %s\n' "$argocd_repo"
|
|
1273
|
+
else
|
|
1274
|
+
printf ' ○ argocd no GitOps repository: devzone argocd init\n'
|
|
1275
|
+
fi
|
|
1261
1276
|
# Socket Docker de l'hôte (#432) : l'avertissement montre l'état réel,
|
|
1262
1277
|
# le socket monté (même variable que docker-relais.sh), pas l'option :
|
|
1263
1278
|
# le montage ne change qu'au make rebuild (faux rassurant en attendant)
|
|
@@ -28,7 +28,7 @@ etat_json() {
|
|
|
28
28
|
local id_nom="" id_email="" id_ok=false id_commande=""
|
|
29
29
|
local plat_nom plat_url="" github_json="null"
|
|
30
30
|
local outils_retards_json='[]' outils_commande=""
|
|
31
|
-
local modules_json='[]' m actif desc ef content etat_val echec_val commande_val s
|
|
31
|
+
local modules_json='[]' m actif desc ef content etat_val echec_val commande_val s argocd_repo=""
|
|
32
32
|
local docker_hote=false docker_hote_actif=false relais_source
|
|
33
33
|
local services_cluster="" services_distant=false
|
|
34
34
|
local travail_ctx="" travail_interne=false ctx_hote=""
|
|
@@ -255,6 +255,8 @@ etat_json() {
|
|
|
255
255
|
append_alerte cluster_interne "cluster de travail : $travail_ctx (cluster interne de devzone)" "devzone utiliser $ctx_hote"
|
|
256
256
|
fi
|
|
257
257
|
|
|
258
|
+
argocd_repo="$(conf_get argocd repo)"
|
|
259
|
+
|
|
258
260
|
jq -n \
|
|
259
261
|
--argjson schema 1 \
|
|
260
262
|
--arg dv "$dv_raw" \
|
|
@@ -269,6 +271,7 @@ etat_json() {
|
|
|
269
271
|
--argjson retards "$outils_retards_json" \
|
|
270
272
|
--arg outils_commande "$outils_commande" \
|
|
271
273
|
--argjson modules "$modules_json" \
|
|
274
|
+
--arg argocd_repo "$argocd_repo" \
|
|
272
275
|
--argjson docker_hote "$docker_hote" \
|
|
273
276
|
--argjson docker_hote_actif "$docker_hote_actif" \
|
|
274
277
|
--arg clusters_services "$clusters_services_raw" \
|
|
@@ -286,6 +289,7 @@ etat_json() {
|
|
|
286
289
|
devzone: { version: (if $dv=="" then null else $dv end), disponible: (if $dvp=="" then null else $dvp end) },
|
|
287
290
|
identite_git: { ok: $id_ok, nom: (if $id_nom=="" then null else $id_nom end), email: (if $id_email=="" then null else $id_email end), commande: (if $id_commande=="" then null else $id_commande end) },
|
|
288
291
|
plateforme: { nom: $plat_nom, url: (if $plat_url=="" then null else $plat_url end), github: $github },
|
|
292
|
+
argocd_repo: (if $argocd_repo == "" then null else $argocd_repo end),
|
|
289
293
|
outils: { retards: $retards, commande: (if $outils_commande=="" then null else $outils_commande end) },
|
|
290
294
|
modules: $modules,
|
|
291
295
|
docker_hote: $docker_hote,
|
|
@@ -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
|
@@ -63,6 +63,12 @@ cd mon-devzone
|
|
|
63
63
|
make shell
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
Avec un compte GitHub, l'option `--gitops <github|none|<url>>` renseigne le dépôt GitOps dès la création du dossier :
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx devzone mon-devzone --gitops github
|
|
70
|
+
```
|
|
71
|
+
|
|
66
72
|
Ou bien récupérer le code directement :
|
|
67
73
|
|
|
68
74
|
```bash
|
|
@@ -325,7 +331,7 @@ Spring Boot écoute sur `0.0.0.0` par défaut : ne fixe pas `server.address` à
|
|
|
325
331
|
make desinstaller
|
|
326
332
|
```
|
|
327
333
|
|
|
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
|
|
334
|
+
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
335
|
|
|
330
336
|
Avec la commande installée globalement (`npm install -g devzone`), tu peux aussi lancer, dans le dossier du devzone :
|
|
331
337
|
|
|
@@ -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
|