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.
- package/.devcontainer/.dockerignore +1 -1
- package/.devcontainer/argocd/argocd.sh +6 -7
- package/.devcontainer/argocd/catalogue-argocd.sh +114 -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 +1 -1
- package/.devcontainer/password.sh +8 -0
- package/README.md +1 -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 +2 -1
- 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 +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 +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
|
@@ -1,61 +1,61 @@
|
|
|
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
|
-
#
|
|
58
|
-
#
|
|
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).
|
|
59
59
|
pw_services() {
|
|
60
60
|
local port
|
|
61
61
|
if grep -qxE 'postgres=(on|true|oui)' .devzone.modules 2>/dev/null; then
|
|
@@ -74,8 +74,8 @@ pw_services() {
|
|
|
74
74
|
fi
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
#
|
|
78
|
-
|
|
77
|
+
# Is port $1 already in use on the workstation? (lsof, otherwise nc -z)
|
|
78
|
+
pw_taken() {
|
|
79
79
|
if command -v lsof >/dev/null 2>&1; then
|
|
80
80
|
lsof -nP -iTCP:"$1" -sTCP:LISTEN >/dev/null 2>&1
|
|
81
81
|
else
|
|
@@ -83,138 +83,143 @@ pw_pris() {
|
|
|
83
83
|
fi
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
|
|
89
|
-
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
|
|
90
90
|
d="$(pw_dir)"
|
|
91
91
|
pid="$(cat "$d/relais/$port" 2>/dev/null || true)"
|
|
92
|
-
|
|
93
|
-
if
|
|
94
|
-
[ -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"; }
|
|
95
95
|
return 0
|
|
96
96
|
fi
|
|
97
97
|
# shellcheck disable=SC2046
|
|
98
|
-
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 &
|
|
99
99
|
echo $! >"$d/relais/$port"
|
|
100
100
|
rm -f "$d/pris/$port"
|
|
101
|
-
echo "→ port $port
|
|
101
|
+
echo "→ port $port relayed on 127.0.0.1"
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
#
|
|
105
|
-
|
|
104
|
+
# Stops relay of port $1 and forgets its warning.
|
|
105
|
+
pw_remove() {
|
|
106
106
|
local d pid
|
|
107
107
|
d="$(pw_dir)"
|
|
108
108
|
pid="$(cat "$d/relais/$1" 2>/dev/null || true)"
|
|
109
|
-
if
|
|
109
|
+
if pw_alive "$pid"; then kill "$pid" 2>/dev/null || true; fi
|
|
110
110
|
rm -f "$d/relais/$1" "$d/pris/$1"
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
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
|
|
116
116
|
d="$(pw_dir)"
|
|
117
117
|
mkdir -p "$d/relais" "$d/pris"
|
|
118
|
-
while IFS='|' read -r p ns
|
|
118
|
+
while IFS='|' read -r p ns target remote; do
|
|
119
119
|
[ -n "$p" ] || continue
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
wanted="$wanted $p "
|
|
121
|
+
pw_relay "$p" "$ns" "$target" "${remote:-$p}"
|
|
122
122
|
done <<<"$(pw_services)"
|
|
123
|
-
for p in $(
|
|
124
|
-
case "$
|
|
125
|
-
|
|
126
|
-
|
|
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"
|
|
127
127
|
done
|
|
128
128
|
for f in "$d"/relais/* "$d"/pris/*; do
|
|
129
129
|
[ -e "$f" ] || continue
|
|
130
130
|
l="$(basename "$f")"
|
|
131
|
-
case "$
|
|
131
|
+
case "$wanted" in *" $l "*) ;; *) pw_remove "$l" ;; esac
|
|
132
132
|
done
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
#
|
|
136
|
-
|
|
135
|
+
# Removes all relays from the state folder.
|
|
136
|
+
pw_remove_all() {
|
|
137
137
|
local f
|
|
138
138
|
for f in "$(pw_dir)"/relais/*; do
|
|
139
|
-
if [ -e "$f" ]; then
|
|
139
|
+
if [ -e "$f" ]; then pw_remove "$(basename "$f")"; fi
|
|
140
140
|
done
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
#
|
|
144
|
-
|
|
143
|
+
# Watcher loop: one round every 3 s; on stop, removes its relays and lock.
|
|
144
|
+
pw_loop() {
|
|
145
145
|
local d
|
|
146
146
|
d="$(pw_dir)"
|
|
147
|
-
trap '
|
|
147
|
+
trap 'pw_remove_all; rm -rf "$d/verrou" "$d/pid"; exit 0' TERM INT
|
|
148
148
|
while :; do
|
|
149
|
-
|
|
149
|
+
pw_round || true
|
|
150
150
|
sleep "${DEVZONE_PORTS_WORKSPACE_PAS:-3}" &
|
|
151
151
|
wait $!
|
|
152
152
|
done
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
#
|
|
155
|
+
# Starts the watcher, only one: mkdir lock, pid recorded; $1=silence: no guard message.
|
|
156
156
|
# shellcheck disable=SC2120
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
ports_start() {
|
|
158
|
+
pw_guard "${1:-}" || return 0
|
|
159
159
|
local d pid
|
|
160
160
|
d="$(pw_dir)"
|
|
161
161
|
mkdir -p "$d"
|
|
162
162
|
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
163
|
-
if
|
|
164
|
-
echo "
|
|
163
|
+
if pw_alive "$pid"; then
|
|
164
|
+
echo "Workspace ports: watcher already running (pid $pid)"
|
|
165
165
|
return 0
|
|
166
166
|
fi
|
|
167
167
|
rm -rf "$d/verrou"
|
|
168
168
|
mkdir "$d/verrou" 2>/dev/null || return 0
|
|
169
|
-
nohup bash "${BASH_SOURCE[0]}"
|
|
169
|
+
nohup bash "${BASH_SOURCE[0]}" loop >>"$d/journal.log" 2>&1 &
|
|
170
170
|
echo $! >"$d/pid"
|
|
171
171
|
disown 2>/dev/null || true
|
|
172
|
-
echo "
|
|
172
|
+
echo "Workspace ports: watcher started, log $d/journal.log"
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
#
|
|
176
|
-
|
|
175
|
+
# Stops the watcher and all its port-forwards; without watcher, removes leftovers.
|
|
176
|
+
ports_stop() {
|
|
177
177
|
local d pid
|
|
178
178
|
d="$(pw_dir)"
|
|
179
179
|
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
180
|
-
if
|
|
180
|
+
if pw_alive "$pid"; then
|
|
181
181
|
kill "$pid" 2>/dev/null || true
|
|
182
|
-
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
|
|
183
183
|
fi
|
|
184
|
-
|
|
184
|
+
pw_remove_all
|
|
185
185
|
rm -rf "$d/verrou" "$d/pid"
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
#
|
|
189
|
-
|
|
188
|
+
# Shows status: watcher, relayed ports, reported taken ports.
|
|
189
|
+
ports_status() {
|
|
190
190
|
local d pid f
|
|
191
191
|
d="$(pw_dir)"
|
|
192
192
|
pid="$(cat "$d/pid" 2>/dev/null || true)"
|
|
193
|
-
if
|
|
193
|
+
if pw_alive "$pid"; then echo "Port watcher: running (pid $pid)"; else echo "Port watcher: stopped"; fi
|
|
194
194
|
for f in "$d"/relais/*; do
|
|
195
|
-
if [ -e "$f" ] &&
|
|
195
|
+
if [ -e "$f" ] && pw_alive "$(cat "$f")"; then echo " 127.0.0.1:$(basename "$f") relayed"; fi
|
|
196
196
|
done
|
|
197
197
|
for f in "$d"/pris/*; do
|
|
198
|
-
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
|
|
199
199
|
done
|
|
200
200
|
return 0
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
#
|
|
203
|
+
# Subcommand "devzone workspace ports [start|stop|status]" (default: status).
|
|
204
204
|
ports() {
|
|
205
|
-
case "${1:-
|
|
206
|
-
demarrer)
|
|
207
|
-
arreter)
|
|
208
|
-
etat)
|
|
209
|
-
*) 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 ;;
|
|
210
210
|
esac
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
#
|
|
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).
|
|
214
219
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
215
|
-
|
|
220
|
+
pw_guard quiet || exit 2
|
|
216
221
|
case "${1:-}" in
|
|
217
|
-
boucle)
|
|
218
|
-
tour)
|
|
222
|
+
loop | boucle) pw_loop ;;
|
|
223
|
+
round | tour) pw_round ;;
|
|
219
224
|
esac
|
|
220
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,6 +1,6 @@
|
|
|
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
6
|
# devzone workspace services disable <service> [--yes]
|
|
@@ -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,16 +92,20 @@ services_run() {
|
|
|
91
92
|
echo "✖ unknown service: ${service:-(none)} ($(services_usage))" >&2
|
|
92
93
|
return 1
|
|
93
94
|
fi
|
|
94
|
-
# Argo CD itself, and postgres when Argo CD holds the devzone
|
|
95
|
-
# by the workstation, no installer in the pod (#516)
|
|
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)
|
|
96
97
|
if [ "$service" = argocd ]; then
|
|
97
98
|
argocd_toggle "$action" "$@"
|
|
98
99
|
return
|
|
99
100
|
fi
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
104
109
|
if ! services_pod_running; then
|
|
105
110
|
echo "✖ workspace pod $POD not running: devzone workspace start" >&2
|
|
106
111
|
return 1
|
|
@@ -137,7 +142,7 @@ services_run() {
|
|
|
137
142
|
# One line per service: installed (namespace present) or not
|
|
138
143
|
services_status() {
|
|
139
144
|
local s ns
|
|
140
|
-
for s in gitlab postgres argocd; do
|
|
145
|
+
for s in gitlab postgres mysql argocd; do
|
|
141
146
|
ns="$(services_namespace "$s")"
|
|
142
147
|
# shellcheck disable=SC2046
|
|
143
148
|
if kubectl $(drapeau_kubectl) get namespace "$ns" >/dev/null 2>&1; then
|