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
package/manage/workspace.sh
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# charts/devzone-workspace
|
|
2
|
+
# Workstation commands for the Kubernetes workspace (#398, #399): drives the
|
|
3
|
+
# charts/devzone-workspace chart with host helm and kubectl.
|
|
4
4
|
set -euo pipefail
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Pod, namespace
|
|
6
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
ROOT="$(cd "$HERE/.." && pwd)"
|
|
8
|
+
# Pod, namespace and projects folder inside the container (#399).
|
|
9
9
|
POD="devzone-workspace-0"
|
|
10
10
|
NAMESPACE="devzone-workspace"
|
|
11
|
-
|
|
11
|
+
PROJECTS_DIR="/workspaces/projets"
|
|
12
|
+
# compatibility alias, removed with lot 4 (#509)
|
|
13
|
+
# shellcheck disable=SC2034
|
|
14
|
+
DOSSIER_PROJETS="$PROJECTS_DIR"
|
|
12
15
|
|
|
13
|
-
#
|
|
14
|
-
|
|
16
|
+
# Helm flag: devzone context if it exists, otherwise current context (no flag).
|
|
17
|
+
helm_flag() {
|
|
15
18
|
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
16
19
|
printf -- '--kube-context devzone'
|
|
17
20
|
fi
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
#
|
|
21
|
-
|
|
23
|
+
# kubectl flag: devzone context if it exists, otherwise current context (no flag).
|
|
24
|
+
kubectl_flag() {
|
|
22
25
|
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
23
26
|
printf -- '--context devzone'
|
|
24
27
|
fi
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
printf '%s/charts/devzone-workspace' "$
|
|
30
|
+
# Chart path in the repository (or installed package).
|
|
31
|
+
chart_path() {
|
|
32
|
+
printf '%s/charts/devzone-workspace' "$ROOT"
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
#
|
|
33
|
-
|
|
35
|
+
# Repository of the image published at each devzone release.
|
|
36
|
+
IMAGE_REPO="ghcr.io/simbienvenuehoulboumi/devzone-workspace"
|
|
34
37
|
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
|
|
38
|
+
# Why: without tag, the chart takes its appVersion (0.1.0), an image never
|
|
39
|
+
# published; the package version is published at each release, and a
|
|
40
|
+
# development clone (0.0.0) uses latest.
|
|
41
|
+
default_image_tag() {
|
|
39
42
|
local version
|
|
40
|
-
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$
|
|
43
|
+
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$ROOT/package.json" | head -1)"
|
|
41
44
|
if [ -z "$version" ] || [ "$version" = "0.0.0" ]; then
|
|
42
45
|
echo "latest"
|
|
43
46
|
else
|
|
@@ -45,53 +48,53 @@ image_par_defaut() {
|
|
|
45
48
|
fi
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
local
|
|
51
|
-
|
|
52
|
-
tag="$(
|
|
51
|
+
# Installs or upgrades the workspace in the cluster.
|
|
52
|
+
start_workspace() {
|
|
53
|
+
local repo tag image with_image="" args=()
|
|
54
|
+
repo="$IMAGE_REPO"
|
|
55
|
+
tag="$(default_image_tag)"
|
|
53
56
|
while [ $# -gt 0 ]; do
|
|
54
57
|
case "$1" in
|
|
55
58
|
--image)
|
|
56
59
|
if [ $# -lt 2 ] || [ -z "$2" ]; then
|
|
57
|
-
echo "✖ option --image
|
|
60
|
+
echo "✖ option --image: provide an image <repository:tag> (devzone workspace start --image <repository:tag>)" >&2
|
|
58
61
|
return 1
|
|
59
62
|
fi
|
|
60
63
|
case "$2" in
|
|
61
64
|
*:*)
|
|
62
|
-
|
|
65
|
+
repo="${2%:*}"
|
|
63
66
|
tag="${2##*:}"
|
|
64
|
-
|
|
67
|
+
with_image=yes
|
|
65
68
|
;;
|
|
66
69
|
*)
|
|
67
|
-
echo "✖ option --image
|
|
70
|
+
echo "✖ option --image: image has no tag, expected <repository:tag> (devzone workspace start --image <repository:tag>)" >&2
|
|
68
71
|
return 1
|
|
69
72
|
;;
|
|
70
73
|
esac
|
|
71
74
|
shift 2
|
|
72
75
|
;;
|
|
73
76
|
*)
|
|
74
|
-
echo "✖ option
|
|
77
|
+
echo "✖ unknown option: $1 (devzone workspace start [--image <repository:tag>])" >&2
|
|
75
78
|
return 1
|
|
76
79
|
;;
|
|
77
80
|
esac
|
|
78
81
|
done
|
|
79
|
-
image="$
|
|
82
|
+
image="$repo:$tag"
|
|
80
83
|
# Argo CD first when wanted (#516): the workspace is then an Application
|
|
81
84
|
argocd_ensure
|
|
82
|
-
workspace_deploy "$
|
|
85
|
+
workspace_deploy "$repo" "$tag" "$with_image"
|
|
83
86
|
# Projects of .argocd.conf held too (#516)
|
|
84
87
|
argocd_reconcile || true
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
wait_for_pod "$image" || return 1
|
|
89
|
+
ports_start silence
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
# helm direct: the chart of the package, image set by the options
|
|
90
93
|
workspace_helm_deploy() {
|
|
91
|
-
local
|
|
94
|
+
local repo="$1" tag="$2" with_image="$3" args=()
|
|
92
95
|
args=(--namespace devzone-workspace --create-namespace)
|
|
93
|
-
if [ -n "$
|
|
94
|
-
args+=(--set "image.repository=$
|
|
96
|
+
if [ -n "$with_image" ]; then
|
|
97
|
+
args+=(--set "image.repository=$repo" --set "image.tag=$tag")
|
|
95
98
|
else
|
|
96
99
|
args+=(--set "image.tag=$tag")
|
|
97
100
|
fi
|
|
@@ -101,129 +104,139 @@ workspace_helm_deploy() {
|
|
|
101
104
|
args+=(--set "image.pullPolicy=Always")
|
|
102
105
|
fi
|
|
103
106
|
# shellcheck disable=SC2046
|
|
104
|
-
helm $(
|
|
107
|
+
helm $(helm_flag) upgrade --install devzone-workspace "$(chart_path)" "${args[@]}"
|
|
105
108
|
}
|
|
106
109
|
|
|
107
|
-
#
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
# Uninstalls the workspace from the cluster (Argo CD Application or helm release).
|
|
111
|
+
stop_workspace() {
|
|
112
|
+
ports_stop
|
|
110
113
|
workspace_undeploy
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
#
|
|
114
|
-
|
|
116
|
+
# Shows workspace pod status.
|
|
117
|
+
status_workspace() {
|
|
115
118
|
# shellcheck disable=SC2046
|
|
116
|
-
kubectl $(
|
|
119
|
+
kubectl $(kubectl_flag) get pods --namespace devzone-workspace
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
#
|
|
120
|
-
|
|
122
|
+
# Opens a shell in the workspace container.
|
|
123
|
+
shell_workspace() {
|
|
121
124
|
# shellcheck disable=SC2046
|
|
122
|
-
kubectl $(
|
|
125
|
+
kubectl $(kubectl_flag) exec -it devzone-workspace-0 \
|
|
123
126
|
--namespace devzone-workspace -c workspace -- bash
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
|
|
129
|
+
# VS Code steps (#399): attach to the pod with Kubernetes and Dev Containers
|
|
130
|
+
# extensions, without any command other than devzone.
|
|
131
|
+
vscode_workspace() {
|
|
129
132
|
cat <<EOF
|
|
130
|
-
|
|
131
|
-
1.
|
|
132
|
-
2.
|
|
133
|
-
|
|
134
|
-
(
|
|
135
|
-
3.
|
|
136
|
-
Pod
|
|
133
|
+
Attach VS Code to the pod: "Kubernetes" and "Dev Containers" extensions
|
|
134
|
+
1. kubectl context: devzone — namespace $NAMESPACE, pod $POD, container workspace
|
|
135
|
+
2. Kubernetes view: right-click the workspace container,
|
|
136
|
+
"Attach to Running Kubernetes Container"
|
|
137
|
+
(with Dev Containers extension: "Dev Containers: Attach to Running Container")
|
|
138
|
+
3. Open folder $PROJECTS_DIR in the attached window
|
|
139
|
+
Pod not ready: devzone workspace status
|
|
137
140
|
EOF
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
|
|
143
|
-
local
|
|
144
|
-
if [ -z "$
|
|
145
|
-
echo "✖
|
|
143
|
+
# Copies a workstation folder to $PROJECTS_DIR in the pod (#399, kubectl cp):
|
|
144
|
+
# the project keeps its folder name in the pod.
|
|
145
|
+
copy_to() {
|
|
146
|
+
local folder="${1:-}"
|
|
147
|
+
if [ -z "$folder" ]; then
|
|
148
|
+
echo "✖ provide a workstation folder: devzone workspace copy-to <folder>" >&2
|
|
146
149
|
exit 1
|
|
147
150
|
fi
|
|
148
|
-
if [ ! -d "$
|
|
149
|
-
echo "✖
|
|
151
|
+
if [ ! -d "$folder" ]; then
|
|
152
|
+
echo "✖ folder not found: $folder" >&2
|
|
150
153
|
exit 1
|
|
151
154
|
fi
|
|
152
|
-
|
|
155
|
+
folder="$(cd "$folder" && pwd)"
|
|
153
156
|
# shellcheck disable=SC2046
|
|
154
|
-
kubectl $(
|
|
157
|
+
kubectl $(kubectl_flag) cp "$folder" "$POD:$PROJECTS_DIR/$(basename "$folder")" \
|
|
155
158
|
--namespace "$NAMESPACE" -c workspace
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
local
|
|
162
|
-
if [ -z "$
|
|
163
|
-
echo "✖
|
|
161
|
+
# Copies a project from $PROJECTS_DIR in the pod to the workstation (#399, kubectl cp):
|
|
162
|
+
# the workstation folder gets the project name.
|
|
163
|
+
copy_from() {
|
|
164
|
+
local folder="${1:-}"
|
|
165
|
+
if [ -z "$folder" ]; then
|
|
166
|
+
echo "✖ provide a workstation folder: devzone workspace copy-from <folder>" >&2
|
|
164
167
|
exit 1
|
|
165
168
|
fi
|
|
166
|
-
#
|
|
167
|
-
|
|
169
|
+
# Absolute path: "copy-from ." gives the current folder name.
|
|
170
|
+
folder="$(cd "$folder" 2>/dev/null && pwd || echo "$folder")"
|
|
168
171
|
# shellcheck disable=SC2046
|
|
169
|
-
kubectl $(
|
|
172
|
+
kubectl $(kubectl_flag) cp "$POD:$PROJECTS_DIR/$(basename "$folder")" "$folder" \
|
|
170
173
|
--namespace "$NAMESPACE" -c workspace
|
|
171
174
|
}
|
|
172
175
|
|
|
173
|
-
#
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
# French names of the command and compatibility aliases (lot 3, #508)
|
|
177
|
+
# shellcheck source=manage/scripts/workspace-aliases.sh
|
|
178
|
+
. "$HERE/scripts/workspace-aliases.sh"
|
|
179
|
+
# shellcheck source=manage/scripts/workspace-wait.sh
|
|
180
|
+
. "$HERE/scripts/workspace-wait.sh"
|
|
181
|
+
# shellcheck source=manage/scripts/migrer.sh
|
|
182
|
+
. "$HERE/scripts/migrer.sh"
|
|
183
|
+
# shellcheck source=manage/scripts/migrer-retour.sh
|
|
184
|
+
. "$HERE/scripts/migrer-retour.sh"
|
|
185
|
+
# shellcheck source=manage/scripts/ports-workspace.sh
|
|
186
|
+
. "$HERE/scripts/ports-workspace.sh"
|
|
187
|
+
# shellcheck source=manage/scripts/services-workspace.sh
|
|
188
|
+
. "$HERE/scripts/services-workspace.sh"
|
|
189
|
+
# shellcheck source=manage/scripts/argocd-workspace.sh
|
|
190
|
+
. "$HERE/scripts/argocd-workspace.sh"
|
|
191
|
+
# shellcheck source=manage/scripts/argocd-services.sh
|
|
192
|
+
. "$HERE/scripts/argocd-services.sh"
|
|
187
193
|
|
|
188
194
|
# English command names are accepted, French ones unchanged (#502).
|
|
189
195
|
# A copied devzone may miss the aliases file: then no normalization.
|
|
190
196
|
# shellcheck source=../.devcontainer/command-aliases.sh
|
|
191
197
|
# shellcheck disable=SC1091
|
|
192
|
-
if [ -f "$
|
|
193
|
-
. "$
|
|
198
|
+
if [ -f "$ROOT/.devcontainer/command-aliases.sh" ]; then
|
|
199
|
+
. "$ROOT/.devcontainer/command-aliases.sh"
|
|
194
200
|
if [ "$#" -gt 0 ]; then
|
|
195
201
|
set -- "$(command_canonical "$1")" "${@:2}"
|
|
196
202
|
fi
|
|
197
203
|
fi
|
|
198
204
|
|
|
205
|
+
if [ "$#" -gt 0 ]; then
|
|
206
|
+
set -- "$(workspace_command "$1")" "${@:2}"
|
|
207
|
+
fi
|
|
208
|
+
if [ "${1:-}" = "ports" ] && [ "$#" -gt 1 ]; then
|
|
209
|
+
set -- "$1" "$(workspace_ports_command "$2")" "${@:3}"
|
|
210
|
+
fi
|
|
211
|
+
|
|
199
212
|
case "${1:-}" in
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
shell)
|
|
204
|
-
vscode)
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
start) start_workspace "${@:2}" ;;
|
|
214
|
+
stop) stop_workspace ;;
|
|
215
|
+
status) status_workspace ;;
|
|
216
|
+
shell) shell_workspace ;;
|
|
217
|
+
vscode) vscode_workspace ;;
|
|
218
|
+
copy-to) copy_to "${@:2}" ;;
|
|
219
|
+
copy-from) copy_from "${@:2}" ;;
|
|
207
220
|
ports) ports "${@:2}" ;;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
221
|
+
migrate) migrate_workspace "${@:2}" ;;
|
|
222
|
+
revert) revert_workspace "${@:2}" ;;
|
|
223
|
+
clean-docker) clean_docker "${@:2}" ;;
|
|
211
224
|
services) services "${@:2}" ;;
|
|
212
225
|
argocd) argocd_cmd "${@:2}" ;;
|
|
213
226
|
'' | -h | --help | aide)
|
|
214
|
-
echo "devzone workspace
|
|
215
|
-
echo "
|
|
216
|
-
echo " ports [
|
|
227
|
+
echo "devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|ports|services|argocd|migrate|revert|clean-docker"
|
|
228
|
+
echo " start [--image repository:tag] install workspace (image for devzone version by default)"
|
|
229
|
+
echo " ports [start|stop|status] applications and services from pod on workstation localhost"
|
|
217
230
|
echo " services enable|disable <service> [options] | status"
|
|
218
231
|
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:
|
|
221
|
-
echo "
|
|
222
|
-
echo "
|
|
223
|
-
echo "
|
|
232
|
+
echo " argocd status | init [--repo <url>|--none] | apply | app add <repo url> [path] [--name N] [--revision R] | app list | app remove <N>"
|
|
233
|
+
echo " Argo CD of the workspace: .argocd.conf, GitOps repository, your projects as Applications"
|
|
234
|
+
echo " migrate [--yes] copy Docker workstation to Kubernetes workspace (nothing is deleted)"
|
|
235
|
+
echo " revert [--bring-back] back to Docker workstation; --bring-back: copy pod projects first"
|
|
236
|
+
echo " clean-docker remove devzone-* Docker volumes, after confirmation [y/N] (--yes)"
|
|
224
237
|
;;
|
|
225
238
|
*)
|
|
226
|
-
echo "✖
|
|
239
|
+
echo "✖ unknown subcommand: $1 (devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|ports|services|argocd|migrate|revert|clean-docker)" >&2
|
|
227
240
|
exit 1
|
|
228
241
|
;;
|
|
229
242
|
esac
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Argo CD minimal (#411) : un seul réplica par composant, sans Dex ni
|
|
2
|
-
# notifications, serveur en ClusterIP (aucun Ingress, aucun LoadBalancer).
|
|
3
|
-
# L'accès passe par le relais kubectl port-forward du conteneur (8443:443).
|
|
4
|
-
global:
|
|
5
|
-
domain: ""
|
|
6
|
-
# Aggregate ClusterRoles (#516): the Application resources join the edit role,
|
|
7
|
-
# so the limited devzone account (#430) manages the Applications of the
|
|
8
|
-
# projects in devzone-argocd (devzone argocd app …)
|
|
9
|
-
createAggregateRoles: true
|
|
10
|
-
dex:
|
|
11
|
-
enabled: false
|
|
12
|
-
notifications:
|
|
13
|
-
enabled: false
|
|
14
|
-
server:
|
|
15
|
-
replicas: 1
|
|
16
|
-
service:
|
|
17
|
-
type: ClusterIP
|
|
18
|
-
ingress:
|
|
19
|
-
enabled: false
|
|
20
|
-
controller:
|
|
21
|
-
replicas: 1
|
|
22
|
-
repoServer:
|
|
23
|
-
replicas: 1
|
|
24
|
-
applicationSet:
|
|
25
|
-
replicas: 1
|