devzone 0.36.7 → 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.
- package/.devcontainer/.dockerignore +1 -1
- package/.devcontainer/argocd/application.sh +69 -0
- package/.devcontainer/argocd/apps.sh +262 -0
- package/.devcontainer/argocd/argocd.sh +52 -8
- package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
- package/.devcontainer/argocd/conf.sh +141 -0
- package/.devcontainer/argocd/gitops.sh +214 -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 +2 -1
- package/.devcontainer/password.sh +8 -0
- package/README.md +2 -2
- 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/charts/devzone-postgres/Chart.yaml +6 -0
- package/charts/devzone-postgres/templates/service.yaml +15 -0
- package/charts/devzone-postgres/templates/statefulset.yaml +56 -0
- package/charts/devzone-postgres/values.yaml +11 -0
- package/manage/devzone +4 -1
- package/manage/scripts/argocd-services-svc.sh +110 -0
- package/manage/scripts/argocd-services.sh +179 -0
- package/manage/scripts/argocd-workspace.sh +221 -0
- package/manage/scripts/ci-dns.sh +10 -10
- package/manage/scripts/desinstaller.sh +137 -135
- 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 +94 -82
- package/manage/scripts/poste.sh +48 -49
- package/manage/scripts/services-workspace.sh +22 -5
- package/manage/scripts/versions.sh +88 -88
- package/manage/scripts/workspace-aliases.sh +47 -0
- package/manage/scripts/workspace-wait.sh +27 -24
- package/manage/workspace.sh +134 -105
- package/package.json +1 -1
- package/.devcontainer/argocd/values.yaml +0 -21
|
@@ -1,74 +1,81 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Applications
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
2
|
+
# Applications and services of the Kubernetes workspace on workstation localhost (#401).
|
|
3
|
+
# Sourced by manage/workspace.sh (ports_* functions); run directly with "loop" or
|
|
4
|
+
# "round", it is the workstation watcher: only one, mkdir lock and pid in
|
|
5
|
+
# .devzone.ports-workspace/. It relays with kubectl port-forward, on 127.0.0.1
|
|
6
|
+
# only, TCP ports >= 1024 listening in the pod, and devzone services of active
|
|
7
|
+
# modules in .devzone.modules. Guard: never under bats without
|
|
8
8
|
# DEVZONE_PORTS_WORKSPACE_REEL=oui.
|
|
9
9
|
|
|
10
10
|
PW_POD="devzone-workspace-0"
|
|
11
11
|
PW_NS="devzone-workspace"
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
#
|
|
12
|
+
# Internal pod ports, never relayed: kubedock and buildkit.
|
|
13
|
+
PW_INTERNAL=" 2475 1234 "
|
|
14
|
+
# pgAdmin service port: read from the service, without it nothing is relayed.
|
|
15
15
|
PW_JSONPATH='jsonpath={.spec.ports[0].port}'
|
|
16
16
|
|
|
17
|
-
#
|
|
17
|
+
# Watcher state folder: lock, pid, relays, reported ports, log.
|
|
18
18
|
pw_dir() { printf '%s' "${DEVZONE_PORTS_WORKSPACE_DIR:-$PWD/.devzone.ports-workspace}"; }
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# kubectl context flag: devzone if it exists, otherwise current context.
|
|
21
21
|
pw_ctx() {
|
|
22
22
|
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
23
23
|
printf -- '--context devzone'
|
|
24
24
|
fi
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
# kubectl
|
|
27
|
+
# Watcher kubectl: devzone context if it exists, then given arguments.
|
|
28
28
|
pw_kubectl() {
|
|
29
29
|
# shellcheck disable=SC2046
|
|
30
30
|
kubectl $(pw_ctx) "$@"
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
#
|
|
34
|
-
|
|
33
|
+
# Guard: refuse under bats without DEVZONE_PORTS_WORKSPACE_REEL=oui (message if $1 empty).
|
|
34
|
+
pw_guard() {
|
|
35
35
|
if [ -n "${BATS_TEST_TMPDIR:-}" ] && [ "${DEVZONE_PORTS_WORKSPACE_REEL:-}" != oui ]; then
|
|
36
|
-
[ -n "${1:-}" ] || echo "✖
|
|
36
|
+
[ -n "${1:-}" ] || echo "✖ port watcher refused under bats (DEVZONE_PORTS_WORKSPACE_REEL=oui required)" >&2
|
|
37
37
|
return 2
|
|
38
38
|
fi
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
#
|
|
42
|
-
|
|
41
|
+
# Is process $1 alive?
|
|
42
|
+
pw_alive() { [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null; }
|
|
43
43
|
|
|
44
|
-
#
|
|
45
|
-
|
|
44
|
+
# TCP ports >= 1024 listening in the pod (ss -ltnH), excluding internal ports, one per line.
|
|
45
|
+
pw_pod_ports() {
|
|
46
46
|
local p
|
|
47
47
|
pw_kubectl --namespace "$PW_NS" exec "$PW_POD" -c workspace -- ss -ltnH 2>/dev/null |
|
|
48
48
|
awk '{n=split($4,a,":"); print a[n]}' | sort -un | while read -r p; do
|
|
49
49
|
case "$p" in '' | *[!0-9]*) continue ;; esac
|
|
50
50
|
[ "$p" -ge 1024 ] || continue
|
|
51
|
-
case "$
|
|
51
|
+
case "$PW_INTERNAL" in *" $p "*) continue ;; esac
|
|
52
52
|
echo "$p"
|
|
53
53
|
done
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
56
|
+
# devzone services to relay, one "port|namespace|target[|remote port]" line per
|
|
57
|
+
# active module service: postgres (5432) and pgAdmin if present in namespace,
|
|
58
|
+
# mysql (3306), and the Argo CD UI (8443 → 443) when present (#516).
|
|
58
59
|
pw_services() {
|
|
60
|
+
local port
|
|
59
61
|
if grep -qxE 'postgres=(on|true|oui)' .devzone.modules 2>/dev/null; then
|
|
60
62
|
echo "5432|devzone-postgres|svc/postgres"
|
|
61
|
-
local port
|
|
62
63
|
port="$(pw_kubectl --namespace devzone-postgres get svc pgadmin -o "$PW_JSONPATH" 2>/dev/null || true)"
|
|
63
64
|
case "$port" in '' | *[!0-9]*) ;; *) echo "$port|devzone-postgres|svc/pgadmin" ;; esac
|
|
64
65
|
fi
|
|
65
66
|
if grep -qxE 'mysql=(on|true|oui)' .devzone.modules 2>/dev/null; then
|
|
66
67
|
echo "3306|devzone-mysql|svc/mysql"
|
|
67
68
|
fi
|
|
69
|
+
# Argo CD UI: https port of svc/argocd-server on 127.0.0.1:8443, unless argocd=off
|
|
70
|
+
if ! grep -qx 'argocd=off' .devzone.modules 2>/dev/null; then
|
|
71
|
+
port="$(pw_kubectl --namespace devzone-argocd get svc argocd-server \
|
|
72
|
+
-o 'jsonpath={.spec.ports[?(@.name=="https")].port}' 2>/dev/null || true)"
|
|
73
|
+
case "$port" in '' | *[!0-9]*) ;; *) echo "${DEVZONE_ARGOCD_PORT:-8443}|devzone-argocd|svc/argocd-server|$port" ;; esac
|
|
74
|
+
fi
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
#
|
|
71
|
-
|
|
77
|
+
# Is port $1 already in use on the workstation? (lsof, otherwise nc -z)
|
|
78
|
+
pw_taken() {
|
|
72
79
|
if command -v lsof >/dev/null 2>&1; then
|
|
73
80
|
lsof -nP -iTCP:"$1" -sTCP:LISTEN >/dev/null 2>&1
|
|
74
81
|
else
|
|
@@ -76,138 +83,143 @@ pw_pris() {
|
|
|
76
83
|
fi
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
|
|
82
|
-
local port="$1" ns="$2"
|
|
86
|
+
# Starts relay of port $1 to port $4 (default: $1) of target $3 in namespace $2,
|
|
87
|
+
# unless already alive; port taken on workstation: only one warning line per port.
|
|
88
|
+
pw_relay() {
|
|
89
|
+
local port="$1" ns="$2" target="$3" remote="${4:-$1}" d pid
|
|
83
90
|
d="$(pw_dir)"
|
|
84
91
|
pid="$(cat "$d/relais/$port" 2>/dev/null || true)"
|
|
85
|
-
|
|
86
|
-
if
|
|
87
|
-
[ -e "$d/pris/$port" ] || { : >"$d/pris/$port"; echo "⚠ port $port
|
|
92
|
+
pw_alive "$pid" && return 0
|
|
93
|
+
if pw_taken "$port"; then
|
|
94
|
+
[ -e "$d/pris/$port" ] || { : >"$d/pris/$port"; echo "⚠ port $port already in use on the workstation, not relayed"; }
|
|
88
95
|
return 0
|
|
89
96
|
fi
|
|
90
97
|
# shellcheck disable=SC2046
|
|
91
|
-
kubectl $(pw_ctx) --namespace "$ns" port-forward --address 127.0.0.1 "$
|
|
98
|
+
kubectl $(pw_ctx) --namespace "$ns" port-forward --address 127.0.0.1 "$target" "$port:$remote" </dev/null >/dev/null 2>&1 &
|
|
92
99
|
echo $! >"$d/relais/$port"
|
|
93
100
|
rm -f "$d/pris/$port"
|
|
94
|
-
echo "→ port $port
|
|
101
|
+
echo "→ port $port relayed on 127.0.0.1"
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
#
|
|
98
|
-
|
|
104
|
+
# Stops relay of port $1 and forgets its warning.
|
|
105
|
+
pw_remove() {
|
|
99
106
|
local d pid
|
|
100
107
|
d="$(pw_dir)"
|
|
101
108
|
pid="$(cat "$d/relais/$1" 2>/dev/null || true)"
|
|
102
|
-
if
|
|
109
|
+
if pw_alive "$pid"; then kill "$pid" 2>/dev/null || true; fi
|
|
103
110
|
rm -f "$d/relais/$1" "$d/pris/$1"
|
|
104
111
|
}
|
|
105
112
|
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
local d
|
|
113
|
+
# One watcher round: relay new ports, remove those that disappeared.
|
|
114
|
+
pw_round() {
|
|
115
|
+
local d wanted="" p ns target remote l f
|
|
109
116
|
d="$(pw_dir)"
|
|
110
117
|
mkdir -p "$d/relais" "$d/pris"
|
|
111
|
-
while IFS='|' read -r p ns
|
|
118
|
+
while IFS='|' read -r p ns target remote; do
|
|
112
119
|
[ -n "$p" ] || continue
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
wanted="$wanted $p "
|
|
121
|
+
pw_relay "$p" "$ns" "$target" "${remote:-$p}"
|
|
115
122
|
done <<<"$(pw_services)"
|
|
116
|
-
for p in $(
|
|
117
|
-
case "$
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
for p in $(pw_pod_ports); do
|
|
124
|
+
case "$wanted" in *" $p "*) continue ;; esac
|
|
125
|
+
wanted="$wanted $p "
|
|
126
|
+
pw_relay "$p" "$PW_NS" "pod/$PW_POD"
|
|
120
127
|
done
|
|
121
128
|
for f in "$d"/relais/* "$d"/pris/*; do
|
|
122
129
|
[ -e "$f" ] || continue
|
|
123
130
|
l="$(basename "$f")"
|
|
124
|
-
case "$
|
|
131
|
+
case "$wanted" in *" $l "*) ;; *) pw_remove "$l" ;; esac
|
|
125
132
|
done
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
#
|
|
129
|
-
|
|
135
|
+
# Removes all relays from the state folder.
|
|
136
|
+
pw_remove_all() {
|
|
130
137
|
local f
|
|
131
138
|
for f in "$(pw_dir)"/relais/*; do
|
|
132
|
-
if [ -e "$f" ]; then
|
|
139
|
+
if [ -e "$f" ]; then pw_remove "$(basename "$f")"; fi
|
|
133
140
|
done
|
|
134
141
|
}
|
|
135
142
|
|
|
136
|
-
#
|
|
137
|
-
|
|
143
|
+
# Watcher loop: one round every 3 s; on stop, removes its relays and lock.
|
|
144
|
+
pw_loop() {
|
|
138
145
|
local d
|
|
139
146
|
d="$(pw_dir)"
|
|
140
|
-
trap '
|
|
147
|
+
trap 'pw_remove_all; rm -rf "$d/verrou" "$d/pid"; exit 0' TERM INT
|
|
141
148
|
while :; do
|
|
142
|
-
|
|
149
|
+
pw_round || true
|
|
143
150
|
sleep "${DEVZONE_PORTS_WORKSPACE_PAS:-3}" &
|
|
144
151
|
wait $!
|
|
145
152
|
done
|
|
146
153
|
}
|
|
147
154
|
|
|
148
|
-
#
|
|
155
|
+
# Starts the watcher, only one: mkdir lock, pid recorded; $1=silence: no guard message.
|
|
149
156
|
# shellcheck disable=SC2120
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
ports_start() {
|
|
158
|
+
pw_guard "${1:-}" || return 0
|
|
152
159
|
local d pid
|
|
153
160
|
d="$(pw_dir)"
|
|
154
161
|
mkdir -p "$d"
|
|
155
162
|
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
156
|
-
if
|
|
157
|
-
echo "
|
|
163
|
+
if pw_alive "$pid"; then
|
|
164
|
+
echo "Workspace ports: watcher already running (pid $pid)"
|
|
158
165
|
return 0
|
|
159
166
|
fi
|
|
160
167
|
rm -rf "$d/verrou"
|
|
161
168
|
mkdir "$d/verrou" 2>/dev/null || return 0
|
|
162
|
-
nohup bash "${BASH_SOURCE[0]}"
|
|
169
|
+
nohup bash "${BASH_SOURCE[0]}" loop >>"$d/journal.log" 2>&1 &
|
|
163
170
|
echo $! >"$d/pid"
|
|
164
171
|
disown 2>/dev/null || true
|
|
165
|
-
echo "
|
|
172
|
+
echo "Workspace ports: watcher started, log $d/journal.log"
|
|
166
173
|
}
|
|
167
174
|
|
|
168
|
-
#
|
|
169
|
-
|
|
175
|
+
# Stops the watcher and all its port-forwards; without watcher, removes leftovers.
|
|
176
|
+
ports_stop() {
|
|
170
177
|
local d pid
|
|
171
178
|
d="$(pw_dir)"
|
|
172
179
|
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
173
|
-
if
|
|
180
|
+
if pw_alive "$pid"; then
|
|
174
181
|
kill "$pid" 2>/dev/null || true
|
|
175
|
-
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
|
182
|
+
for _ in 1 2 3 4 5 6 7 8 9 10; do pw_alive "$pid" || break; sleep 0.2; done
|
|
176
183
|
fi
|
|
177
|
-
|
|
184
|
+
pw_remove_all
|
|
178
185
|
rm -rf "$d/verrou" "$d/pid"
|
|
179
186
|
}
|
|
180
187
|
|
|
181
|
-
#
|
|
182
|
-
|
|
188
|
+
# Shows status: watcher, relayed ports, reported taken ports.
|
|
189
|
+
ports_status() {
|
|
183
190
|
local d pid f
|
|
184
191
|
d="$(pw_dir)"
|
|
185
192
|
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
186
|
-
if
|
|
193
|
+
if pw_alive "$pid"; then echo "Port watcher: running (pid $pid)"; else echo "Port watcher: stopped"; fi
|
|
187
194
|
for f in "$d"/relais/*; do
|
|
188
|
-
if [ -e "$f" ] &&
|
|
195
|
+
if [ -e "$f" ] && pw_alive "$(cat "$f")"; then echo " 127.0.0.1:$(basename "$f") relayed"; fi
|
|
189
196
|
done
|
|
190
197
|
for f in "$d"/pris/*; do
|
|
191
|
-
if [ -e "$f" ]; then echo " ⚠ port $(basename "$f")
|
|
198
|
+
if [ -e "$f" ]; then echo " ⚠ port $(basename "$f") already in use on the workstation, not relayed"; fi
|
|
192
199
|
done
|
|
193
200
|
return 0
|
|
194
201
|
}
|
|
195
202
|
|
|
196
|
-
#
|
|
203
|
+
# Subcommand "devzone workspace ports [start|stop|status]" (default: status).
|
|
197
204
|
ports() {
|
|
198
|
-
case "${1:-
|
|
199
|
-
demarrer)
|
|
200
|
-
arreter)
|
|
201
|
-
etat)
|
|
202
|
-
*) echo "✖ devzone workspace ports
|
|
205
|
+
case "${1:-status}" in
|
|
206
|
+
start | demarrer) ports_start ;;
|
|
207
|
+
stop | arreter) ports_stop ;;
|
|
208
|
+
status | etat) ports_status ;;
|
|
209
|
+
*) echo "✖ devzone workspace ports start|stop|status" >&2; return 1 ;;
|
|
203
210
|
esac
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
#
|
|
213
|
+
# compatibility aliases, removed with lot 4 (#509)
|
|
214
|
+
ports_demarrer() { ports_start "$@"; }
|
|
215
|
+
ports_arreter() { ports_stop "$@"; }
|
|
216
|
+
ports_etat() { ports_status "$@"; }
|
|
217
|
+
|
|
218
|
+
# Run directly: watcher loop, or a single round (tests).
|
|
207
219
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
208
|
-
|
|
220
|
+
pw_guard quiet || exit 2
|
|
209
221
|
case "${1:-}" in
|
|
210
|
-
boucle)
|
|
211
|
-
tour)
|
|
222
|
+
loop | boucle) pw_loop ;;
|
|
223
|
+
round | tour) pw_round ;;
|
|
212
224
|
esac
|
|
213
225
|
fi
|
package/manage/scripts/poste.sh
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# .devzone.modules (#472).
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# Portable
|
|
2
|
+
# Why: make up|shell|stop|rebuild always drives the Docker container, even
|
|
3
|
+
# after "devzone workspace migrate", which writes workspace=kubernetes in
|
|
4
|
+
# .devzone.modules (#472). This script reads that mode: in Kubernetes it hands
|
|
5
|
+
# off to manage/workspace.sh (repo clone) or npx devzone@<version> workspace
|
|
6
|
+
# (folder created by npx devzone); in Docker it returns 3 and does nothing, so
|
|
7
|
+
# the Makefile keeps its original recipe. The advice target shows, after an
|
|
8
|
+
# update, what the workstation can do next (#472).
|
|
9
|
+
# Portable: bash 3.2 (macOS) and Linux.
|
|
10
10
|
set -uo pipefail
|
|
11
11
|
|
|
12
12
|
usage() {
|
|
13
|
-
echo "usage
|
|
13
|
+
echo "usage: bash manage/scripts/poste.sh up|shell|stop|rebuild|advice <folder>" >&2
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
local
|
|
20
|
-
|
|
21
|
-
if [ "$
|
|
16
|
+
# Last workspace= value in <folder>/.devzone.modules; missing, empty or not
|
|
17
|
+
# kubernetes -> docker.
|
|
18
|
+
workspace_mode() {
|
|
19
|
+
local folder="$1" value
|
|
20
|
+
value="$(grep '^workspace=' "$folder/.devzone.modules" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
|
|
21
|
+
if [ "$value" = "kubernetes" ]; then
|
|
22
22
|
echo kubernetes
|
|
23
23
|
else
|
|
24
24
|
echo docker
|
|
25
25
|
fi
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
local
|
|
32
|
-
version="$(sed -n 's/^version \([^[:space:]]*\)[[:space:]]*$/\1/p' "$
|
|
28
|
+
# Folder version: first "version X.Y.Z" line in .devzone.version; unreadable or
|
|
29
|
+
# empty -> latest.
|
|
30
|
+
folder_version() {
|
|
31
|
+
local folder="$1" version
|
|
32
|
+
version="$(sed -n 's/^version \([^[:space:]]*\)[[:space:]]*$/\1/p' "$folder/.devzone.version" 2>/dev/null | head -1 || true)"
|
|
33
33
|
if [ -z "$version" ]; then
|
|
34
34
|
echo latest
|
|
35
35
|
else
|
|
@@ -37,9 +37,9 @@ version_dossier() {
|
|
|
37
37
|
fi
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
# Kubernetes
|
|
41
|
-
#
|
|
42
|
-
|
|
40
|
+
# Kubernetes reachable: kubectl and helm present, and kubectl cluster-info
|
|
41
|
+
# responds within 5 s (--context devzone if that context is declared).
|
|
42
|
+
kube_ready() {
|
|
43
43
|
command -v kubectl >/dev/null 2>&1 || return 1
|
|
44
44
|
command -v helm >/dev/null 2>&1 || return 1
|
|
45
45
|
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
@@ -49,53 +49,52 @@ kube_pret() {
|
|
|
49
49
|
fi
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
52
|
+
# Workspace command for the folder: clone script if present, otherwise the
|
|
53
|
+
# published CLI for the folder version, run from the folder.
|
|
54
54
|
workspace_cmd() {
|
|
55
|
-
local
|
|
55
|
+
local folder="$1" version
|
|
56
56
|
shift
|
|
57
|
-
if [ -f "$
|
|
58
|
-
(cd "$
|
|
57
|
+
if [ -f "$folder/manage/workspace.sh" ]; then
|
|
58
|
+
(cd "$folder" && bash manage/workspace.sh "$@")
|
|
59
59
|
else
|
|
60
|
-
version="$(
|
|
61
|
-
(cd "$
|
|
60
|
+
version="$(folder_version "$folder")"
|
|
61
|
+
(cd "$folder" && npx -y "devzone@$version" workspace "$@")
|
|
62
62
|
fi
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
case "$
|
|
68
|
-
up | shell | stop | rebuild | conseil) ;;
|
|
65
|
+
target="${1:-}"
|
|
66
|
+
folder="${2:-}"
|
|
67
|
+
case "$target" in
|
|
68
|
+
up | shell | stop | rebuild | advice | conseil) ;;
|
|
69
69
|
*)
|
|
70
70
|
usage
|
|
71
71
|
exit 2
|
|
72
72
|
;;
|
|
73
73
|
esac
|
|
74
|
-
if [ -z "$
|
|
74
|
+
if [ -z "$folder" ]; then
|
|
75
75
|
usage
|
|
76
76
|
exit 2
|
|
77
77
|
fi
|
|
78
78
|
|
|
79
|
-
#
|
|
80
|
-
|
|
81
|
-
if [ "$
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
echo "Kubernetes joignable : devzone workspace migrer passe ce poste dans le cluster (rien n'est supprimé, retour : devzone workspace revenir)."
|
|
79
|
+
# Advice after update: always exit 0, nothing to do in Docker without reachable Kubernetes.
|
|
80
|
+
if [ "$target" = "advice" ] || [ "$target" = "conseil" ]; then
|
|
81
|
+
if [ "$(workspace_mode "$folder")" = kubernetes ]; then
|
|
82
|
+
echo "Kubernetes workspace: the new image is used on the next devzone workspace start (or make up)."
|
|
83
|
+
elif kube_ready; then
|
|
84
|
+
echo "Kubernetes reachable: devzone workspace migrate moves this workstation to the cluster (nothing is deleted, rollback: devzone workspace revert)."
|
|
86
85
|
fi
|
|
87
86
|
exit 0
|
|
88
87
|
fi
|
|
89
88
|
|
|
90
|
-
#
|
|
91
|
-
[ "$(
|
|
89
|
+
# Docker workstation: Makefile resumes its current recipe (exit 3).
|
|
90
|
+
[ "$(workspace_mode "$folder")" = kubernetes ] || exit 3
|
|
92
91
|
|
|
93
|
-
case "$
|
|
94
|
-
up) workspace_cmd "$
|
|
95
|
-
shell) workspace_cmd "$
|
|
96
|
-
stop) workspace_cmd "$
|
|
92
|
+
case "$target" in
|
|
93
|
+
up) workspace_cmd "$folder" start ;;
|
|
94
|
+
shell) workspace_cmd "$folder" start && workspace_cmd "$folder" shell ;;
|
|
95
|
+
stop) workspace_cmd "$folder" stop ;;
|
|
97
96
|
rebuild)
|
|
98
|
-
echo "✖ make rebuild
|
|
97
|
+
echo "✖ make rebuild: this workstation is in Kubernetes workspace mode (workspace=kubernetes in .devzone.modules), nothing to rebuild on the machine; back to Docker workstation: devzone workspace revert" >&2
|
|
99
98
|
exit 1
|
|
100
99
|
;;
|
|
101
100
|
esac
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# devzone workspace services (#528): installs or removes the devzone services
|
|
3
|
-
# (gitlab, postgres, argocd) of a Kubernetes workspace from the workstation.
|
|
3
|
+
# (gitlab, postgres, mysql, argocd) of a Kubernetes workspace from the workstation.
|
|
4
4
|
# Sourced by manage/workspace.sh (drapeau_kubectl, POD, NAMESPACE).
|
|
5
5
|
# devzone workspace services enable <service> [options]
|
|
6
|
-
# devzone workspace services disable <service> [--
|
|
6
|
+
# devzone workspace services disable <service> [--yes]
|
|
7
7
|
# devzone workspace services status
|
|
8
8
|
# Why: the pod has no administrator access to the cluster (#430), while the
|
|
9
9
|
# installers need one. The workstation creates a ServiceAccount bound to
|
|
@@ -19,12 +19,12 @@ SERVICES_ADMIN_SCRIPT="${DEVZONE_SERVICES_ADMIN_SCRIPT:-/usr/local/share/devzone
|
|
|
19
19
|
SERVICES_TOKEN_DURATION="${DEVZONE_SERVICES_TOKEN_DURATION:-1h}"
|
|
20
20
|
|
|
21
21
|
services_usage() {
|
|
22
|
-
echo "devzone workspace services enable|disable <gitlab|postgres|argocd> [options] | status"
|
|
22
|
+
echo "devzone workspace services enable|disable <gitlab|postgres|mysql|argocd> [options] | status"
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
services_known() {
|
|
26
26
|
case "${1:-}" in
|
|
27
|
-
gitlab | postgres | argocd) return 0 ;;
|
|
27
|
+
gitlab | postgres | mysql | argocd) return 0 ;;
|
|
28
28
|
esac
|
|
29
29
|
return 1
|
|
30
30
|
}
|
|
@@ -34,6 +34,7 @@ services_namespace() {
|
|
|
34
34
|
case "$1" in
|
|
35
35
|
gitlab) echo devzone-gitlab ;;
|
|
36
36
|
postgres) echo devzone-postgres ;;
|
|
37
|
+
mysql) echo devzone-mysql ;;
|
|
37
38
|
argocd) echo devzone-argocd ;;
|
|
38
39
|
esac
|
|
39
40
|
}
|
|
@@ -91,6 +92,20 @@ services_run() {
|
|
|
91
92
|
echo "✖ unknown service: ${service:-(none)} ($(services_usage))" >&2
|
|
92
93
|
return 1
|
|
93
94
|
fi
|
|
95
|
+
# Argo CD itself, and postgres and mysql when Argo CD holds the devzone
|
|
96
|
+
# charts: done by the workstation, no installer in the pod (#516, #538)
|
|
97
|
+
if [ "$service" = argocd ]; then
|
|
98
|
+
argocd_toggle "$action" "$@"
|
|
99
|
+
return
|
|
100
|
+
fi
|
|
101
|
+
case "$service" in
|
|
102
|
+
postgres | mysql)
|
|
103
|
+
if argocd_holds_charts; then
|
|
104
|
+
services_argocd_toggle "$service" "$action" "$@"
|
|
105
|
+
return
|
|
106
|
+
fi
|
|
107
|
+
;;
|
|
108
|
+
esac
|
|
94
109
|
if ! services_pod_running; then
|
|
95
110
|
echo "✖ workspace pod $POD not running: devzone workspace start" >&2
|
|
96
111
|
return 1
|
|
@@ -110,6 +125,8 @@ services_run() {
|
|
|
110
125
|
return 1
|
|
111
126
|
fi
|
|
112
127
|
echo "▶ $action $service in the pod $POD…"
|
|
128
|
+
# The installer of the pod still spells --oui (#510): --yes translated
|
|
129
|
+
set -- "${@/--yes/--oui}"
|
|
113
130
|
# shellcheck disable=SC2046
|
|
114
131
|
printf '%s\n' "$token" | kubectl $(drapeau_kubectl) exec -i "$POD" --namespace "$NAMESPACE" \
|
|
115
132
|
-c workspace -- bash "$SERVICES_ADMIN_SCRIPT" "$action" "$service" "$@" || code=$?
|
|
@@ -125,7 +142,7 @@ services_run() {
|
|
|
125
142
|
# One line per service: installed (namespace present) or not
|
|
126
143
|
services_status() {
|
|
127
144
|
local s ns
|
|
128
|
-
for s in gitlab postgres argocd; do
|
|
145
|
+
for s in gitlab postgres mysql argocd; do
|
|
129
146
|
ns="$(services_namespace "$s")"
|
|
130
147
|
# shellcheck disable=SC2046
|
|
131
148
|
if kubectl $(drapeau_kubectl) get namespace "$ns" >/dev/null 2>&1; then
|