devzone 7.1.0 → 7.2.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/Dockerfile +15 -22
- package/.devcontainer/ai/host-check.message +12 -12
- package/.devcontainer/ai/host-check.sh +1 -1
- package/.devcontainer/catalog/app.sh +5 -12
- package/.devcontainer/catalog/catalog-watcher.sh +7 -7
- package/.devcontainer/catalog.sh +1 -1
- package/.devcontainer/cluster.sh +1 -11
- package/.devcontainer/devcontainer.json +1 -11
- package/.devcontainer/devzone +19 -23
- package/.devcontainer/devzone-ai.sh +1 -1
- package/.devcontainer/devzone-cluster.sh +2 -3
- package/.devcontainer/devzone-modules.sh +7 -2
- package/.devcontainer/devzone-repair.sh +11 -21
- package/.devcontainer/devzone-services.sh +21 -20
- package/.devcontainer/devzone-status.sh +4 -12
- package/.devcontainer/gitlab/demo/.gitlab-ci.yml +1 -1
- package/.devcontainer/help.sh +3 -5
- package/.devcontainer/isolation.sh +1 -1
- package/.devcontainer/kube-account.sh +12 -173
- package/.devcontainer/metrics-server.sh +1 -1
- package/.devcontainer/packages.sh +3 -3
- package/.devcontainer/password.sh +5 -6
- package/.devcontainer/ports-json.sh +0 -4
- package/.devcontainer/ports.sh +7 -103
- package/.devcontainer/services-admin.sh +2 -2
- package/.devcontainer/state-json.sh +4 -14
- package/.devcontainer/versions.env +2 -2
- package/.devcontainer/workspace-init.sh +1 -9
- package/Makefile +6 -6
- package/README.md +14 -33
- package/bin/SHA256SUMS +6 -6
- package/bin/devzone-darwin-amd64 +0 -0
- package/bin/devzone-darwin-arm64 +0 -0
- package/bin/devzone-linux-amd64 +0 -0
- package/bin/devzone-linux-arm64 +0 -0
- package/bin/devzone-windows-amd64.exe +0 -0
- package/bin/devzone-windows-arm64.exe +0 -0
- package/manage/devzone +7 -20
- package/manage/scripts/ci/check-names.sh +5 -6
- package/manage/scripts/ci/ticket-protocol.txt +7 -0
- package/manage/scripts/ci/versions-tools-plan.sh +1 -1
- package/manage/scripts/devzone-create.sh +4 -4
- package/manage/scripts/devzone-update.sh +18 -22
- package/manage/scripts/workspace/argocd-services.sh +1 -1
- package/manage/scripts/workspace/argocd-workspace.sh +2 -2
- package/manage/scripts/workspace/ports-workspace.sh +5 -5
- package/manage/scripts/workspace/services-workspace.sh +3 -3
- package/manage/scripts/workspace/workspace-update.sh +0 -3
- package/manage/workspace.sh +0 -14
- package/package.json +1 -1
- package/.devcontainer/argocd/argocd.sh +0 -222
- package/.devcontainer/argocd/catalog-argocd.sh +0 -119
- package/.devcontainer/argocd/services-hook.sh +0 -181
- package/.devcontainer/catalog/mysql/install.sh +0 -87
- package/.devcontainer/catalog/mysql/mysql.sh +0 -262
- package/.devcontainer/catalog/mysql/volume.sh +0 -71
- package/.devcontainer/command-aliases.sh +0 -234
- package/.devcontainer/git-identity.sh +0 -28
- package/.devcontainer/gitlab/argocd.sh +0 -54
- package/.devcontainer/gitlab/chart.sh +0 -39
- package/.devcontainer/gitlab/gitlab.sh +0 -168
- package/.devcontainer/gitlab/installation.sh +0 -193
- package/.devcontainer/gitlab/secrets.sh +0 -95
- package/.devcontainer/gitlab/seed.sh +0 -204
- package/.devcontainer/gitlab/test-gitlab-restes.sh +0 -16
- package/.devcontainer/gitlab/test-gitlab.sh +0 -489
- package/.devcontainer/kind-wrapper.sh +0 -45
- package/.devcontainer/kube-config.sh +0 -78
- package/.devcontainer/kube-reachable.sh +0 -64
- package/.devcontainer/ports-auto.sh +0 -247
- package/.devcontainer/post-create.sh +0 -91
- package/.devcontainer/postgres/postgres.sh +0 -309
- package/.devcontainer/rename-legacy-files.sh +0 -172
- package/.devcontainer/rename-legacy-ports.sh +0 -119
- package/.devcontainer/startup.sh +0 -65
- package/manage/scripts/ci/check-english.sh +0 -57
|
@@ -63,13 +63,13 @@ show_state() {
|
|
|
63
63
|
printf ' ✖ module %-10s failed: incomplete install (%s): devzone apply\n' "$m" "$(cat "$(failure_marker_file "$m")")"
|
|
64
64
|
elif [ "$(value_of "$m")" = on ] && [ "$m" = gitlab ]; then
|
|
65
65
|
# gitlab active: its real state (ready, runner, failed)
|
|
66
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(
|
|
66
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(devzone gitlab status)"
|
|
67
67
|
elif [ "$(value_of "$m")" = on ] && [ "$m" = postgres ]; then
|
|
68
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(
|
|
68
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(devzone postgres status)"
|
|
69
69
|
elif [ "$(value_of "$m")" = on ] && [ "$m" = argocd ]; then
|
|
70
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(
|
|
70
|
+
printf ' ✔ module %-10s %s\n' "$m" "$("$ICI/devzone" argocd status)"
|
|
71
71
|
elif [ "$(value_of "$m")" = on ] && [ "$m" = mysql ]; then
|
|
72
|
-
printf ' ✔ module %-10s %s\n' "$m" "$(
|
|
72
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(devzone mysql status)"
|
|
73
73
|
elif [ "$(value_of "$m")" = on ]; then
|
|
74
74
|
printf ' ✔ module %-10s active: %s\n' "$m" "$(description "$m")"
|
|
75
75
|
else
|
|
@@ -98,14 +98,6 @@ show_state() {
|
|
|
98
98
|
if [ -n "$current_cluster" ] && ! cluster_is_local "$current_cluster"; then
|
|
99
99
|
printf ' ⚠ cluster remote: %s — services on a remote cluster\n' "$current_cluster"
|
|
100
100
|
fi
|
|
101
|
-
# Limited account token (#845): renewed as soon as it is close to expiry,
|
|
102
|
-
# only outside the pod and with a services cluster chosen (the cases where
|
|
103
|
-
# kube-account.sh is used); a failed renewal is reported for devzone repair
|
|
104
|
-
if ! in_pod && [ -n "$current_cluster" ] && ! account_token_fresh; then
|
|
105
|
-
if ! bash "$ICI/kube-account.sh" jeton >/dev/null 2>&1; then
|
|
106
|
-
echo " ⚠ limited account token expired: devzone repair"
|
|
107
|
-
fi
|
|
108
|
-
fi
|
|
109
101
|
devzone cluster clean --quiet || true
|
|
110
102
|
# Old kind-gitlab cluster still present: invite to migrate (#396)
|
|
111
103
|
if kind get clusters 2>/dev/null | grep -qx "gitlab${INSTANCE_SUFFIX}"; then
|
package/.devcontainer/help.sh
CHANGED
|
@@ -12,13 +12,12 @@ devzone_aide() {
|
|
|
12
12
|
devzone platform gitlab GitLab, [--url URL] (default: gitlab module)
|
|
13
13
|
devzone enable <module> enable and apply at once
|
|
14
14
|
devzone disable <module> [--yes] disable and apply at once (--yes: also deletes the data)
|
|
15
|
-
devzone apply install what is enabled
|
|
15
|
+
devzone apply install what is enabled
|
|
16
16
|
devzone repair repair gitlab, postgres, ports, passwords
|
|
17
|
-
devzone start full start (startup scripts and summary)
|
|
18
17
|
devzone metrics [context…] install metrics-server (kubectl top, k9s)
|
|
19
18
|
devzone use CTX [--confirm CTX] switch the kubectl working cluster
|
|
20
19
|
devzone clusters view of the connected clusters (work and services)
|
|
21
|
-
devzone is-enabled <module> code 0 if enabled
|
|
20
|
+
devzone is-enabled <module> code 0 if enabled
|
|
22
21
|
devzone test-bash32 run the bats tests under bash 3.2 (Docker container)
|
|
23
22
|
devzone test-gitlab end-to-end test of the GitLab module and platform
|
|
24
23
|
devzone agent <folder> <instructions> drive opencode with the instructions file
|
|
@@ -36,9 +35,8 @@ devzone_aide() {
|
|
|
36
35
|
devzone argocd status|relay-start|relay-stop Argo CD (argocd module)
|
|
37
36
|
devzone argocd app add <repo url> [path]|list|remove <N> projects deployed by Argo CD (#516)
|
|
38
37
|
devzone cluster [CTX] [--yes] [--confirm CTX] services cluster of devzone, or change it
|
|
39
|
-
devzone port [
|
|
38
|
+
devzone port [--close <n>] list or remove a relay of the workstation
|
|
40
39
|
devzone passwords regenerate .password and print its path
|
|
41
40
|
devzone packages [add|remove|apply] … system packages kept after a rebuild
|
|
42
|
-
Old French names are refused and print the new name (see the reference).
|
|
43
41
|
AIDE
|
|
44
42
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Network isolation and access authorization between devzone namespaces.
|
|
3
3
|
# File <= 250 lines: functions namespace_isolate, allow, forbid.
|
|
4
4
|
# These functions modify NetworkPolicies in the Kubernetes cluster.
|
|
5
|
-
# Loaded by argocd.sh, catalog.sh, mysql
|
|
5
|
+
# Loaded by argocd.sh, catalog.sh, the mysql and postgres Go modules, gitlab.sh; shipped with the package.
|
|
6
6
|
|
|
7
7
|
# Sets an isolating NetworkPolicy in a namespace.
|
|
8
8
|
# Only the pods of the same namespace can reach the services.
|
|
@@ -3,19 +3,15 @@
|
|
|
3
3
|
# agents) can only act in the devzone-* namespaces. The account is the
|
|
4
4
|
# ServiceAccount devzone-agent of the devzone-system namespace, bound to the
|
|
5
5
|
# edit ClusterRole (no RBAC, no quotas) in each devzone namespace by a
|
|
6
|
-
# RoleBinding
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
# Library sourced by cluster.sh; executable for the token:
|
|
12
|
-
# kube-account.sh jeton (argument kept: called by startup.sh and devzone repair)
|
|
6
|
+
# RoleBinding. The installers alone use the admin context (host context in
|
|
7
|
+
# ~/.kube/hote.config, kind cluster in ~/.kube/config); the shells use
|
|
8
|
+
# ~/.kube/config and the agents the limited ~/.kube/agent.config (devzone
|
|
9
|
+
# context only, #844).
|
|
10
|
+
# Library sourced by cluster.sh.
|
|
13
11
|
|
|
14
12
|
ACCOUNT_NS=devzone-system
|
|
15
13
|
ACCOUNT_SA=devzone-agent
|
|
16
|
-
ACCOUNT_DURATION=24h
|
|
17
14
|
ACCOUNT_CONFIG="${DEVZONE_KUBE_CONFIG:-$HOME/.kube/config}"
|
|
18
|
-
ACCOUNT_TOKEN_EXPIRY="${DEVZONE_KUBE_TOKEN_EXPIRY:-$HOME/.kube/devzone-token.expiry}"
|
|
19
15
|
|
|
20
16
|
# kubeconfig file that holds the admin context ctx: hote.config if it lists it
|
|
21
17
|
# (host clusters), otherwise ~/.kube/config (kind clusters of the container).
|
|
@@ -76,25 +72,18 @@ account_context() {
|
|
|
76
72
|
kubectl config current-context 2>/dev/null || true
|
|
77
73
|
}
|
|
78
74
|
|
|
79
|
-
# Sets up the limited account with the admin context: devzone-system namespace
|
|
80
|
-
# and devzone-agent ServiceAccount (idempotent, resumed at startup and at each
|
|
81
|
-
# installation).
|
|
82
|
-
account_setup() {
|
|
83
|
-
local ctx="$1"
|
|
84
|
-
account_admin "$ctx" create namespace "$ACCOUNT_NS" --dry-run=client -o yaml |
|
|
85
|
-
account_admin "$ctx" apply -f - >/dev/null || return 1
|
|
86
|
-
account_admin "$ctx" -n "$ACCOUNT_NS" create serviceaccount "$ACCOUNT_SA" \
|
|
87
|
-
--dry-run=client -o yaml | account_admin "$ctx" apply -f - >/dev/null || return 1
|
|
88
|
-
}
|
|
89
|
-
|
|
90
75
|
# Allows the account in namespace ns: devzone-agent RoleBinding to the edit
|
|
91
76
|
# ClusterRole (read, write, secrets, NetworkPolicies — no RBAC, no quotas), set
|
|
92
77
|
# with the admin context after the namespace is created.
|
|
93
|
-
# The account is set up first if missing:
|
|
94
|
-
#
|
|
78
|
+
# The account is set up first if missing: devzone-system namespace and
|
|
79
|
+
# devzone-agent ServiceAccount, so an installation on a still blank cluster
|
|
80
|
+
# makes the account usable at the next token renewal.
|
|
95
81
|
account_allow() {
|
|
96
82
|
local ctx="$1" ns="$2"
|
|
97
|
-
|
|
83
|
+
account_admin "$ctx" create namespace "$ACCOUNT_NS" --dry-run=client -o yaml |
|
|
84
|
+
account_admin "$ctx" apply -f - >/dev/null || return 1
|
|
85
|
+
account_admin "$ctx" -n "$ACCOUNT_NS" create serviceaccount "$ACCOUNT_SA" \
|
|
86
|
+
--dry-run=client -o yaml | account_admin "$ctx" apply -f - >/dev/null || return 1
|
|
98
87
|
account_admin "$ctx" -n "$ns" create rolebinding "$ACCOUNT_SA" \
|
|
99
88
|
--clusterrole=edit --serviceaccount="$ACCOUNT_NS:$ACCOUNT_SA" \
|
|
100
89
|
--dry-run=client -o yaml | account_admin "$ctx" apply -f - >/dev/null || return 1
|
|
@@ -116,153 +105,3 @@ account_namespace() {
|
|
|
116
105
|
account_admin "$ctx" label namespace "$ns" "$CLUSTER_LABEL" --overwrite >/dev/null || return 1
|
|
117
106
|
account_allow "$ctx" "$ns" || return 1
|
|
118
107
|
}
|
|
119
|
-
|
|
120
|
-
# Catches up the existing devzone namespaces: RoleBinding set in each namespace
|
|
121
|
-
# labelled CLUSTER_LABEL (idempotent), for the installations prior to the
|
|
122
|
-
# limited account.
|
|
123
|
-
account_catch_up() {
|
|
124
|
-
local ctx="$1" ns label="${CLUSTER_LABEL:-app.kubernetes.io/managed-by=devzone}"
|
|
125
|
-
while IFS= read -r ns; do
|
|
126
|
-
[ -n "$ns" ] || continue
|
|
127
|
-
ns="${ns#namespace/}"
|
|
128
|
-
account_admin "$ctx" -n "$ns" create rolebinding "$ACCOUNT_SA" \
|
|
129
|
-
--clusterrole=edit --serviceaccount="$ACCOUNT_NS:$ACCOUNT_SA" \
|
|
130
|
-
--dry-run=client -o yaml | account_admin "$ctx" apply -f - >/dev/null || return 1
|
|
131
|
-
done < <(account_admin "$ctx" get namespaces -l "$label" -o name 2>/dev/null || true)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
# Epoch seconds of the RFC 3339 expiration timestamp of a TokenRequest
|
|
135
|
-
# response; empty when the local date cannot read it, so the caller falls back
|
|
136
|
-
# to now + 24 h (Bash 3.2: GNU date -d, then the BSD date form).
|
|
137
|
-
account_expiry_epoch() {
|
|
138
|
-
local ts="$1" epoch
|
|
139
|
-
[ -n "$ts" ] || return 0
|
|
140
|
-
epoch="$(date -u -d "$ts" +%s 2>/dev/null || true)"
|
|
141
|
-
if [ -n "$epoch" ]; then
|
|
142
|
-
echo "$epoch"
|
|
143
|
-
return 0
|
|
144
|
-
fi
|
|
145
|
-
epoch="$(date -j -u -f '%Y-%m-%dT%H:%M:%SZ' "$ts" +%s 2>/dev/null || true)"
|
|
146
|
-
[ -n "$epoch" ] && echo "$epoch"
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
# True when the token has more than one hour left, read from the expiry file
|
|
150
|
-
# without any cluster call: absent, unreadable, non-numeric, close or past
|
|
151
|
-
# expiry → false.
|
|
152
|
-
account_token_fresh() {
|
|
153
|
-
local expiry now
|
|
154
|
-
[ -f "$ACCOUNT_TOKEN_EXPIRY" ] || return 1
|
|
155
|
-
expiry="$(cat "$ACCOUNT_TOKEN_EXPIRY" 2>/dev/null || true)"
|
|
156
|
-
case "$expiry" in
|
|
157
|
-
'' | *[!0-9]*) return 1 ;;
|
|
158
|
-
esac
|
|
159
|
-
now="$(date +%s)"
|
|
160
|
-
[ "$expiry" -gt $((now + 3600)) ]
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
# Renews the account's token (24 h TokenRequest) and writes it into the devzone
|
|
164
|
-
# context of ~/.kube/config: user devzone-agent, same cluster as the admin
|
|
165
|
-
# context (cluster entry copied: server, certificate authority and
|
|
166
|
-
# tls-server-name of the host context). The expiry timestamp of the TokenRequest
|
|
167
|
-
# response is kept in ACCOUNT_TOKEN_EXPIRY (now + 24 h if it is unreadable), only
|
|
168
|
-
# once a real call through the devzone context has succeeded.
|
|
169
|
-
account_token() {
|
|
170
|
-
local ctx="$1" conf token cluster server tls ca_data ca_file out expires expiry now answer
|
|
171
|
-
local entry=()
|
|
172
|
-
conf="$(account_admin_config "$ctx")"
|
|
173
|
-
out="$(account_admin "$ctx" create token "$ACCOUNT_SA" -n "$ACCOUNT_NS" \
|
|
174
|
-
--duration="$ACCOUNT_DURATION" \
|
|
175
|
-
-o jsonpath='{.status.token}{"\n"}{.status.expirationTimestamp}')" || return 1
|
|
176
|
-
token="$(printf '%s\n' "$out" | sed -n '1p')"
|
|
177
|
-
expires="$(printf '%s\n' "$out" | sed -n '2p')"
|
|
178
|
-
if [ -z "$token" ]; then
|
|
179
|
-
echo "devzone : limited account token is empty" >&2
|
|
180
|
-
return 1
|
|
181
|
-
fi
|
|
182
|
-
cluster="$(KUBECONFIG="$conf" kubectl config view \
|
|
183
|
-
-o jsonpath="{.contexts[?(@.name==\"$ctx\")].context.cluster}" 2>/dev/null || true)"
|
|
184
|
-
if [ -z "$cluster" ]; then
|
|
185
|
-
echo "devzone : cluster of context $ctx not found in $conf" >&2
|
|
186
|
-
return 1
|
|
187
|
-
fi
|
|
188
|
-
server="$(KUBECONFIG="$conf" kubectl config view \
|
|
189
|
-
-o jsonpath="{.clusters[?(@.name==\"$cluster\")].cluster.server}" 2>/dev/null || true)"
|
|
190
|
-
if [ -z "$server" ]; then
|
|
191
|
-
echo "devzone : server of cluster $cluster not found in $conf" >&2
|
|
192
|
-
return 1
|
|
193
|
-
fi
|
|
194
|
-
ca_data="$(KUBECONFIG="$conf" kubectl config view --raw -o jsonpath="{.clusters[?(@.name==\"$cluster\")].cluster.certificate-authority-data}" 2>/dev/null || true)"
|
|
195
|
-
ca_file="$(KUBECONFIG="$conf" kubectl config view \
|
|
196
|
-
-o jsonpath="{.clusters[?(@.name==\"$cluster\")].cluster.certificate-authority}" 2>/dev/null || true)"
|
|
197
|
-
entry=(--server="$server")
|
|
198
|
-
if [ -n "$ca_file" ]; then
|
|
199
|
-
entry+=(--certificate-authority="$ca_file" --embed-certs=true)
|
|
200
|
-
fi
|
|
201
|
-
tls="$(KUBECONFIG="$conf" kubectl config view \
|
|
202
|
-
-o jsonpath="{.clusters[?(@.name==\"$cluster\")].cluster.tls-server-name}" 2>/dev/null || true)"
|
|
203
|
-
if [ -n "$tls" ]; then
|
|
204
|
-
entry+=(--tls-server-name="$tls")
|
|
205
|
-
fi
|
|
206
|
-
KUBECONFIG="$ACCOUNT_CONFIG" kubectl config set-cluster "$cluster" \
|
|
207
|
-
${entry[@]+"${entry[@]}"} >/dev/null || return 1
|
|
208
|
-
if [ -n "$ca_data" ]; then
|
|
209
|
-
KUBECONFIG="$ACCOUNT_CONFIG" kubectl config set \
|
|
210
|
-
"clusters.$cluster.certificate-authority-data" "$ca_data" >/dev/null || return 1
|
|
211
|
-
fi
|
|
212
|
-
KUBECONFIG="$ACCOUNT_CONFIG" kubectl config set-credentials "$ACCOUNT_SA" \
|
|
213
|
-
--token="$token" >/dev/null || return 1
|
|
214
|
-
KUBECONFIG="$ACCOUNT_CONFIG" kubectl config set-context devzone \
|
|
215
|
-
--cluster="$cluster" --user="$ACCOUNT_SA" >/dev/null || return 1
|
|
216
|
-
answer="$(KUBECONFIG="$ACCOUNT_CONFIG" kubectl --context devzone \
|
|
217
|
-
auth can-i get pods -n "$ACCOUNT_NS" 2>/dev/null || true)"
|
|
218
|
-
case "$answer" in
|
|
219
|
-
yes | no) ;;
|
|
220
|
-
*)
|
|
221
|
-
echo "devzone : limited account context not reachable" >&2
|
|
222
|
-
rm -f "$ACCOUNT_TOKEN_EXPIRY"
|
|
223
|
-
return 1
|
|
224
|
-
;;
|
|
225
|
-
esac
|
|
226
|
-
now="$(date +%s)"
|
|
227
|
-
expiry="$(account_expiry_epoch "$expires")"
|
|
228
|
-
[ -n "$expiry" ] || expiry=$((now + 86400))
|
|
229
|
-
mkdir -p "$(dirname "$ACCOUNT_TOKEN_EXPIRY")"
|
|
230
|
-
printf '%s\n' "$expiry" >"$ACCOUNT_TOKEN_EXPIRY"
|
|
231
|
-
chmod 600 "$ACCOUNT_TOKEN_EXPIRY"
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
# Writes the limited agent kubeconfig: the devzone context only, current context
|
|
235
|
-
# set to it, for the agents that hold the limited account (Claude Code, #844).
|
|
236
|
-
# The contexts are read from ACCOUNT_CONFIG, never from the file being written:
|
|
237
|
-
# the view goes to a temporary file of the same folder, moved in place (atomic,
|
|
238
|
-
# mode 600); a failure empties the target and returns 1.
|
|
239
|
-
account_agent_config() {
|
|
240
|
-
local conf="${DEVZONE_KUBE_AGENT_CONFIG:-$HOME/.kube/agent.config}" tmp
|
|
241
|
-
tmp="$(mktemp "$(dirname "$conf")/.agent.config.XXXXXX")" || return 1
|
|
242
|
-
# shellcheck disable=SC2015 # the failure branch must empty the target too
|
|
243
|
-
( umask 077; KUBECONFIG="$ACCOUNT_CONFIG" kubectl config view --minify --flatten \
|
|
244
|
-
--context devzone >"$tmp" ) && KUBECONFIG="$tmp" kubectl config use-context devzone >/dev/null 2>&1 \
|
|
245
|
-
|| { rm -f "$tmp"; : >"$conf"; return 1; }
|
|
246
|
-
chmod 600 "$tmp"; mv "$tmp" "$conf"
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
# Direct execution: account token renewed at startup (startup.sh) and by
|
|
250
|
-
# « devzone repair ». Without a chosen services cluster: nothing to do.
|
|
251
|
-
# When the file is sourced, $0 differs from BASH_SOURCE: nothing runs.
|
|
252
|
-
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
253
|
-
if [ "${1:-}" != jeton ]; then
|
|
254
|
-
echo "devzone : kube-account : jeton" >&2
|
|
255
|
-
exit 1
|
|
256
|
-
fi
|
|
257
|
-
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
258
|
-
RACINE="${DEVZONE_ROOT:-$(dirname "$ICI")}"
|
|
259
|
-
ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
|
|
260
|
-
ctx="$(grep -E '^cluster=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
|
|
261
|
-
if [ -z "$ctx" ]; then
|
|
262
|
-
exit 0
|
|
263
|
-
fi
|
|
264
|
-
account_setup "$ctx" || exit 1
|
|
265
|
-
account_catch_up "$ctx" || exit 1
|
|
266
|
-
account_token "$ctx" || exit 1
|
|
267
|
-
account_agent_config || exit 1
|
|
268
|
-
fi
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# --kubelet-insecure-tls: the kubelet of Docker Desktop and kind has a
|
|
8
8
|
# self-signed certificate, without this option the pod never becomes Ready.
|
|
9
9
|
# Exits in error if a requested context is unknown or unreachable, or if an
|
|
10
|
-
# installation fails
|
|
10
|
+
# installation fails.
|
|
11
11
|
set -euo pipefail
|
|
12
12
|
|
|
13
13
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# System packages kept after a rebuild (#351): a list in the devzone folder
|
|
3
3
|
# (<root>/.devzone.packages, a comment header + one package name per line, sorted,
|
|
4
|
-
# without duplicates), reinstalled at each container creation
|
|
4
|
+
# without duplicates), reinstalled at each container creation.
|
|
5
5
|
# A package installed by hand is lost by a rebuild, unless it is in this list.
|
|
6
6
|
# packages.sh or packages.sh list list with the state of each package
|
|
7
7
|
# packages.sh add <name>… validates, installs, adds to the list
|
|
8
8
|
# packages.sh remove <name>… removes from the list and uninstalls (except image packages)
|
|
9
|
-
# packages.sh apply installs everything missing
|
|
9
|
+
# packages.sh apply installs everything missing
|
|
10
10
|
# The state of a package comes from dpkg-query -W -f='${Status}'; the system
|
|
11
11
|
# commands go through overridable variables for the tests (sudo, apt-get,
|
|
12
12
|
# apt-cache, dpkg-query, mark, timestamp). Compatible with bash 3.2 (macOS).
|
|
@@ -223,6 +223,6 @@ case "${1:-}" in
|
|
|
223
223
|
add) add_packages "${@:2}" ;;
|
|
224
224
|
remove) remove_packages "${@:2}" ;;
|
|
225
225
|
apply) apply_packages ;;
|
|
226
|
-
-h | --help
|
|
226
|
+
-h | --help) awk 'NR==1{next} /^#$/{exit} /^#/{sub(/^# ?/,""); print; next} {exit}' "${BASH_SOURCE[0]}" ;;
|
|
227
227
|
*) refuse "unknown command: ${1:-(none)} (devzone packages --help)" ;;
|
|
228
228
|
esac
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Grouped credentials of the accounts created by devzone (#332).
|
|
3
|
-
# password.sh
|
|
4
|
-
# password.sh
|
|
3
|
+
# password.sh regenerate reads the module files, writes $ROOT/.password
|
|
4
|
+
# password.sh path prints the path of $ROOT/.password
|
|
5
5
|
# The module files stay the source: .password is a regenerated view.
|
|
6
6
|
# Plain-text secrets: never printed, never committed (.gitignore), mode 600.
|
|
7
|
-
# (regenerer and chemin are public subcommand names, kept as they are.)
|
|
8
7
|
set -euo pipefail
|
|
9
8
|
|
|
10
9
|
PASSWORD_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -139,10 +138,10 @@ password_regenerate() (
|
|
|
139
138
|
|
|
140
139
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
141
140
|
case "${1:-}" in
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
regenerate) password_regenerate ;;
|
|
142
|
+
path) printf '%s\n' "$PASSWORD_TARGET" ;;
|
|
144
143
|
*)
|
|
145
|
-
echo "devzone : password.sh :
|
|
144
|
+
echo "devzone : password.sh : regenerate | path" >&2
|
|
146
145
|
exit 1
|
|
147
146
|
;;
|
|
148
147
|
esac
|
|
@@ -27,9 +27,5 @@ list_json() {
|
|
|
27
27
|
json="$(jq -c --argjson port "$port" --argjson active "$active" --arg app "$app" \
|
|
28
28
|
'. + [{port:$port,active:$active,application:$app,auto:false}]' <<<"$json")"
|
|
29
29
|
done
|
|
30
|
-
auto_json="$(bash "$HERE/ports-auto.sh" list_json_auto 2>/dev/null || echo '[]')"
|
|
31
|
-
if [ -n "$auto_json" ] && [ "$auto_json" != "[]" ]; then
|
|
32
|
-
json="$(jq -s 'add' <<<"$json"$'\n'"$auto_json")"
|
|
33
|
-
fi
|
|
34
30
|
printf '%s\n' "$json"
|
|
35
31
|
}
|
package/.devcontainer/ports.sh
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Port relays (#290): applications
|
|
3
|
-
# 127.0.0.1 of the workstation,
|
|
4
|
-
# ports.sh open <n> opens the relay of port <n>
|
|
2
|
+
# Port relays of the workstation (#290): applications reachable from
|
|
3
|
+
# 127.0.0.1 of the workstation, kept in the state of devzone.
|
|
5
4
|
# ports.sh list relays of the state: port, active, application
|
|
6
5
|
# ports.sh close <n> removes the relay and the port from the state
|
|
7
|
-
# ports.sh restart recreates the relays of the state toward the current IP
|
|
8
6
|
# ports.sh resume one-line summary for the devzone recap
|
|
9
7
|
# The state is the line "ports=8080,3000" of DEVZONE_STATE (sorted, no duplicate).
|
|
10
8
|
# ROOT: a single dirname from HERE (.devcontainer) = root of the devzone repository.
|
|
11
9
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then set -euo pipefail; fi
|
|
12
10
|
|
|
13
|
-
SOCAT_IMAGE=alpine/socat:1.8.0.3
|
|
14
|
-
|
|
15
11
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
16
12
|
ROOT="${DEVZONE_ROOT:-$(dirname "$HERE")}"
|
|
17
13
|
ETAT="${DEVZONE_STATE:-$ROOT/.devzone.modules}"
|
|
@@ -28,9 +24,9 @@ refuse() { echo "devzone : port : $*" >&2; exit 1; }
|
|
|
28
24
|
# French values (read by the tools, #557): a contract, UTF-8 written as byte escapes.
|
|
29
25
|
APP_RESPONDS="application responds"
|
|
30
26
|
APP_NONE="no application"
|
|
31
|
-
# shellcheck disable=SC2034 # read by ports-json.sh
|
|
27
|
+
# shellcheck disable=SC2034 # read by ports-json.sh (sourced)
|
|
32
28
|
JSON_APP_RESPONDS=$'application r\303\251pond'
|
|
33
|
-
# shellcheck disable=SC2034 # read by ports-json.sh
|
|
29
|
+
# shellcheck disable=SC2034 # read by ports-json.sh (sourced)
|
|
34
30
|
JSON_APP_NONE="aucune application"
|
|
35
31
|
|
|
36
32
|
relay_name() { echo "devzone-$INSTANCE-port-$1"; }
|
|
@@ -64,28 +60,6 @@ remove_port() {
|
|
|
64
60
|
write_ports "$(sort_ports "$rest")"
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
# Network and address of the devzone container, read on the host's Docker: the
|
|
68
|
-
# relay runs there and must reach the container by its IP.
|
|
69
|
-
network_ip() {
|
|
70
|
-
local line
|
|
71
|
-
command -v docker >/dev/null 2>&1 || return 1
|
|
72
|
-
line="$(docker inspect "$(hostname)" \
|
|
73
|
-
--format '{{range $nom, $r := .NetworkSettings.Networks}}{{$nom}} {{$r.IPAddress}}{{"\n"}}{{end}}' 2>/dev/null |
|
|
74
|
-
awk 'NF >= 2 && $2 != "" { print; exit }')" || return 1
|
|
75
|
-
[ -n "$line" ] || return 1
|
|
76
|
-
NETWORK="${line%% *}"
|
|
77
|
-
IP="${line#* }"
|
|
78
|
-
[ -n "$NETWORK" ] && [ -n "$IP" ]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
relay_exists() {
|
|
82
|
-
local name
|
|
83
|
-
name="$(relay_name "$1")"
|
|
84
|
-
command -v docker >/dev/null 2>&1 || return 1
|
|
85
|
-
[ -n "$(docker ps -a --filter "name=^$name$" --format '{{.Names}}' 2>/dev/null |
|
|
86
|
-
grep -Fx "$name" || true)" ]
|
|
87
|
-
}
|
|
88
|
-
|
|
89
63
|
relay_active() {
|
|
90
64
|
local name
|
|
91
65
|
name="$(relay_name "$1")"
|
|
@@ -94,47 +68,6 @@ relay_active() {
|
|
|
94
68
|
grep -Fx "$name" || true)" ]
|
|
95
69
|
}
|
|
96
70
|
|
|
97
|
-
# Launches the relay; on failure, a clear message and code 1 (this function does
|
|
98
|
-
# not change the state)
|
|
99
|
-
launch() {
|
|
100
|
-
local port="$1" network="$2" ip="$3" name output
|
|
101
|
-
name="$(relay_name "$port")"
|
|
102
|
-
if output="$(docker run -d --restart unless-stopped \
|
|
103
|
-
--name "$name" \
|
|
104
|
-
--label "devzone.instance=$INSTANCE" \
|
|
105
|
-
--label "devzone.port=$port" \
|
|
106
|
-
--network "$network" \
|
|
107
|
-
-p "127.0.0.1:$port:$port" \
|
|
108
|
-
"$SOCAT_IMAGE" \
|
|
109
|
-
"tcp-listen:$port,fork,reuseaddr" "tcp-connect:$ip:$port" 2>&1)"; then
|
|
110
|
-
return 0
|
|
111
|
-
fi
|
|
112
|
-
case "$output" in
|
|
113
|
-
*"port is already allocated"* | *"address already in use"*)
|
|
114
|
-
echo "devzone : port : port already in use on the workstation : $port" >&2
|
|
115
|
-
;;
|
|
116
|
-
*)
|
|
117
|
-
echo "devzone : port : relay on port $port failed : $output" >&2
|
|
118
|
-
;;
|
|
119
|
-
esac
|
|
120
|
-
return 1
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
open_port() {
|
|
124
|
-
local port="${1:-}"
|
|
125
|
-
validate_port "$port"
|
|
126
|
-
if relay_active "$port"; then
|
|
127
|
-
add_port "$port"
|
|
128
|
-
echo "✔ relay already open: 127.0.0.1:$port on the workstation → $port in the container"
|
|
129
|
-
return 0
|
|
130
|
-
fi
|
|
131
|
-
network_ip || refuse "devzone container not found: host Docker unreachable?"
|
|
132
|
-
docker rm -f "$(relay_name "$port")" >/dev/null 2>&1 || true
|
|
133
|
-
launch "$port" "$NETWORK" "$IP" || exit 1
|
|
134
|
-
add_port "$port"
|
|
135
|
-
echo "✔ 127.0.0.1:$port on the workstation → $port in the container (relay $(relay_name "$port"))"
|
|
136
|
-
}
|
|
137
|
-
|
|
138
71
|
close_port() {
|
|
139
72
|
local port="${1:-}"
|
|
140
73
|
validate_port "$port"
|
|
@@ -149,7 +82,7 @@ list_ports() {
|
|
|
149
82
|
local ports port mark app
|
|
150
83
|
ports="$(sort_ports "$(read_ports)")"
|
|
151
84
|
if [ -z "$ports" ]; then
|
|
152
|
-
echo "no relay
|
|
85
|
+
echo "no relay"
|
|
153
86
|
return 0
|
|
154
87
|
fi
|
|
155
88
|
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
@@ -166,14 +99,13 @@ list_ports() {
|
|
|
166
99
|
fi
|
|
167
100
|
printf ' %-5s %s %s\n' "$port" "$mark" "$app"
|
|
168
101
|
done
|
|
169
|
-
bash "$HERE/ports-auto.sh" list_auto 2>/dev/null || true
|
|
170
102
|
}
|
|
171
103
|
|
|
172
104
|
summary() {
|
|
173
105
|
local ports port output=""
|
|
174
106
|
ports="$(sort_ports "$(read_ports)")"
|
|
175
107
|
if [ -z "$ports" ]; then
|
|
176
|
-
echo "none
|
|
108
|
+
echo "none"
|
|
177
109
|
return 0
|
|
178
110
|
fi
|
|
179
111
|
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
@@ -187,28 +119,6 @@ summary() {
|
|
|
187
119
|
echo "$output"
|
|
188
120
|
}
|
|
189
121
|
|
|
190
|
-
restart_relays() {
|
|
191
|
-
local ports port rc=0
|
|
192
|
-
ports="$(sort_ports "$(read_ports)")"
|
|
193
|
-
[ -n "$ports" ] || return 0
|
|
194
|
-
if ! network_ip; then
|
|
195
|
-
echo "devzone : port : relays not restarted: devzone container not found (host Docker unreachable?)" >&2
|
|
196
|
-
return 1
|
|
197
|
-
fi
|
|
198
|
-
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
199
|
-
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
200
|
-
if ! port_valid "$port"; then
|
|
201
|
-
echo "devzone : port : invalid port in the state, ignored: $port" >&2
|
|
202
|
-
rc=1
|
|
203
|
-
continue
|
|
204
|
-
fi
|
|
205
|
-
# The container IP changes at each start: the relay is recreated
|
|
206
|
-
docker rm -f "$(relay_name "$port")" >/dev/null 2>&1 || true
|
|
207
|
-
launch "$port" "$NETWORK" "$IP" || rc=1
|
|
208
|
-
done
|
|
209
|
-
return "$rc"
|
|
210
|
-
}
|
|
211
|
-
|
|
212
122
|
# Machine-readable output of list: a JSON array [{port,active,application,auto}], jq only.
|
|
213
123
|
# shellcheck source=SCRIPTDIR/ports-json.sh
|
|
214
124
|
# shellcheck disable=SC1091
|
|
@@ -218,14 +128,8 @@ case "${1:-}" in
|
|
|
218
128
|
'' | list)
|
|
219
129
|
if [ "${2:-}" = "--json" ]; then list_json; else list_ports; fi
|
|
220
130
|
;;
|
|
221
|
-
open) open_port "${2:-}" ;;
|
|
222
131
|
close | --close) close_port "${2:-}" ;;
|
|
223
|
-
restart) restart_relays ;;
|
|
224
132
|
resume) summary ;;
|
|
225
|
-
|
|
226
|
-
exclude) bash "$HERE/ports-auto.sh" exclude "${2:-}" ;;
|
|
227
|
-
include) bash "$HERE/ports-auto.sh" include "${2:-}" ;;
|
|
228
|
-
-h | --help | aide) sed -n '2,8p' "$0" | sed 's/^# \{0,1\}//' ;;
|
|
229
|
-
*) open_port "$1" ;;
|
|
133
|
+
-h | --help) sed -n '2,8p' "$0" | sed 's/^# \{0,1\}//' ;;
|
|
230
134
|
esac
|
|
231
135
|
fi
|
|
@@ -41,8 +41,8 @@ refuse() {
|
|
|
41
41
|
action="${1:-}"
|
|
42
42
|
service="${2:-}"
|
|
43
43
|
case "$action" in
|
|
44
|
-
enable
|
|
45
|
-
disable
|
|
44
|
+
enable) action=enable ;;
|
|
45
|
+
disable) action=disable ;;
|
|
46
46
|
seed) ;;
|
|
47
47
|
*) refuse "usage: services-admin.sh enable|disable|seed gitlab|postgres|argocd [options]" ;;
|
|
48
48
|
esac
|
|
@@ -126,11 +126,11 @@ state_json() {
|
|
|
126
126
|
state_value="failed"
|
|
127
127
|
command_value="devzone apply"
|
|
128
128
|
elif [ "$m" = gitlab ]; then
|
|
129
|
-
if out="$(
|
|
129
|
+
if out="$(devzone gitlab status 2>/dev/null)"; then
|
|
130
130
|
state_value="$out"
|
|
131
131
|
else
|
|
132
132
|
state_value=""
|
|
133
|
-
add_error modules "gitlab
|
|
133
|
+
add_error modules "gitlab status unavailable"
|
|
134
134
|
fi
|
|
135
135
|
elif [ "$m" = postgres ] || [ "$m" = llm ]; then
|
|
136
136
|
if out="$(bash "$ICI/$m/$m.sh" status 2>/dev/null)"; then
|
|
@@ -140,14 +140,13 @@ state_json() {
|
|
|
140
140
|
add_error modules "$m.sh state unavailable"
|
|
141
141
|
fi
|
|
142
142
|
elif [ "$m" = argocd ]; then
|
|
143
|
-
if out="$(
|
|
143
|
+
if out="$("$ICI/devzone" argocd status 2>/dev/null)"; then
|
|
144
144
|
state_value="$out"
|
|
145
145
|
else
|
|
146
146
|
state_value=""
|
|
147
|
-
add_error modules "argocd.sh status unavailable"
|
|
148
147
|
fi
|
|
149
148
|
elif [ "$m" = mysql ]; then
|
|
150
|
-
if out="$(
|
|
149
|
+
if out="$(devzone mysql status 2>/dev/null)"; then
|
|
151
150
|
state_value="$out"
|
|
152
151
|
else
|
|
153
152
|
state_value=""
|
|
@@ -190,15 +189,6 @@ state_json() {
|
|
|
190
189
|
clusters_command="devzone use $host_ctx"
|
|
191
190
|
fi
|
|
192
191
|
|
|
193
|
-
# Limited account token (#845): renewed as soon as it is close to expiry,
|
|
194
|
-
# only outside the pod and with a services cluster chosen; a failed renewal
|
|
195
|
-
# becomes an alert with the repair command.
|
|
196
|
-
if ! in_pod && [ -n "$services_cluster" ] && ! account_token_fresh; then
|
|
197
|
-
if ! bash "$ICI/kube-account.sh" jeton >/dev/null 2>&1; then
|
|
198
|
-
append_alert limited_account_token "limited account token expired" "devzone repair"
|
|
199
|
-
fi
|
|
200
|
-
fi
|
|
201
|
-
|
|
202
192
|
devzone cluster clean --quiet >/dev/null 2>&1 || [ $? -ne 3 ] || append_alert cluster_disk "cluster disk almost full" "devzone repair"
|
|
203
193
|
if ports_out="$(bash "$ICI/ports.sh" list --json 2>/dev/null)"; then
|
|
204
194
|
if printf '%s' "$ports_out" | jq -e . >/dev/null 2>&1; then
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Single source for the repowarden version used by
|
|
2
|
-
REPOWARDEN_VERSION=4.18.
|
|
1
|
+
# Single source for the repowarden version used by workspace-init.sh and manage/scripts/ci/versions.sh.
|
|
2
|
+
REPOWARDEN_VERSION=4.18.1
|
|
3
3
|
|
|
4
4
|
# BuildKit client version installed in the workspace image (#514). Must match
|
|
5
5
|
# buildkit.image in charts/devzone-workspace/values.yaml.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Why:
|
|
3
|
-
# pod (#503). This script installs the devzone tools when the container starts.
|
|
2
|
+
# Why: this script installs the devzone tools in the workspace pod (#503).
|
|
4
3
|
# Each step logs one "devzone init:" line, and a failure never stops the next
|
|
5
4
|
# step. No Docker socket is used and no kubeconfig is fabricated.
|
|
6
5
|
set -uo pipefail
|
|
@@ -58,12 +57,6 @@ init_modules() {
|
|
|
58
57
|
fi
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
# Former French names renamed to English (#733). Idempotent: the script logs one
|
|
62
|
-
# line per rename, and a pair already renamed is left alone
|
|
63
|
-
init_legacy_names() {
|
|
64
|
-
bash "$HERE/rename-legacy-files.sh" || log "legacy names: not renamed"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
60
|
init_prompt() {
|
|
68
61
|
local bashrc="$HOME/.bashrc"
|
|
69
62
|
if ! touch "$bashrc" 2>/dev/null; then
|
|
@@ -93,7 +86,6 @@ PROMPT
|
|
|
93
86
|
|
|
94
87
|
init_safe_directory
|
|
95
88
|
init_repowarden
|
|
96
|
-
init_legacy_names
|
|
97
89
|
init_modules
|
|
98
90
|
init_prompt
|
|
99
91
|
log "done"
|