devzone 0.41.0 → 0.42.1

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.
Files changed (65) hide show
  1. package/.devcontainer/agent.sh +1 -1
  2. package/.devcontainer/argocd/apps.sh +2 -2
  3. package/.devcontainer/argocd/argocd.sh +22 -10
  4. package/.devcontainer/argocd/catalogue-argocd.sh +1 -0
  5. package/.devcontainer/argocd/services.sh +16 -0
  6. package/.devcontainer/catalogue/app.sh +22 -4
  7. package/.devcontainer/catalogue/catalogue-veilleur.sh +2 -2
  8. package/.devcontainer/catalogue/mysql/manifeste.yaml +4 -0
  9. package/.devcontainer/catalogue/mysql/mysql.sh +41 -28
  10. package/.devcontainer/catalogue/mysql/volume.sh +5 -5
  11. package/.devcontainer/catalogue.sh +29 -35
  12. package/.devcontainer/cluster.sh +11 -11
  13. package/.devcontainer/clusters.sh +1 -1
  14. package/.devcontainer/command-aliases.sh +152 -2
  15. package/.devcontainer/demarrage.sh +18 -15
  16. package/.devcontainer/devcontainer.json +1 -1
  17. package/.devcontainer/devzone +106 -118
  18. package/.devcontainer/docker-relais.sh +2 -2
  19. package/.devcontainer/docker-sans-hote.sh +1 -1
  20. package/.devcontainer/etat-json.sh +16 -16
  21. package/.devcontainer/etat.sh +4 -4
  22. package/.devcontainer/gitlab/gitlab.sh +24 -12
  23. package/.devcontainer/gitlab/installation.sh +9 -9
  24. package/.devcontainer/gitlab/secrets.sh +2 -2
  25. package/.devcontainer/gitlab/test-gitlab-restes.sh +16 -0
  26. package/.devcontainer/gitlab/test-gitlab.sh +14 -13
  27. package/.devcontainer/help.sh +40 -0
  28. package/.devcontainer/kube-compte.sh +2 -2
  29. package/.devcontainer/kube-config.sh +1 -1
  30. package/.devcontainer/kube-joignable.sh +2 -0
  31. package/.devcontainer/opencode.jsonc +1 -1
  32. package/.devcontainer/paquets.sh +31 -18
  33. package/.devcontainer/ports-auto.sh +6 -6
  34. package/.devcontainer/ports-json.sh +34 -0
  35. package/.devcontainer/ports.sh +34 -43
  36. package/.devcontainer/post-create.sh +3 -3
  37. package/.devcontainer/postgres/postgres.sh +42 -30
  38. package/.devcontainer/postgres/postgres.yaml +4 -0
  39. package/.devcontainer/services-admin.sh +1 -1
  40. package/.devcontainer/skills/devzone/SKILL.md +16 -16
  41. package/README.md +17 -17
  42. package/charts/devzone-mysql/templates/service.yaml +2 -0
  43. package/charts/devzone-mysql/templates/statefulset.yaml +2 -0
  44. package/charts/devzone-postgres/templates/service.yaml +3 -1
  45. package/charts/devzone-postgres/templates/statefulset.yaml +5 -3
  46. package/charts/devzone-postgres/values.yaml +6 -1
  47. package/charts/devzone-workspace/Chart.yaml +1 -1
  48. package/charts/devzone-workspace/templates/networkpolicy.yaml +4 -0
  49. package/charts/devzone-workspace/templates/role.yaml +4 -0
  50. package/charts/devzone-workspace/templates/rolebinding.yaml +4 -0
  51. package/charts/devzone-workspace/templates/service.yaml +4 -0
  52. package/charts/devzone-workspace/templates/serviceaccount.yaml +4 -0
  53. package/charts/devzone-workspace/templates/statefulset.yaml +4 -0
  54. package/manage/scripts/argocd-services-svc.sh +2 -0
  55. package/manage/scripts/argocd-services.sh +1 -0
  56. package/manage/scripts/argocd-workspace.sh +7 -1
  57. package/manage/scripts/check-charts.sh +158 -0
  58. package/manage/scripts/docker-workstation.sh +73 -0
  59. package/manage/scripts/kube-ready.sh +54 -10
  60. package/manage/scripts/lancer.sh +1 -1
  61. package/manage/scripts/migrer-retour.sh +1 -0
  62. package/manage/scripts/migrer.sh +6 -0
  63. package/manage/scripts/services-workspace.sh +1 -2
  64. package/manage/workspace.sh +4 -1
  65. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  apiVersion: v2
2
2
  name: devzone-workspace
3
- description: devzone development workstation in Kubernetes.
3
+ description: devzone development workstation in Kubernetes, held by Argo CD (#516)
4
4
  type: application
5
5
  version: 0.1.0
6
6
  appVersion: "0.1.0"
@@ -4,6 +4,10 @@ kind: NetworkPolicy
4
4
  metadata:
5
5
  name: {{ include "devzone-workspace.fullname" . }}
6
6
  namespace: {{ .Release.Namespace }}
7
+ labels:
8
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}
9
+ app.kubernetes.io/part-of: devzone
10
+ app.kubernetes.io/managed-by: devzone
7
11
  spec:
8
12
  podSelector: {}
9
13
  policyTypes:
@@ -3,6 +3,10 @@ kind: Role
3
3
  metadata:
4
4
  name: devzone-workspace
5
5
  namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}
8
+ app.kubernetes.io/part-of: devzone
9
+ app.kubernetes.io/managed-by: devzone
6
10
  # Rights of kubedock (0.23.0, read in its sources), limited to the namespace:
7
11
  # pods (create and delete the test containers, list and follow them),
8
12
  # pods/log, pods/exec and pods/portforward (logs, commands, ports), services and
@@ -3,6 +3,10 @@ kind: RoleBinding
3
3
  metadata:
4
4
  name: devzone-workspace
5
5
  namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}
8
+ app.kubernetes.io/part-of: devzone
9
+ app.kubernetes.io/managed-by: devzone
6
10
  subjects:
7
11
  - kind: ServiceAccount
8
12
  name: {{ include "devzone-workspace.serviceAccountName" . }}
@@ -3,6 +3,10 @@ kind: Service
3
3
  metadata:
4
4
  name: {{ include "devzone-workspace.fullname" . }}
5
5
  namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}
8
+ app.kubernetes.io/part-of: devzone
9
+ app.kubernetes.io/managed-by: devzone
6
10
  spec:
7
11
  clusterIP: None
8
12
  selector:
@@ -4,4 +4,8 @@ kind: ServiceAccount
4
4
  metadata:
5
5
  name: {{ include "devzone-workspace.serviceAccountName" . }}
6
6
  namespace: {{ .Release.Namespace }}
7
+ labels:
8
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}
9
+ app.kubernetes.io/part-of: devzone
10
+ app.kubernetes.io/managed-by: devzone
7
11
  {{- end -}}
@@ -3,6 +3,10 @@ kind: StatefulSet
3
3
  metadata:
4
4
  name: {{ include "devzone-workspace.fullname" . }}
5
5
  namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}
8
+ app.kubernetes.io/part-of: devzone
9
+ app.kubernetes.io/managed-by: devzone
6
10
  spec:
7
11
  serviceName: {{ include "devzone-workspace.fullname" . }}
8
12
  replicas: {{ .Values.replicaCount }}
@@ -81,6 +81,8 @@ services_argocd_toggle() {
81
81
  echo "✖ $svc through Argo CD takes no option (got: $*)" >&2
82
82
  return 1
83
83
  fi
84
+ # Before [services] is written: a refused chart leaves the state unchanged
85
+ chart_require "$svc" || return $?
84
86
  echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
85
87
  services_note "$svc" on
86
88
  services_reconcile
@@ -109,6 +109,7 @@ workspace_deploy() {
109
109
  params="image.tag=$tag"
110
110
  [ -z "$with_image" ] || params="$params image.repository=$repository"
111
111
  [ "$tag" != latest ] || params="$params image.pullPolicy=Always"
112
+ chart_require workspace || return $?
112
113
  # GitOps repository created or designated first, with its root Application
113
114
  gitops_init || return 1
114
115
  gitops_root || return 1
@@ -137,6 +137,7 @@ argocd_passwords_refresh() {
137
137
 
138
138
  # Installs Argo CD (pinned chart and values), idempotent (upgrade --install)
139
139
  argocd_install() {
140
+ chart_require argocd || return 2
140
141
  argocd_memory_ok || return 2
141
142
  echo "▶ Argo CD $ARGOCD_CHART_VERSION in $ARGOCD_NS (helm, up to ${ARGOCD_WAIT}s)…"
142
143
  ak create namespace "$ARGOCD_NS" --dry-run=client -o yaml | ak apply -f - >/dev/null
@@ -153,10 +154,15 @@ argocd_install() {
153
154
  }
154
155
 
155
156
  # Installs it when wanted and missing (workspace start); a refusal (memory)
156
- # is told and the start goes on with helm direct
157
+ # is told and the start goes on with helm direct. A cluster that does not
158
+ # answer is not "helm direct": the start has already stopped on it (#565)
157
159
  argocd_ensure() {
158
160
  argocd_wanted || return 0
159
161
  argocd_installed && return 0
162
+ if ! kube_ready_reason >/dev/null; then
163
+ echo "⚠ Argo CD not checked: the cluster does not answer (devzone workspace services enable argocd once it does)" >&2
164
+ return 0
165
+ fi
160
166
  argocd_install || echo "⚠ Argo CD not installed: the workspace is deployed with helm directly (devzone workspace services enable argocd to retry)" >&2
161
167
  return 0
162
168
  }
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env bash
2
+ # CI check of the convention of the devzone charts (#554), documented in the
3
+ # section "Charts de devzone" of manage/docs/reference.md. Each folder of
4
+ # charts/ is checked: its name, Chart.yaml, then its family, by its
5
+ # dependencies: a wrapper (Chart.lock, oci:// recommended) or a service
6
+ # (templates without a hard-coded namespace, Secret, Ingress or LoadBalancer,
7
+ # the three labels on each object; the common keys in values.yaml). Every
8
+ # charts/devzone-<x> named by the code must be a folder. helm lint and helm
9
+ # template run when helm is installed. A fault is printed as
10
+ # "✖ charts/<x> : <rule>" and the run exits 1; otherwise
11
+ # "✔ charts : N charts conformes". Tests: CHARTS_DIR, CHARTS_CODE_DIRS and
12
+ # CHARTS_NO_HELM=1. bash 3.2 (macOS).
13
+
14
+ set -u
15
+
16
+ ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ ROOT="$(cd "$ICI/../.." && pwd)"
18
+ CHARTS_DIR="${CHARTS_DIR:-$ROOT/charts}"
19
+ CHARTS_CODE_DIRS="${CHARTS_CODE_DIRS:-$ROOT/.devcontainer $ROOT/manage/scripts}"
20
+ # The workstation keeps its own values (per volume, not a shared service)
21
+ CHARTS_NO_COMMON="devzone-workspace"
22
+ COMMON_KEYS="image size memory port claim resources"
23
+ FAULTS=0
24
+ COUNT=0
25
+
26
+ fault() {
27
+ printf '✖ charts/%s : %s\n' "$1" "$2"
28
+ FAULTS=$((FAULTS + 1))
29
+ }
30
+
31
+ # Top-level key of Chart.yaml (file, key), quotes removed
32
+ chart_key() {
33
+ sed -n "s/^$2:[[:space:]]*//p" "$1" | head -1 |
34
+ sed -e 's/[[:space:]]*$//' -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'\$/\1/"
35
+ }
36
+
37
+ # Chart.yaml: name equal to the folder, type, version (semver), appVersion and
38
+ # description not empty
39
+ charts_check_chart_yaml() {
40
+ local f="$1/Chart.yaml" name="$2" re='^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.+-]*)?$'
41
+ [ "$(chart_key "$f" name)" = "$name" ] || fault "$name" "Chart.yaml name must be \"$name\""
42
+ [ "$(chart_key "$f" type)" = application ] || fault "$name" "Chart.yaml type must be application"
43
+ [[ "$(chart_key "$f" version)" =~ $re ]] || fault "$name" "Chart.yaml version must be semver"
44
+ [ -n "$(chart_key "$f" appVersion)" ] || fault "$name" "Chart.yaml appVersion must not be empty"
45
+ [ -n "$(chart_key "$f" description)" ] || fault "$name" "Chart.yaml description must not be empty"
46
+ }
47
+
48
+ # Wrapper: Chart.lock committed; a repository outside oci:// is a warning
49
+ charts_check_wrapper() {
50
+ local dir="$1" name="$2"
51
+ [ -f "$dir/Chart.lock" ] || fault "$name" "wrapper without Chart.lock (commit it)"
52
+ if grep -E '^[[:space:]]*repository:' "$dir/Chart.yaml" | grep -qv 'oci://'; then
53
+ echo "⚠ charts/$name : a dependency repository is not oci:// (recommended)"
54
+ fi
55
+ }
56
+
57
+ # Service: objects (a kind: line) with the labels, no hard-coded namespace,
58
+ # no Secret, no Ingress, no LoadBalancer
59
+ charts_check_templates() {
60
+ local dir="$1" name="$2" f rel label
61
+ for f in "$dir"/templates/*.yaml; do
62
+ [ -f "$f" ] || continue
63
+ rel="templates/$(basename "$f")"
64
+ if grep -E '^[[:space:]]*namespace:' "$f" | grep -qv 'Release\.Namespace'; then
65
+ fault "$name" "$rel: namespace must be {{ .Release.Namespace }}, not hard-coded"
66
+ fi
67
+ grep -Eq '^kind:[[:space:]]*Secret' "$f" && fault "$name" "$rel: no Secret in a chart (created apart)"
68
+ grep -Eq '^kind:[[:space:]]*Ingress' "$f" && fault "$name" "$rel: no Ingress in a chart"
69
+ grep -Eq 'type:[[:space:]]*LoadBalancer' "$f" && fault "$name" "$rel: no LoadBalancer in a chart"
70
+ grep -Eq '^kind:' "$f" || continue
71
+ for label in 'app.kubernetes.io/name:' 'app.kubernetes.io/part-of: devzone' 'app.kubernetes.io/managed-by: devzone'; do
72
+ grep -Fq "$label" "$f" || fault "$name" "$rel: label $label missing"
73
+ done
74
+ done
75
+ }
76
+
77
+ # Service: the common keys of values.yaml (the workstation is exempt)
78
+ charts_check_values() {
79
+ local dir="$1" name="$2" key
80
+ case " $CHARTS_NO_COMMON " in *" $name "*) return 0 ;; esac
81
+ for key in $COMMON_KEYS; do
82
+ grep -Eq "^$key:" "$dir/values.yaml" || fault "$name" "values.yaml lacks the common key $key"
83
+ done
84
+ }
85
+
86
+ # helm lint and template, on a copy: the wrapper gets its dependency built
87
+ # first, with an empty DOCKER_CONFIG (anonymous pull)
88
+ charts_check_helm() {
89
+ local dir="$1" name="$2" tmp conf
90
+ [ "${CHARTS_NO_HELM:-0}" = 1 ] && return 0
91
+ command -v helm >/dev/null 2>&1 || return 0
92
+ tmp="$(mktemp -d)" || return 0
93
+ conf="$(mktemp -d)"
94
+ cp -R "$dir" "$tmp/$name"
95
+ if grep -q '^dependencies:' "$dir/Chart.yaml"; then
96
+ DOCKER_CONFIG="$conf" helm dependency build "$tmp/$name" >"$tmp/log" 2>&1 ||
97
+ fault "$name" "helm dependency build fails: $(tail -1 "$tmp/log")"
98
+ fi
99
+ helm lint --quiet "$tmp/$name" >"$tmp/log" 2>&1 || fault "$name" "helm lint fails: $(tail -1 "$tmp/log")"
100
+ DOCKER_CONFIG="$conf" helm template "$name" "$tmp/$name" >/dev/null 2>"$tmp/log" ||
101
+ fault "$name" "helm template fails: $(tail -1 "$tmp/log")"
102
+ rm -rf "$tmp" "$conf"
103
+ }
104
+
105
+ # One folder of charts/
106
+ charts_check_dir() {
107
+ local dir="$1" name re='^devzone-[a-z0-9-]+$'
108
+ name="$(basename "$dir")"
109
+ COUNT=$((COUNT + 1))
110
+ [[ "$name" =~ $re ]] || fault "$name" "folder name must match devzone-[a-z0-9-]+"
111
+ if [ ! -f "$dir/Chart.yaml" ]; then
112
+ fault "$name" "Chart.yaml missing"
113
+ return 0
114
+ fi
115
+ [ -f "$dir/values.yaml" ] || fault "$name" "values.yaml missing"
116
+ charts_check_chart_yaml "$dir" "$name"
117
+ if grep -q '^dependencies:' "$dir/Chart.yaml"; then
118
+ charts_check_wrapper "$dir" "$name"
119
+ else
120
+ charts_check_templates "$dir" "$name"
121
+ charts_check_values "$dir" "$name"
122
+ fi
123
+ charts_check_helm "$dir" "$name"
124
+ }
125
+
126
+ # Each charts/devzone-<x> named by the code must be a folder of CHARTS_DIR;
127
+ # $svc or $app (variables) are not names and do not match
128
+ charts_check_references() {
129
+ local dir hits hit file name
130
+ for dir in $CHARTS_CODE_DIRS; do
131
+ [ -d "$dir" ] || continue
132
+ hits="$(grep -rnoE 'charts/devzone-[a-z0-9-]+' "$dir" 2>/dev/null)" || hits=""
133
+ while IFS= read -r hit; do
134
+ [ -n "$hit" ] || continue
135
+ file="${hit%%:*}"
136
+ name="${hit##*charts/}"
137
+ if [ ! -d "$CHARTS_DIR/$name" ]; then
138
+ fault "$name" "named in $file but the folder is absent"
139
+ fi
140
+ done <<EOF
141
+ $hits
142
+ EOF
143
+ done
144
+ }
145
+
146
+ if [ ! -d "$CHARTS_DIR" ]; then
147
+ echo "✖ charts : folder not found: $CHARTS_DIR"
148
+ exit 1
149
+ fi
150
+ for dir in "$CHARTS_DIR"/*/; do
151
+ [ -d "$dir" ] || continue
152
+ charts_check_dir "${dir%/}"
153
+ done
154
+ charts_check_references
155
+ if [ "$FAULTS" -ne 0 ]; then
156
+ exit 1
157
+ fi
158
+ echo "✔ charts : $COUNT charts conformes"
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ # Docker workstation put to sleep when the Kubernetes workspace takes over (#517).
3
+ # Sourced by migrer.sh (stop) and migrer-retour.sh (start). Containers of the
4
+ # workstation folder (label devcontainer.local_folder) and the automatic port
5
+ # relays of this instance (labels devzone.auto=true, devzone.instance) are
6
+ # stopped, never removed. Without Docker,
7
+ # only a warning: the migration does not fail for that.
8
+
9
+ # Docker answers on the workstation (command present and daemon running).
10
+ docker_workstation_ready() {
11
+ command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1
12
+ }
13
+
14
+ # Ids, one per line, of the containers of folder $1 and of the automatic relays
15
+ # of this instance (DEVZONE_VOLUMES, default devzone, as in desinstaller.sh): the
16
+ # relays of another devzone on the same machine are not touched.
17
+ # $2 is "running" (docker ps) or "exited" (stopped containers, docker ps -a).
18
+ docker_workstation_ids() {
19
+ local folder="$1" etat="$2" instance="${DEVZONE_VOLUMES:-devzone}"
20
+ if [ "$etat" = exited ]; then
21
+ {
22
+ docker ps -aq --filter "label=devcontainer.local_folder=$folder" --filter status=exited
23
+ docker ps -aq --filter "label=devzone.auto=true" --filter "label=devzone.instance=$instance" --filter status=exited
24
+ } 2>/dev/null | sort -u || true
25
+ else
26
+ {
27
+ docker ps -q --filter "label=devcontainer.local_folder=$folder"
28
+ docker ps -q --filter "label=devzone.auto=true" --filter "label=devzone.instance=$instance"
29
+ } 2>/dev/null | sort -u || true
30
+ fi
31
+ }
32
+
33
+ # Stops the running containers of folder $1 and the automatic relays (docker stop).
34
+ docker_workstation_stop() {
35
+ local ids
36
+ if ! docker_workstation_ready; then
37
+ echo " ⚠ Docker workstation: Docker does not respond, nothing stopped" >&2
38
+ return 0
39
+ fi
40
+ ids="$(docker_workstation_ids "$1" running)"
41
+ if [ -z "$ids" ]; then
42
+ echo " – Docker workstation: no running container"
43
+ return 0
44
+ fi
45
+ # shellcheck disable=SC2086
46
+ if docker stop $ids >/dev/null 2>&1; then
47
+ echo " ✔ Docker workstation stopped (kept: devzone workspace revert restarts it)"
48
+ else
49
+ echo " ⚠ Docker workstation: some containers could not be stopped" >&2
50
+ fi
51
+ return 0
52
+ }
53
+
54
+ # Starts again the stopped containers of folder $1 and the automatic relays (docker start).
55
+ docker_workstation_start() {
56
+ local ids
57
+ if ! docker_workstation_ready; then
58
+ echo " ⚠ Docker workstation: Docker does not respond, nothing started" >&2
59
+ return 0
60
+ fi
61
+ ids="$(docker_workstation_ids "$1" exited)"
62
+ if [ -z "$ids" ]; then
63
+ echo " – Docker workstation: no stopped container to start"
64
+ return 0
65
+ fi
66
+ # shellcheck disable=SC2086
67
+ if docker start $ids >/dev/null 2>&1; then
68
+ echo " ✔ Docker workstation started again"
69
+ else
70
+ echo " ⚠ Docker workstation: some containers could not be started" >&2
71
+ fi
72
+ return 0
73
+ }
@@ -1,31 +1,75 @@
1
1
  #!/usr/bin/env bash
2
- # Shared check of the Kubernetes cluster (#497), sourced by poste.sh (and by
3
- # create-mode.sh at creation). Sourced only: no code at file level.
4
- # Compatible with bash 3.2 (macOS) and Linux.
2
+ # Shared check of the Kubernetes cluster (#497, #565), sourced by poste.sh,
3
+ # create-mode.sh (creation) and workspace.sh (workspace start). Sourced only:
4
+ # no code at file level. Compatible with bash 3.2 (macOS) and Linux.
5
5
 
6
6
  # Returns 0 when kubectl and helm are present and the cluster answers within 5 s
7
7
  # (context devzone if declared, otherwise the current context). Otherwise
8
8
  # prints one short line on stdout (kubectl missing, helm missing, or
9
- # cluster <context> unreachable (<server>)) and returns 1.
9
+ # cluster <context> unreachable (<server>)) and returns 1. With --hint, prints
10
+ # the message for the user instead (#565, see kube_unreachable_hint).
10
11
  kube_ready_reason() {
11
- local context server
12
+ local context server hint=no
13
+ [ "${1:-}" = --hint ] && hint=yes
12
14
  command -v kubectl >/dev/null 2>&1 || {
13
- echo "kubectl missing"
15
+ kube_say "kubectl missing" "$hint"
14
16
  return 1
15
17
  }
16
18
  command -v helm >/dev/null 2>&1 || {
17
- echo "helm missing"
19
+ kube_say "helm missing" "$hint"
18
20
  return 1
19
21
  }
20
22
  if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
21
23
  kubectl cluster-info --request-timeout=5s --context devzone >/dev/null 2>&1 && return 0
22
24
  context=devzone
23
- server="$(kubectl config view --minify --context devzone -o 'jsonpath={.clusters[0].server}' 2>/dev/null || true)"
25
+ server="$(kubectl config view --minify --context devzone -o 'jsonpath={.clusters[0].cluster.server}' 2>/dev/null || true)"
24
26
  else
25
27
  kubectl cluster-info --request-timeout=5s >/dev/null 2>&1 && return 0
26
28
  context="$(kubectl config current-context 2>/dev/null || true)"
27
- server="$(kubectl config view --minify -o 'jsonpath={.clusters[0].server}' 2>/dev/null || true)"
29
+ server="$(kubectl config view --minify -o 'jsonpath={.clusters[0].cluster.server}' 2>/dev/null || true)"
30
+ fi
31
+ if [ "$hint" = yes ]; then
32
+ kube_unreachable_hint "${context:-none}" "${server:-unknown server}"
33
+ else
34
+ echo "cluster ${context:-none} unreachable (${server:-unknown server})"
28
35
  fi
29
- echo "cluster ${context:-none} unreachable (${server:-unknown server})"
30
36
  return 1
31
37
  }
38
+
39
+ # One reason line: as is, or as a ✖ line for the user (--hint).
40
+ kube_say() {
41
+ if [ "$2" = yes ]; then
42
+ echo "✖ $1"
43
+ else
44
+ echo "$1"
45
+ fi
46
+ }
47
+
48
+ # Cluster name of a context (empty when unknown).
49
+ kube_context_cluster() {
50
+ kubectl config view --minify --context "$1" -o 'jsonpath={.clusters[0].name}' 2>/dev/null || true
51
+ }
52
+
53
+ # Message of an unreachable cluster <context> at <server> (#565). The cluster of
54
+ # Docker Desktop (context docker-desktop, or a local server 127.0.0.1 or
55
+ # localhost of a cluster named docker-desktop) runs inside Docker Desktop: when
56
+ # docker info fails, the cause is Docker Desktop stopped; when Docker answers,
57
+ # Kubernetes is disabled in it. Any other context gets the generic message.
58
+ kube_unreachable_hint() {
59
+ local context="$1" server="$2" cluster host
60
+ cluster="$(kube_context_cluster "$context")"
61
+ host="${server#*://}"
62
+ host="${host%%[:/]*}"
63
+ if [ "$context" = docker-desktop ] ||
64
+ { [ "$cluster" = docker-desktop ] && { [ "$host" = 127.0.0.1 ] || [ "$host" = localhost ]; }; }; then
65
+ if ! docker info >/dev/null 2>&1; then
66
+ echo "✖ Docker Desktop is stopped: the Kubernetes cluster of this machine runs inside it. Start Docker Desktop, then: make shell"
67
+ echo " Tip: Settings → General → Start Docker Desktop when you sign in"
68
+ else
69
+ echo "✖ Kubernetes cluster $context unreachable ($server): enable Kubernetes in Docker Desktop (Settings → Kubernetes) or check kubectl config get-contexts"
70
+ fi
71
+ return 0
72
+ fi
73
+ echo "✖ Kubernetes cluster $context unreachable ($server)"
74
+ echo " Check the contexts: kubectl config get-contexts"
75
+ }
@@ -97,7 +97,7 @@ show_steps() {
97
97
  *"Start: Run: docker run"*) announce container "Creating container" ;;
98
98
  *"Running the postCreateCommand"*) announce postcreate "Installing in container (repowarden, modules)" ;;
99
99
  *"Running the postStartCommand"*) announce poststart "Starting (git identity, clusters, state)" ;;
100
- "devzone ready"* | "devzone started"* | "devzone rebuilt"* | "devzone : "* | " ✔ "* | " ✖ "* | " ○ "* | " ⚠ "* | " "[!\ ]* | "git-identite : "* | "kube-config : "* | "metrics-server : "*)
100
+ "devzone ready"* | "devzone started"* | "devzone rebuilt"* | "devzone : "* | "devzone: "* | " ✔ "* | " ✖ "* | " ○ "* | " ⚠ "* | " "[!\ ]* | "git-identite : "* | "kube-config : "* | "metrics-server : "*)
101
101
  echo " $line"
102
102
  last_announce="$(date +%s)"
103
103
  ;;
@@ -50,6 +50,7 @@ revert_workspace() {
50
50
  done <<<"$list"
51
51
  fi
52
52
  record_workspace docker || { fail "cannot write .devzone.modules"; return 1; }
53
+ docker_workstation_start "$PWD"
53
54
  echo "✔ workspace=docker: Docker workstation and its volumes are intact. Start it again: make shell"
54
55
  }
55
56
 
@@ -4,6 +4,10 @@
4
4
  # kubectl_flag, copy_to and copy_from. Nothing is ever deleted except by
5
5
  # clean-docker, after confirmation. Run from the devzone workstation folder.
6
6
 
7
+ # Docker workstation sleep on migrate (stop here, start in migrer-retour.sh).
8
+ # shellcheck source=manage/scripts/docker-workstation.sh
9
+ . "$(dirname "${BASH_SOURCE[0]}")/docker-workstation.sh"
10
+
7
11
  # vscode home in the pod and image used to copy Docker volumes.
8
12
  POD_HOME="/home/vscode"
9
13
  COPY_IMAGE="${DEVZONE_IMAGE_COPIE:-busybox:1.36}"
@@ -192,9 +196,11 @@ record_workspace() {
192
196
  }
193
197
 
194
198
  # Step 5: switch, workspace=kubernetes recorded on workstation; nothing is deleted.
199
+ # The Docker workstation containers and port relays are stopped, not removed (#517).
195
200
  step_switch() {
196
201
  echo "▶ [5/5] switch: workspace=kubernetes in .devzone.modules"
197
202
  record_workspace kubernetes || { fail "cannot write .devzone.modules"; return 1; }
203
+ docker_workstation_stop "$PWD"
198
204
  echo " ✔ done; Docker workstation and its volumes are intact (rollback: devzone workspace revert)"
199
205
  }
200
206
 
@@ -125,8 +125,7 @@ services_run() {
125
125
  return 1
126
126
  fi
127
127
  echo "▶ $action $service in the pod $POD…"
128
- # The installer of the pod still spells --oui (#510): --yes translated
129
- set -- "${@/--yes/--oui}"
128
+ # The installer of the pod takes --yes (#557) : no translation, no warning
130
129
  # shellcheck disable=SC2046
131
130
  printf '%s\n' "$token" | kubectl $(drapeau_kubectl) exec -i "$POD" --namespace "$NAMESPACE" \
132
131
  -c workspace -- bash "$SERVICES_ADMIN_SCRIPT" "$action" "$service" "$@" || code=$?
@@ -48,9 +48,10 @@ default_image_tag() {
48
48
  fi
49
49
  }
50
50
 
51
- # Installs or upgrades the workspace in the cluster.
51
+ # Installs or upgrades the workspace in the cluster; the cluster is checked first (#565): no Argo CD, helm or pod wait for a stopped one.
52
52
  start_workspace() {
53
53
  local repo tag image with_image="" args=()
54
+ kube_ready_reason --hint >&2 || return 1
54
55
  repo="$IMAGE_REPO"
55
56
  tag="$(default_image_tag)"
56
57
  while [ $# -gt 0 ]; do
@@ -172,6 +173,8 @@ copy_from() {
172
173
  # French names of the command and compatibility aliases (lot 3, #508)
173
174
  # shellcheck source=manage/scripts/workspace-aliases.sh
174
175
  . "$HERE/scripts/workspace-aliases.sh"
176
+ # shellcheck source=manage/scripts/kube-ready.sh
177
+ . "$HERE/scripts/kube-ready.sh"
175
178
  # shellcheck source=manage/scripts/workspace-wait.sh
176
179
  . "$HERE/scripts/workspace-wait.sh"
177
180
  # shellcheck source=manage/scripts/workspace-clone.sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "0.41.0",
3
+ "version": "0.42.1",
4
4
  "description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {