devzone 0.36.7 → 0.37.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/argocd/application.sh +69 -0
- package/.devcontainer/argocd/apps.sh +262 -0
- package/.devcontainer/argocd/argocd.sh +46 -1
- package/.devcontainer/argocd/conf.sh +141 -0
- package/.devcontainer/argocd/gitops.sh +214 -0
- package/.devcontainer/argocd/values.yaml +4 -0
- package/.devcontainer/devzone +1 -0
- package/README.md +1 -1
- 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 +2 -0
- package/manage/scripts/argocd-services.sh +243 -0
- package/manage/scripts/argocd-workspace.sh +219 -0
- package/manage/scripts/ports-workspace.sh +17 -10
- package/manage/scripts/services-workspace.sh +13 -1
- package/manage/scripts/workspace-wait.sh +2 -2
- package/manage/workspace.sh +23 -7
- package/package.json +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Argo CD of the Kubernetes workspace, driven from the workstation (#516).
|
|
3
|
+
# Sourced by manage/workspace.sh (drapeau_kubectl, drapeau_helm, RACINE: the
|
|
4
|
+
# package; $PWD: the devzone folder of the workstation, its .devzone.modules,
|
|
5
|
+
# workspace/.argocd and .password).
|
|
6
|
+
# argocd_wanted 0 unless .devzone.modules says argocd=off (on by default)
|
|
7
|
+
# argocd_installed namespace devzone-argocd present
|
|
8
|
+
# argocd_active wanted and installed: Applications instead of helm direct
|
|
9
|
+
# argocd_ensure installs it when wanted and missing (workspace start)
|
|
10
|
+
# argocd_install | argocd_uninstall | argocd_status
|
|
11
|
+
# argocd_revision Git revision of the devzone charts; empty on a dev clone
|
|
12
|
+
# argocd_apply_application / argocd_delete_application
|
|
13
|
+
# Why: the pod has no administrator access (#430); the workstation has helm
|
|
14
|
+
# and kubectl. The admin password goes to workspace/.argocd/admin.env and
|
|
15
|
+
# .password of the workstation, never on screen. bash 3.2 (macOS).
|
|
16
|
+
|
|
17
|
+
ARGOCD_NS="devzone-argocd"
|
|
18
|
+
ARGOCD_CHART_VERSION="${ARGOCD_VERSION:-10.14.0}"
|
|
19
|
+
ARGOCD_LOCAL_PORT="${ARGOCD_PORT:-8443}"
|
|
20
|
+
ARGOCD_WAIT="${ARGOCD_ATTENTE:-600}"
|
|
21
|
+
ARGOCD_MIN_MEMORY_KI=1048576
|
|
22
|
+
DEVZONE_REPO_URL="${DEVZONE_REPO_URL:-https://github.com/SimBienvenueHoulBoumi/devzone.git}"
|
|
23
|
+
|
|
24
|
+
argocd_values() { printf '%s/.devcontainer/argocd/values.yaml' "$RACINE"; }
|
|
25
|
+
argocd_generator() { printf '%s/.devcontainer/argocd/application.sh' "$RACINE"; }
|
|
26
|
+
argocd_secrets_dir() { printf '%s/workspace/.argocd' "$PWD"; }
|
|
27
|
+
|
|
28
|
+
# kubectl of the workstation, context devzone when it exists
|
|
29
|
+
ak() {
|
|
30
|
+
# shellcheck disable=SC2046
|
|
31
|
+
kubectl $(drapeau_kubectl) "$@"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Last value of a key of .devzone.modules of the workstation (empty if none)
|
|
35
|
+
state_read() {
|
|
36
|
+
grep "^$1=" .devzone.modules 2>/dev/null | tail -1 | cut -d= -f2- || true
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# key=value written in .devzone.modules of the workstation, other lines kept
|
|
40
|
+
state_note() {
|
|
41
|
+
local f=".devzone.modules" tmp
|
|
42
|
+
tmp="$f.tmp.$$"
|
|
43
|
+
{
|
|
44
|
+
if [ -f "$f" ]; then grep -v "^$1=" "$f" || true; fi
|
|
45
|
+
echo "$1=$2"
|
|
46
|
+
} >"$tmp" && mv "$tmp" "$f"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
argocd_wanted() { [ "$(state_read argocd)" != off ]; }
|
|
50
|
+
|
|
51
|
+
argocd_installed() { ak get namespace "$ARGOCD_NS" >/dev/null 2>&1; }
|
|
52
|
+
|
|
53
|
+
argocd_active() { argocd_wanted && argocd_installed; }
|
|
54
|
+
|
|
55
|
+
# Git revision of the devzone charts: DEVZONE_ARGOCD_REVISION, else the tag of
|
|
56
|
+
# the package version; empty on a development clone (0.0.0: the local chart
|
|
57
|
+
# is not in Git)
|
|
58
|
+
argocd_revision() {
|
|
59
|
+
local version
|
|
60
|
+
if [ -n "${DEVZONE_ARGOCD_REVISION:-}" ]; then
|
|
61
|
+
printf '%s' "$DEVZONE_ARGOCD_REVISION"
|
|
62
|
+
return 0
|
|
63
|
+
fi
|
|
64
|
+
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$RACINE/package.json" | head -1)"
|
|
65
|
+
case "$version" in
|
|
66
|
+
'' | 0.0.0) ;;
|
|
67
|
+
*) printf 'v%s' "$version" ;;
|
|
68
|
+
esac
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Kubernetes memory quantity in Ki (Ki, Mi, Gi, Ti, K, M, G, bytes)
|
|
72
|
+
argocd_quantity_ki() {
|
|
73
|
+
local q="${1:-}" n
|
|
74
|
+
case "$q" in
|
|
75
|
+
*Ki) n="${q%Ki}"; echo $((n)) ;;
|
|
76
|
+
*Mi) n="${q%Mi}"; echo $((n * 1024)) ;;
|
|
77
|
+
*Gi) n="${q%Gi}"; echo $((n * 1024 * 1024)) ;;
|
|
78
|
+
*Ti) n="${q%Ti}"; echo $((n * 1024 * 1024 * 1024)) ;;
|
|
79
|
+
*K | *k) n="${q%[Kk]}"; echo $((n * 1000 / 1024)) ;;
|
|
80
|
+
*M) n="${q%M}"; echo $((n * 1000 * 1000 / 1024)) ;;
|
|
81
|
+
*G) n="${q%G}"; echo $((n * 1000 * 1000 * 1000 / 1024)) ;;
|
|
82
|
+
*)
|
|
83
|
+
case "$q" in
|
|
84
|
+
'' | *[!0-9]*) echo 0 ;;
|
|
85
|
+
*) echo $((q / 1024)) ;;
|
|
86
|
+
esac
|
|
87
|
+
;;
|
|
88
|
+
esac
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Refuses under 1 Gi of allocatable memory in the cluster (sum of the nodes)
|
|
92
|
+
argocd_memory_ok() {
|
|
93
|
+
local lines value total=0
|
|
94
|
+
lines="$(ak get nodes -o jsonpath='{range .items[*]}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || lines=""
|
|
95
|
+
if [ -z "$lines" ]; then
|
|
96
|
+
echo "✖ argocd: cluster unreachable or nodes unreadable (kubectl config get-contexts)" >&2
|
|
97
|
+
return 2
|
|
98
|
+
fi
|
|
99
|
+
while IFS= read -r value; do
|
|
100
|
+
[ -n "$value" ] || continue
|
|
101
|
+
total=$((total + $(argocd_quantity_ki "$value")))
|
|
102
|
+
done <<<"$lines"
|
|
103
|
+
if [ "$total" -lt "$ARGOCD_MIN_MEMORY_KI" ]; then
|
|
104
|
+
echo "✖ argocd: at least 1 Gi of allocatable memory is needed in the cluster (available: $((total / 1024)) Mi); enlarge the cluster (Docker Desktop → Settings → Resources), then: devzone workspace services enable argocd" >&2
|
|
105
|
+
return 2
|
|
106
|
+
fi
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Initial admin password, read with kubectl (go-template base64decode: no
|
|
110
|
+
# base64 of the workstation involved), written in workspace/.argocd/admin.env
|
|
111
|
+
# (600) and in .password; never printed
|
|
112
|
+
argocd_save_admin_password() {
|
|
113
|
+
local dir password
|
|
114
|
+
dir="$(argocd_secrets_dir)"
|
|
115
|
+
password="$(ak -n "$ARGOCD_NS" get secret argocd-initial-admin-secret \
|
|
116
|
+
-o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
|
|
117
|
+
if [ -z "$password" ]; then
|
|
118
|
+
echo "⚠ argocd: admin password unreadable (secret argocd-initial-admin-secret); .password not updated" >&2
|
|
119
|
+
return 0
|
|
120
|
+
fi
|
|
121
|
+
mkdir -p "$dir"
|
|
122
|
+
chmod 700 "$dir"
|
|
123
|
+
(
|
|
124
|
+
umask 077
|
|
125
|
+
printf 'ARGOCD_URL=https://localhost:%s\nARGOCD_USER=admin\nARGOCD_PASSWORD=%s\n' "$ARGOCD_LOCAL_PORT" "$password" >"$dir/admin.env"
|
|
126
|
+
)
|
|
127
|
+
chmod 600 "$dir/admin.env"
|
|
128
|
+
argocd_passwords_refresh
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# .password of the workstation regenerated from workspace/.*/ (password.sh of the package)
|
|
132
|
+
argocd_passwords_refresh() {
|
|
133
|
+
DEVZONE_RACINE="$PWD" bash "$RACINE/.devcontainer/password.sh" regenerer 2>/dev/null ||
|
|
134
|
+
echo "⚠ .password not updated (bash .devcontainer/password.sh regenerer)" >&2
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Installs Argo CD (pinned chart and values), idempotent (upgrade --install)
|
|
138
|
+
argocd_install() {
|
|
139
|
+
argocd_memory_ok || return 2
|
|
140
|
+
echo "▶ Argo CD $ARGOCD_CHART_VERSION in $ARGOCD_NS (helm, up to ${ARGOCD_WAIT}s)…"
|
|
141
|
+
ak create namespace "$ARGOCD_NS" --dry-run=client -o yaml | ak apply -f - >/dev/null
|
|
142
|
+
ak label namespace "$ARGOCD_NS" app.kubernetes.io/managed-by=devzone --overwrite >/dev/null
|
|
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
|
+
# shellcheck disable=SC2046
|
|
146
|
+
helm $(drapeau_helm) upgrade --install argocd argo/argo-cd \
|
|
147
|
+
--version "$ARGOCD_CHART_VERSION" --namespace "$ARGOCD_NS" \
|
|
148
|
+
-f "$(argocd_values)" --timeout "${ARGOCD_WAIT}s" --wait || return 1
|
|
149
|
+
argocd_save_admin_password
|
|
150
|
+
echo "✔ Argo CD ready: https://localhost:$ARGOCD_LOCAL_PORT once devzone workspace ports runs; user admin, password in .password"
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Installs it when wanted and missing (workspace start); a refusal (memory)
|
|
154
|
+
# is told and the start goes on with helm direct
|
|
155
|
+
argocd_ensure() {
|
|
156
|
+
argocd_wanted || return 0
|
|
157
|
+
argocd_installed && return 0
|
|
158
|
+
argocd_install || echo "⚠ Argo CD not installed: the workspace is deployed with helm directly (devzone workspace services enable argocd to retry)" >&2
|
|
159
|
+
return 0
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
# Applications removed without cascade (finalizer dropped first: the services
|
|
163
|
+
# stay, under helm direct; the GitOps repository keeps its files), then helm
|
|
164
|
+
# uninstall and the namespace
|
|
165
|
+
argocd_uninstall() {
|
|
166
|
+
local app
|
|
167
|
+
if argocd_installed; then
|
|
168
|
+
echo "▶ Argo CD removal: Applications released (their resources stay), release and namespace deleted…"
|
|
169
|
+
while IFS= read -r app; do
|
|
170
|
+
[ -n "$app" ] || continue
|
|
171
|
+
gitops_direct_delete_application "${app#*/}" keep
|
|
172
|
+
done <<<"$(ak -n "$ARGOCD_NS" get applications.argoproj.io -o name 2>/dev/null || true)"
|
|
173
|
+
# shellcheck disable=SC2046
|
|
174
|
+
helm $(drapeau_helm) uninstall argocd --namespace "$ARGOCD_NS" >/dev/null 2>&1 || true
|
|
175
|
+
ak delete namespace "$ARGOCD_NS" --wait=true --ignore-not-found >/dev/null
|
|
176
|
+
fi
|
|
177
|
+
rm -rf "$(argocd_secrets_dir)"
|
|
178
|
+
argocd_passwords_refresh
|
|
179
|
+
echo "✔ Argo CD removed; the services stay, under helm direct"
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
# Applies the Application <name> of <kind> to <namespace> from <repo> at
|
|
183
|
+
# <revision>, <path>; the other arguments are Helm parameters key=value.
|
|
184
|
+
# In the GitOps repository when one is designated (gitops.sh), else directly
|
|
185
|
+
argocd_apply_application() {
|
|
186
|
+
gitops_apply_application "$@"
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
# Deletes an Application (and its file of the GitOps repository); keep:
|
|
190
|
+
# finalizer dropped first, its resources stay
|
|
191
|
+
argocd_delete_application() {
|
|
192
|
+
gitops_delete_application "$@"
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
argocd_application_exists() {
|
|
196
|
+
ak -n "$ARGOCD_NS" get application.argoproj.io "$1" >/dev/null 2>&1
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
# Installed or not, then the Applications with their sync and health status
|
|
200
|
+
argocd_status() {
|
|
201
|
+
if ! argocd_installed; then
|
|
202
|
+
echo "○ argocd not installed: devzone workspace services enable argocd"
|
|
203
|
+
return 0
|
|
204
|
+
fi
|
|
205
|
+
if argocd_wanted; then
|
|
206
|
+
echo "✔ argocd installed: https://localhost:$ARGOCD_LOCAL_PORT (devzone workspace ports), user admin, password in .password"
|
|
207
|
+
else
|
|
208
|
+
echo "⚠ argocd installed but argocd=off in .devzone.modules: devzone workspace services enable argocd, or disable to remove it"
|
|
209
|
+
fi
|
|
210
|
+
if gitops_enabled; then
|
|
211
|
+
echo " GitOps repository: $(gitops_repo) (apps/, root Application $GITOPS_ROOT_APP)"
|
|
212
|
+
else
|
|
213
|
+
echo " no GitOps repository: Applications applied directly (devzone workspace argocd init)"
|
|
214
|
+
fi
|
|
215
|
+
ak -n "$ARGOCD_NS" get applications.argoproj.io \
|
|
216
|
+
-o custom-columns='APPLICATION:.metadata.name,KIND:.metadata.labels.devzone\.io/kind,SYNC:.status.sync.status,HEALTH:.status.health.status,REVISION:.spec.source.targetRevision' \
|
|
217
|
+
2>/dev/null | sed 's/^/ /'
|
|
218
|
+
return 0
|
|
219
|
+
}
|
|
@@ -53,18 +53,25 @@ pw_ports_pod() {
|
|
|
53
53
|
done
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
# Services de devzone à relayer, une ligne « port|namespace|cible »
|
|
57
|
-
# modules actifs : postgres (5432) et pgAdmin s'il existe dans le
|
|
56
|
+
# Services de devzone à relayer, une ligne « port|namespace|cible[|port distant] »
|
|
57
|
+
# par service des modules actifs : postgres (5432) et pgAdmin s'il existe dans le
|
|
58
|
+
# namespace, mysql (3306), et l'interface d'Argo CD (8443 → 443) quand elle est là (#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
77
|
# Le port $1 est-il déjà pris sur le poste ? (lsof, sinon nc -z)
|
|
@@ -76,10 +83,10 @@ pw_pris() {
|
|
|
76
83
|
fi
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
# Lance le relais du port $1 vers
|
|
80
|
-
# port pris sur le poste : une seule ligne d'avertissement par port.
|
|
86
|
+
# Lance le relais du port $1 vers le port $4 (défaut : $1) de la cible $3 du namespace
|
|
87
|
+
# $2, sauf s'il vit déjà ; port pris sur le poste : une seule ligne d'avertissement par port.
|
|
81
88
|
pw_relayer() {
|
|
82
|
-
local port="$1" ns="$2" cible="$3" d pid
|
|
89
|
+
local port="$1" ns="$2" cible="$3" distant="${4:-$1}" d pid
|
|
83
90
|
d="$(pw_dir)"
|
|
84
91
|
pid="$(cat "$d/relais/$port" 2>/dev/null || true)"
|
|
85
92
|
pw_vivant "$pid" && return 0
|
|
@@ -88,7 +95,7 @@ pw_relayer() {
|
|
|
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 "$cible" "$port:$
|
|
98
|
+
kubectl $(pw_ctx) --namespace "$ns" port-forward --address 127.0.0.1 "$cible" "$port:$distant" </dev/null >/dev/null 2>&1 &
|
|
92
99
|
echo $! >"$d/relais/$port"
|
|
93
100
|
rm -f "$d/pris/$port"
|
|
94
101
|
echo "→ port $port relayé sur 127.0.0.1"
|
|
@@ -105,13 +112,13 @@ pw_retirer() {
|
|
|
105
112
|
|
|
106
113
|
# Un tour du veilleur : relaie les nouveaux ports, retire ceux qui ont disparu.
|
|
107
114
|
pw_tour() {
|
|
108
|
-
local d voulus="" p ns cible l f
|
|
115
|
+
local d voulus="" p ns cible distant l f
|
|
109
116
|
d="$(pw_dir)"
|
|
110
117
|
mkdir -p "$d/relais" "$d/pris"
|
|
111
|
-
while IFS='|' read -r p ns cible; do
|
|
118
|
+
while IFS='|' read -r p ns cible distant; do
|
|
112
119
|
[ -n "$p" ] || continue
|
|
113
120
|
voulus="$voulus $p "
|
|
114
|
-
pw_relayer "$p" "$ns" "$cible"
|
|
121
|
+
pw_relayer "$p" "$ns" "$cible" "${distant:-$p}"
|
|
115
122
|
done <<<"$(pw_services)"
|
|
116
123
|
for p in $(pw_ports_pod); do
|
|
117
124
|
case "$voulus" in *" $p "*) continue ;; esac
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# (gitlab, postgres, 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
|
|
@@ -91,6 +91,16 @@ services_run() {
|
|
|
91
91
|
echo "✖ unknown service: ${service:-(none)} ($(services_usage))" >&2
|
|
92
92
|
return 1
|
|
93
93
|
fi
|
|
94
|
+
# Argo CD itself, and postgres when Argo CD holds the devzone charts: done
|
|
95
|
+
# by the workstation, no installer in the pod (#516)
|
|
96
|
+
if [ "$service" = argocd ]; then
|
|
97
|
+
argocd_toggle "$action" "$@"
|
|
98
|
+
return
|
|
99
|
+
fi
|
|
100
|
+
if [ "$service" = postgres ] && argocd_holds_charts; then
|
|
101
|
+
postgres_argocd "$action" "$@"
|
|
102
|
+
return
|
|
103
|
+
fi
|
|
94
104
|
if ! services_pod_running; then
|
|
95
105
|
echo "✖ workspace pod $POD not running: devzone workspace start" >&2
|
|
96
106
|
return 1
|
|
@@ -110,6 +120,8 @@ services_run() {
|
|
|
110
120
|
return 1
|
|
111
121
|
fi
|
|
112
122
|
echo "▶ $action $service in the pod $POD…"
|
|
123
|
+
# The installer of the pod still spells --oui (#510): --yes translated
|
|
124
|
+
set -- "${@/--yes/--oui}"
|
|
113
125
|
# shellcheck disable=SC2046
|
|
114
126
|
printf '%s\n' "$token" | kubectl $(drapeau_kubectl) exec -i "$POD" --namespace "$NAMESPACE" \
|
|
115
127
|
-c workspace -- bash "$SERVICES_ADMIN_SCRIPT" "$action" "$service" "$@" || code=$?
|
|
@@ -37,8 +37,8 @@ attendre_pod() {
|
|
|
37
37
|
;;
|
|
38
38
|
esac
|
|
39
39
|
echo " Pour une image construite à la main : devzone workspace demarrer --image <repository:tag>" >&2
|
|
40
|
-
#
|
|
41
|
-
|
|
40
|
+
# Application Argo CD ou release helm (#516) : sinon selfHeal recréerait le pod
|
|
41
|
+
workspace_undeploy >/dev/null 2>&1 || true
|
|
42
42
|
return 1
|
|
43
43
|
;;
|
|
44
44
|
Running*)
|
package/manage/workspace.sh
CHANGED
|
@@ -77,6 +77,18 @@ demarrer() {
|
|
|
77
77
|
esac
|
|
78
78
|
done
|
|
79
79
|
image="$depot:$tag"
|
|
80
|
+
# Argo CD first when wanted (#516): the workspace is then an Application
|
|
81
|
+
argocd_ensure
|
|
82
|
+
workspace_deploy "$depot" "$tag" "$avec_image"
|
|
83
|
+
# Projects of .argocd.conf held too (#516)
|
|
84
|
+
argocd_reconcile || true
|
|
85
|
+
attendre_pod "$image" || return 1
|
|
86
|
+
ports_demarrer silence
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# helm direct: the chart of the package, image set by the options
|
|
90
|
+
workspace_helm_deploy() {
|
|
91
|
+
local depot="$1" tag="$2" avec_image="$3" args=()
|
|
80
92
|
args=(--namespace devzone-workspace --create-namespace)
|
|
81
93
|
if [ -n "$avec_image" ]; then
|
|
82
94
|
args+=(--set "image.repository=$depot" --set "image.tag=$tag")
|
|
@@ -90,15 +102,12 @@ demarrer() {
|
|
|
90
102
|
fi
|
|
91
103
|
# shellcheck disable=SC2046
|
|
92
104
|
helm $(drapeau_helm) upgrade --install devzone-workspace "$(chemin_chart)" "${args[@]}"
|
|
93
|
-
attendre_pod "$image" || return 1
|
|
94
|
-
ports_demarrer silence
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
# Désinstalle le workspace du cluster.
|
|
107
|
+
# Désinstalle le workspace du cluster (Application Argo CD ou release helm).
|
|
98
108
|
arreter() {
|
|
99
109
|
ports_arreter
|
|
100
|
-
|
|
101
|
-
helm $(drapeau_helm) uninstall devzone-workspace --namespace devzone-workspace
|
|
110
|
+
workspace_undeploy
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
# Affiche l'état des pods du workspace.
|
|
@@ -171,6 +180,10 @@ copier_depuis() {
|
|
|
171
180
|
. "$ICI/scripts/ports-workspace.sh"
|
|
172
181
|
# shellcheck source=scripts/services-workspace.sh
|
|
173
182
|
. "$ICI/scripts/services-workspace.sh"
|
|
183
|
+
# shellcheck source=scripts/argocd-workspace.sh
|
|
184
|
+
. "$ICI/scripts/argocd-workspace.sh"
|
|
185
|
+
# shellcheck source=scripts/argocd-services.sh
|
|
186
|
+
. "$ICI/scripts/argocd-services.sh"
|
|
174
187
|
|
|
175
188
|
# English command names are accepted, French ones unchanged (#502).
|
|
176
189
|
# A copied devzone may miss the aliases file: then no normalization.
|
|
@@ -196,18 +209,21 @@ case "${1:-}" in
|
|
|
196
209
|
revenir) revenir "${@:2}" ;;
|
|
197
210
|
nettoyer-docker) nettoyer_docker "${@:2}" ;;
|
|
198
211
|
services) services "${@:2}" ;;
|
|
212
|
+
argocd) argocd_cmd "${@:2}" ;;
|
|
199
213
|
'' | -h | --help | aide)
|
|
200
|
-
echo "devzone workspace demarrer|arreter|etat|shell|vscode|copier-vers|copier-depuis|ports|services|migrer|revenir|nettoyer-docker"
|
|
214
|
+
echo "devzone workspace demarrer|arreter|etat|shell|vscode|copier-vers|copier-depuis|ports|services|argocd|migrer|revenir|nettoyer-docker"
|
|
201
215
|
echo " demarrer [--image dépôt:tag] installe le workspace (image de la version de devzone par défaut)"
|
|
202
216
|
echo " ports [demarrer|arreter|etat] applications et services du pod sur localhost du poste"
|
|
203
217
|
echo " services enable|disable <service> [options] | status"
|
|
204
218
|
echo " devzone services (gitlab, postgres, argocd) of the cluster, installed from the workstation"
|
|
219
|
+
echo " argocd status | app add <repo url> [path] [--name N] [--revision R] | app list | app remove <N>"
|
|
220
|
+
echo " Argo CD of the workspace: deployments held in Git, your projects as Applications"
|
|
205
221
|
echo " migrer [--oui] copie le poste Docker vers le workspace Kubernetes (rien n'est supprimé)"
|
|
206
222
|
echo " revenir [--rapatrier] retour au poste Docker ; --rapatrier : projets du pod recopiés d'abord"
|
|
207
223
|
echo " nettoyer-docker supprime les volumes Docker devzone-*, après confirmation [o/N] (--oui)"
|
|
208
224
|
;;
|
|
209
225
|
*)
|
|
210
|
-
echo "✖ sous-commande inconnue : $1 (devzone workspace demarrer|arreter|etat|shell|vscode|copier-vers|copier-depuis|ports|services|migrer|revenir|nettoyer-docker)" >&2
|
|
226
|
+
echo "✖ sous-commande inconnue : $1 (devzone workspace demarrer|arreter|etat|shell|vscode|copier-vers|copier-depuis|ports|services|argocd|migrer|revenir|nettoyer-docker)" >&2
|
|
211
227
|
exit 1
|
|
212
228
|
;;
|
|
213
229
|
esac
|