devzone 0.37.0 → 0.39.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.
Files changed (38) hide show
  1. package/.devcontainer/.dockerignore +1 -1
  2. package/.devcontainer/argocd/argocd.sh +6 -7
  3. package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
  4. package/.devcontainer/argocd/gitops.sh +18 -0
  5. package/.devcontainer/argocd/services.sh +138 -0
  6. package/.devcontainer/catalogue/app.sh +58 -17
  7. package/.devcontainer/catalogue/mysql/installer.sh +31 -0
  8. package/.devcontainer/catalogue/mysql/mysql.sh +12 -0
  9. package/.devcontainer/devzone +17 -2
  10. package/.devcontainer/etat-json.sh +5 -1
  11. package/.devcontainer/password.sh +8 -0
  12. package/README.md +7 -1
  13. package/charts/devzone-argocd/Chart.lock +6 -0
  14. package/charts/devzone-argocd/Chart.yaml +13 -0
  15. package/charts/devzone-argocd/values.yaml +28 -0
  16. package/charts/devzone-mysql/Chart.yaml +6 -0
  17. package/charts/devzone-mysql/templates/service.yaml +15 -0
  18. package/charts/devzone-mysql/templates/statefulset.yaml +55 -0
  19. package/charts/devzone-mysql/values.yaml +19 -0
  20. package/manage/devzone +83 -4
  21. package/manage/scripts/argocd-services-svc.sh +110 -0
  22. package/manage/scripts/argocd-services.sh +21 -85
  23. package/manage/scripts/argocd-workspace.sh +8 -6
  24. package/manage/scripts/ci-dns.sh +10 -10
  25. package/manage/scripts/desinstaller.sh +150 -136
  26. package/manage/scripts/docker.sh +26 -22
  27. package/manage/scripts/lancer.sh +103 -103
  28. package/manage/scripts/migrer-retour.sh +37 -34
  29. package/manage/scripts/migrer.sh +154 -138
  30. package/manage/scripts/ports-workspace.sh +87 -82
  31. package/manage/scripts/poste.sh +48 -49
  32. package/manage/scripts/services-workspace.sh +15 -10
  33. package/manage/scripts/versions.sh +88 -88
  34. package/manage/scripts/workspace-aliases.sh +47 -0
  35. package/manage/scripts/workspace-wait.sh +26 -23
  36. package/manage/workspace.sh +124 -111
  37. package/package.json +1 -1
  38. package/.devcontainer/argocd/values.yaml +0 -25
@@ -0,0 +1,28 @@
1
+ # Values of the Argo CD of devzone (#411), once the content of
2
+ # .devcontainer/argocd/values.yaml, moved under the argo-cd key of the
3
+ # wrapper (#538). Argo CD minimal: one replica per component, without Dex nor
4
+ # notifications, server in ClusterIP (no Ingress, no LoadBalancer). The access
5
+ # goes through the kubectl port-forward relay of the container (8443:443).
6
+ argo-cd:
7
+ global:
8
+ domain: ""
9
+ # Aggregate ClusterRoles (#516): the Application resources join the edit role,
10
+ # so the limited devzone account (#430) manages the Applications of the
11
+ # projects in devzone-argocd (devzone argocd app ...)
12
+ createAggregateRoles: true
13
+ dex:
14
+ enabled: false
15
+ notifications:
16
+ enabled: false
17
+ server:
18
+ replicas: 1
19
+ service:
20
+ type: ClusterIP
21
+ ingress:
22
+ enabled: false
23
+ controller:
24
+ replicas: 1
25
+ repoServer:
26
+ replicas: 1
27
+ applicationSet:
28
+ replicas: 1
@@ -0,0 +1,6 @@
1
+ apiVersion: v2
2
+ name: devzone-mysql
3
+ description: Shared MySQL of devzone, one database per project (#414), deployed by Argo CD (#538)
4
+ type: application
5
+ version: 0.1.0
6
+ appVersion: "8.4"
@@ -0,0 +1,15 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: {{ .Values.name }}
5
+ namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app: {{ .Values.name }}
8
+ app.kubernetes.io/managed-by: devzone
9
+ spec:
10
+ selector:
11
+ app: {{ .Values.name }}
12
+ ports:
13
+ - name: {{ .Values.name }}
14
+ port: {{ .Values.port }}
15
+ targetPort: 3306
@@ -0,0 +1,55 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: {{ .Values.name }}
5
+ namespace: {{ .Release.Namespace }}
6
+ labels:
7
+ app: {{ .Values.name }}
8
+ app.kubernetes.io/managed-by: devzone
9
+ spec:
10
+ serviceName: {{ .Values.name }}
11
+ replicas: 1
12
+ selector:
13
+ matchLabels:
14
+ app: {{ .Values.name }}
15
+ template:
16
+ metadata:
17
+ labels:
18
+ app: {{ .Values.name }}
19
+ app.kubernetes.io/managed-by: devzone
20
+ spec:
21
+ containers:
22
+ - name: {{ .Values.name }}
23
+ # Pinned version: update it here (same major: data kept)
24
+ image: {{ .Values.image }}
25
+ env:
26
+ - name: MYSQL_ROOT_PASSWORD
27
+ valueFrom:
28
+ secretKeyRef:
29
+ name: {{ .Values.name }}-admin
30
+ key: password
31
+ ports:
32
+ - containerPort: 3306
33
+ name: {{ .Values.name }}
34
+ readinessProbe:
35
+ exec:
36
+ command: ["/bin/sh", "-c", "mysql -uroot -p\"$MYSQL_ROOT_PASSWORD\" -e 'SELECT 1'"]
37
+ initialDelaySeconds: 10
38
+ periodSeconds: 5
39
+ resources:
40
+ requests:
41
+ cpu: {{ .Values.resources.requests.cpu }}
42
+ memory: {{ .Values.memory }}
43
+ volumeMounts:
44
+ - name: {{ .Values.claim }}
45
+ mountPath: /var/lib/mysql
46
+ volumeClaimTemplates:
47
+ - metadata:
48
+ name: {{ .Values.claim }}
49
+ labels:
50
+ app.kubernetes.io/managed-by: devzone
51
+ spec:
52
+ accessModes: ["ReadWriteOnce"]
53
+ resources:
54
+ requests:
55
+ storage: {{ .Values.size }}
@@ -0,0 +1,19 @@
1
+ # Same objects as .devcontainer/catalogue/mysql/manifeste.yaml, the helm-direct
2
+ # path of the catalogue (#414): manage/test/chart-mysql.bats checks that both
3
+ # renderings agree. The secret <name>-admin (root password) is created apart by
4
+ # devzone, never by the chart (#538: secrets out of Git).
5
+ # Name of the application (Service, StatefulSet and secret ref): mysql of the
6
+ # catalogue by default.
7
+ name: mysql
8
+ image: mysql:8.4
9
+ # Port of the Service (the container always listens on 3306)
10
+ port: 3306
11
+ # Memory request (MYSQL_MEMOIRE of the catalogue)
12
+ memory: 1Gi
13
+ # Size of the data volume (MYSQL_TAILLE of the catalogue)
14
+ size: 5Gi
15
+ # Name of the volume claim template (chosen among the existing PVCs, #440)
16
+ claim: donnees
17
+ resources:
18
+ requests:
19
+ cpu: 100m
package/manage/devzone CHANGED
@@ -32,6 +32,7 @@ LIGNES_GITIGNORE=(
32
32
  '.password'
33
33
  '.devzone.sauvegarde/'
34
34
  '.devcontainer/sans-docker-hote/'
35
+ '.devcontainer/without-host-docker/'
35
36
  )
36
37
 
37
38
  version() {
@@ -420,7 +421,9 @@ aide() {
420
421
  cat <<EOF
421
422
  devzone $(version) : environnement de développement conteneurisé
422
423
 
423
- devzone <dossier> crée un devzone dans <dossier> puis le lance (make up)
424
+ devzone <dossier> [--gitops github|none|<url>]
425
+ crée un devzone dans <dossier> puis le lance (make up) ;
426
+ GitOps repository for Argo CD: github, or a URL, or none
424
427
  devzone update [--oui] [--sans-reconstruire]
425
428
  dans un dossier devzone : passe à la version du paquet
426
429
  (sauvegarde les fichiers remplacés, propose make rebuild)
@@ -438,12 +441,54 @@ devzone $(version) : environnement de développement conteneurisé
438
441
  EOF
439
442
  }
440
443
 
444
+ gitops_saisir() {
445
+ # GitOps repository of Argo CD for the creation (#539): github, an
446
+ # existing URL, or none. Asked in a terminal (default: github when gh is
447
+ # connected), or none with a notice without one (the --gitops option names
448
+ # the choice).
449
+ local reponse defaut=""
450
+ if gh auth status >/dev/null 2>&1; then
451
+ defaut="github"
452
+ fi
453
+ printf 'GitOps repository for Argo CD? [G]itHub (created under your gh account at first start) / a URL / [n]one : ' >&2
454
+ read -r reponse || reponse=""
455
+ reponse="${reponse:-$defaut}"
456
+ case "$reponse" in
457
+ G | g | GitHub | github | Oui | oui | OUI) echo "github" ;;
458
+ n | N | none | None | Non | non | NON | aucun | Aucun) echo "none" ;;
459
+ *) echo "$reponse" ;;
460
+ esac
461
+ }
462
+
441
463
  creer() {
442
- local cible="$1"
464
+ local cible="$1" gitops="" expect="" arg valeur login nom instance
465
+ shift
466
+ for arg in "$@"; do
467
+ if [ "$expect" = gitops ]; then gitops="$arg"; expect=""; continue; fi
468
+ case "$arg" in
469
+ --gitops) expect=gitops ;;
470
+ --gitops=*) gitops="${arg#--gitops=}" ;;
471
+ *) echo "✖ option inconnue : $arg (devzone <dossier> [--gitops github|none|<url>])" >&2; exit 1 ;;
472
+ esac
473
+ done
474
+ if [ -n "$expect" ]; then
475
+ echo "✖ --gitops attend une valeur (github, none or a URL)" >&2
476
+ exit 1
477
+ fi
478
+
443
479
  if [ -e "$cible" ] && [ -n "$(ls -A "$cible" 2>/dev/null)" ]; then
444
480
  echo "✖ $cible existe et n'est pas vide : rien n'est écrasé. Choisis un autre dossier." >&2
445
481
  exit 1
446
482
  fi
483
+
484
+ if [ -z "$gitops" ]; then
485
+ if [ -t 0 ]; then
486
+ gitops="$(gitops_saisir)"
487
+ else
488
+ echo "⚠ no GitOps repository for Argo CD: pass --gitops <github|none|https://github.com/<login>/<name>.git> to create a devzone without a terminal; using none" >&2
489
+ gitops="none"
490
+ fi
491
+ fi
447
492
  mkdir -p "$cible/workspace" "$cible/manage"
448
493
  cp -R "${FICHIERS[@]/#/$PAQUET/}" "$cible/"
449
494
  cp -R "$PAQUET/manage/scripts" "$cible/manage/"
@@ -452,6 +497,40 @@ creer() {
452
497
  : >"$cible/.gitignore"
453
498
  completer_gitignore "$cible"
454
499
  chmod +x "$cible/manage/scripts/desinstaller.sh" "$cible/manage/scripts/lancer.sh"
500
+ # The GitOps repository of the new devzone (#539): github, an existing URL,
501
+ # or none, written in the .argocd.conf of the new devzone (conf.sh writes
502
+ # the header of the file when absent)
503
+ . "$PAQUET/.devcontainer/argocd/conf.sh"
504
+ # shellcheck disable=SC2034 # read by conf.sh
505
+ ARGOCD_CONF="$cible/.argocd.conf"
506
+ if [ "$gitops" = github ]; then
507
+ if ! gh auth status >/dev/null 2>&1; then
508
+ echo "⚠ GitHub not connected (gh auth login): no GitOps repository, the Applications are applied directly; pass --gitops none" >&2
509
+ valeur="none"
510
+ else
511
+ login="$(gh api user --jq .login 2>/dev/null)" || login=""
512
+ if [ -z "$login" ]; then
513
+ echo "⚠ GitHub login unreadable (gh api user): no GitOps repository, the Applications are applied directly; pass --gitops none" >&2
514
+ valeur="none"
515
+ else
516
+ nom="${DEVZONE_GITOPS_REPO_NAME:-devzone-argocd}"
517
+ instance="${DEVZONE_VOLUMES:-devzone}"
518
+ if [ "$instance" != "devzone" ]; then
519
+ nom="$nom-$instance"
520
+ fi
521
+ valeur="https://github.com/$login/$nom.git"
522
+ fi
523
+ fi
524
+ elif [ "$gitops" = none ]; then
525
+ valeur="none"
526
+ else
527
+ valeur="$gitops"
528
+ fi
529
+ conf_set argocd "repo=$valeur"
530
+ case "$valeur" in
531
+ none) echo "✔ no GitOps repository: the Applications are applied directly (devzone workspace argocd init to change)" ;;
532
+ *) echo "✔ GitOps repository: $valeur ($cible/.argocd.conf)" ;;
533
+ esac
455
534
  cible="$(cd "$cible" && pwd)"
456
535
  ecrire_manifeste "$cible"
457
536
  echo "✔ devzone $(version) créé dans $cible"
@@ -462,7 +541,7 @@ creer() {
462
541
  # Docker d'abord : le dossier reste prêt, à lancer une fois Docker démarré
463
542
  # shellcheck source=SCRIPTDIR/scripts/docker.sh
464
543
  . "$PAQUET/manage/scripts/docker.sh"
465
- if ! docker_pret "cd $cible && make shell"; then
544
+ if ! docker_ready "cd $cible && make shell"; then
466
545
  echo " Le dossier est prêt : rien à refaire, sauf ce lancement." >&2
467
546
  exit 1
468
547
  fi
@@ -542,6 +621,6 @@ case "${1:-}" in
542
621
  echo "✖ devzone $1 : commande du conteneur ; lance-la dans devzone (make shell), ou choisis un autre nom de dossier" >&2
543
622
  exit 2
544
623
  fi
545
- creer "$1"
624
+ creer "$1" "${@:2}"
546
625
  ;;
547
626
  esac
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env bash
2
+ # Service hooks of the workstation for services.sh (#538): secrets created
3
+ # apart (postgres-admin, mysql-admin, mirrored and never printed), Helm
4
+ # parameters of the mysql chart (existing volume claim), and the
5
+ # devzone workspace services enable|disable switch when Argo CD holds the
6
+ # charts. Sourced by manage/scripts/argocd-services.sh. bash 3.2 (macOS).
7
+
8
+ # Namespace of the service: labelled, isolated like the other devzone-*
9
+ # (services.sh: services_namespace_prepare)
10
+
11
+ # Superuser secret postgres-admin, created apart: an existing secret is kept
12
+ # and mirrored; otherwise a password generated on the workstation. Mirror
13
+ # workspace/.postgres/admin-password (600) and .password; never printed
14
+ services_secret_postgres() {
15
+ local dir="$PWD/workspace/.postgres" file password
16
+ file="$dir/admin-password"
17
+ mkdir -p "$dir"
18
+ chmod 700 "$dir"
19
+ password="$(ak -n "$POSTGRES_NS" get secret postgres-admin \
20
+ -o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
21
+ if [ -n "$password" ]; then
22
+ (umask 077 && printf '%s' "$password" >"$file")
23
+ else
24
+ if [ ! -s "$file" ]; then
25
+ (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$file")
26
+ fi
27
+ ak -n "$POSTGRES_NS" create secret generic postgres-admin --from-file=password="$file" >/dev/null
28
+ fi
29
+ chmod 600 "$file"
30
+ argocd_passwords_refresh
31
+ }
32
+
33
+ # Superuser secret mysql-admin, created apart, the same way; the mirror
34
+ # workspace/.mysql/admin-password feeds the mysql entry of .password
35
+ services_secret_mysql() {
36
+ local dir="$PWD/workspace/.mysql" file password
37
+ file="$dir/admin-password"
38
+ mkdir -p "$dir"
39
+ chmod 700 "$dir"
40
+ password="$(ak -n "$MYSQL_NS" get secret mysql-admin \
41
+ -o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
42
+ if [ -n "$password" ]; then
43
+ (umask 077 && printf '%s' "$password" >"$file")
44
+ else
45
+ if [ ! -s "$file" ]; then
46
+ (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$file")
47
+ fi
48
+ ak -n "$MYSQL_NS" create secret generic mysql-admin --from-file=password="$file" >/dev/null
49
+ fi
50
+ chmod 600 "$file"
51
+ argocd_passwords_refresh
52
+ }
53
+
54
+ # Values of the MySQL chart: image, port, memory and size (catalogue defaults),
55
+ # and the claim to mount chosen among the existing volumes (one PVC *-mysql-0:
56
+ # its prefix; none: the chart default donnees; several: refused)
57
+ services_chart_mysql() {
58
+ local liste claim=""
59
+ liste="$(ak -n "$MYSQL_NS" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null | grep -E '\-mysql-0$' || true)"
60
+ if [ -n "$liste" ]; then
61
+ if [ "$(printf '%s\n' "$liste" | grep -c .)" -gt 1 ]; then
62
+ echo "✖ several MySQL volumes in $MYSQL_NS: devzone mysql volume <name> picks the mounted one" >&2
63
+ return 2
64
+ fi
65
+ claim=" claim=${liste%-mysql-0}"
66
+ fi
67
+ printf 'image=mysql:8.4 port=3306 memory=1Gi size=5Gi%s' "$claim"
68
+ }
69
+
70
+ # devzone workspace services enable|disable postgres|mysql when Argo CD holds
71
+ # the charts: the [services] section written, then reconciled (services.sh).
72
+ # disable keeps the namespace, the volumes and the data; --yes is the explicit
73
+ # data removal (namespace deleted; the mirror workspace/.mysql stays, like
74
+ # supprimer-donnees of the module, the one of .postgres goes)
75
+ services_argocd_toggle() {
76
+ local svc="$1" action="$2" yes
77
+ shift 2
78
+ case "$action" in
79
+ enable)
80
+ if [ "$#" -ne 0 ]; then
81
+ echo "✖ $svc through Argo CD takes no option (got: $*)" >&2
82
+ return 1
83
+ fi
84
+ echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
85
+ services_note "$svc" on
86
+ services_reconcile
87
+ echo "✔ Application devzone-$svc declared ([services] $svc = on in $ARGOCD_CONF); status: devzone workspace argocd status; local access: devzone workspace ports"
88
+ ;;
89
+ disable)
90
+ yes="$(yes_flag "services disable $svc [--yes]" "$@")" || return 1
91
+ services_note "$svc" off
92
+ services_reconcile
93
+ if [ "$yes" = 1 ]; then
94
+ ak delete namespace "devzone-$svc" --wait=true --ignore-not-found >/dev/null
95
+ case "$svc" in
96
+ postgres) rm -rf "$PWD/workspace/.$svc" ;;
97
+ esac
98
+ argocd_passwords_refresh
99
+ echo "✔ $svc removed: Application, namespace devzone-$svc and data ([services] $svc = off)"
100
+ else
101
+ echo "✔ $svc stopped: Application removed, the namespace devzone-$svc, the volumes and the data stay (devzone workspace services disable $svc --yes to remove the data)"
102
+ fi
103
+ ;;
104
+ esac
105
+ }
106
+
107
+ # Toggles postgres on/off as an Argo CD Application (charts/devzone-postgres).
108
+ # Calls services_argocd_toggle to write the [services] section and reconcile.
109
+ postgres_argocd() { services_argocd_toggle postgres "$@"; }
110
+
@@ -1,18 +1,26 @@
1
1
  #!/usr/bin/env bash
2
2
  # Deployments held by Argo CD in the Kubernetes workspace (#516), sourced by
3
3
  # manage/workspace.sh after argocd-workspace.sh: the workspace itself, the
4
- # postgres service, the argocd services switch and devzone workspace argocd.
4
+ # services of the [services] section (services.sh), the argocd services
5
+ # switch and devzone workspace argocd.
5
6
  # workspace_deploy <repository> <tag> <with-image> start: Application, else helm direct
6
7
  # workspace_undeploy stop: Application, else helm uninstall
7
8
  # argocd_toggle enable|disable devzone workspace services … argocd
8
- # postgres_argocd enable|disable [--yes] postgres as an Application
9
+ # services_secret_postgres postgres secret created apart
10
+ # postgres_argocd enable|disable [--yes] postgres: [services] written, then reconciled
9
11
  # argocd_cmd status | init | apply | app add|list|remove devzone workspace argocd …
10
12
  # Secrets stay out of Git: created here, only referenced by the charts.
11
13
  # bash 3.2 (macOS).
12
14
 
13
15
  WORKSPACE_APP="devzone-workspace"
14
- POSTGRES_APP="devzone-postgres"
16
+ # shellcheck disable=SC2034 # read by argocd-services-svc.sh
15
17
  POSTGRES_NS="devzone-postgres"
18
+ # shellcheck disable=SC2034 # read by argocd-services-svc.sh
19
+ MYSQL_NS="devzone-mysql"
20
+ # Services held by Argo CD ([services] of .argocd.conf, services.sh); gitlab
21
+ # joins in its step (#538)
22
+ # shellcheck disable=SC2034 # read by services.sh
23
+ SERVICES_LIST="postgres mysql"
16
24
 
17
25
  # The only option of a removal: --yes (--oui still accepted); prints 1 or 0
18
26
  yes_flag() {
@@ -27,20 +35,6 @@ yes_flag() {
27
35
  echo "$found"
28
36
  }
29
37
 
30
- # [y/N] in a terminal; without one, --yes is required
31
- confirm_removal() {
32
- local answer=""
33
- [ "${2:-0}" = 1 ] && return 0
34
- if [ ! -t 0 ]; then
35
- echo "✖ no terminal: confirmation impossible, run again with --yes" >&2
36
- return 1
37
- fi
38
- read -r -p "$1 [y/N] " answer || true
39
- case "$answer" in y | Y | yes | YES | o | O | oui) return 0 ;; esac
40
- echo "✖ cancelled, nothing changed" >&2
41
- return 1
42
- }
43
-
44
38
  # shellcheck disable=SC2034 # read by apps.sh
45
39
  APPS_CMD="devzone workspace argocd app"
46
40
  # shellcheck disable=SC2034 # read by apps.sh
@@ -61,6 +55,9 @@ ARGOCD_CONF="$PWD/.argocd.conf"
61
55
  # shellcheck source=../../.devcontainer/argocd/apps.sh
62
56
  # shellcheck disable=SC1091
63
57
  . "$RACINE/.devcontainer/argocd/apps.sh"
58
+ # shellcheck source=../../.devcontainer/argocd/services.sh
59
+ # shellcheck disable=SC1091
60
+ . "$RACINE/.devcontainer/argocd/services.sh"
64
61
  argocd_kubectl() { ak "$@"; }
65
62
 
66
63
  # workspace start and argocd apply: the declarations of .argocd.conf held
@@ -69,6 +66,9 @@ argocd_reconcile() {
69
66
  gitops_init || return 1
70
67
  gitops_root || return 1
71
68
  apps_reconcile
69
+ if argocd_holds_charts; then
70
+ services_reconcile
71
+ fi
72
72
  }
73
73
 
74
74
  # Root token of the devzone GitLab for app add: the file of the workstation,
@@ -144,74 +144,10 @@ argocd_toggle() {
144
144
  esac
145
145
  }
146
146
 
147
- # Namespace of the service: labelled, isolated like the other devzone-*
148
- postgres_namespace_prepare() {
149
- ak create namespace "$POSTGRES_NS" --dry-run=client -o yaml | ak apply -f - >/dev/null
150
- ak label namespace "$POSTGRES_NS" app.kubernetes.io/managed-by=devzone --overwrite >/dev/null
151
- ak -n "$POSTGRES_NS" apply -f - >/dev/null <<EOF
152
- apiVersion: networking.k8s.io/v1
153
- kind: NetworkPolicy
154
- metadata:
155
- name: devzone-meme-namespace
156
- labels:
157
- app.kubernetes.io/managed-by: devzone
158
- spec:
159
- podSelector: {}
160
- ingress:
161
- - from:
162
- - podSelector: {}
163
- EOF
164
- }
165
-
166
- # Superuser secret postgres-admin, created apart: an existing secret is kept
167
- # and mirrored; otherwise a password generated on the workstation. Mirror
168
- # workspace/.postgres/admin-password (600) and .password; never printed
169
- postgres_secret_ensure() {
170
- local dir="$PWD/workspace/.postgres" file password
171
- file="$dir/admin-password"
172
- mkdir -p "$dir"
173
- chmod 700 "$dir"
174
- password="$(ak -n "$POSTGRES_NS" get secret postgres-admin \
175
- -o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
176
- if [ -n "$password" ]; then
177
- (umask 077 && printf '%s' "$password" >"$file")
178
- else
179
- if [ ! -s "$file" ]; then
180
- (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$file")
181
- fi
182
- ak -n "$POSTGRES_NS" create secret generic postgres-admin --from-file=password="$file" >/dev/null
183
- fi
184
- chmod 600 "$file"
185
- argocd_passwords_refresh
186
- }
187
-
188
- postgres_argocd() {
189
- local action="$1" yes
190
- shift
191
- case "$action" in
192
- enable)
193
- if [ "$#" -ne 0 ]; then
194
- echo "✖ postgres through Argo CD takes no option (got: $*)" >&2
195
- return 1
196
- fi
197
- echo "▶ postgres as an Argo CD Application (charts/devzone-postgres at $(argocd_revision))…"
198
- postgres_namespace_prepare
199
- postgres_secret_ensure
200
- argocd_apply_application "$POSTGRES_APP" service "$POSTGRES_NS" \
201
- "$DEVZONE_REPO_URL" "$(argocd_revision)" charts/devzone-postgres
202
- echo "✔ Application $POSTGRES_APP declared; status: devzone workspace argocd status; local access: devzone workspace ports"
203
- ;;
204
- disable)
205
- yes="$(yes_flag "services disable postgres [--yes]" "$@")" || return 1
206
- confirm_removal "Remove PostgreSQL and ALL its databases (Application and namespace $POSTGRES_NS)?" "$yes" || return 1
207
- argocd_delete_application "$POSTGRES_APP"
208
- ak delete namespace "$POSTGRES_NS" --wait=true --ignore-not-found >/dev/null
209
- rm -rf "$PWD/workspace/.postgres"
210
- argocd_passwords_refresh
211
- echo "✔ postgres removed: Application, namespace $POSTGRES_NS and databases"
212
- ;;
213
- esac
214
- }
147
+ # Service hooks (secrets, mysql chart parameters, services switch)
148
+ # shellcheck source=argocd-services-svc.sh
149
+ # shellcheck disable=SC1091
150
+ . "$(dirname "${BASH_SOURCE[0]}")/argocd-services-svc.sh"
215
151
 
216
152
  # devzone workspace argocd status | app …
217
153
  argocd_cmd() {
@@ -21,7 +21,8 @@ ARGOCD_WAIT="${ARGOCD_ATTENTE:-600}"
21
21
  ARGOCD_MIN_MEMORY_KI=1048576
22
22
  DEVZONE_REPO_URL="${DEVZONE_REPO_URL:-https://github.com/SimBienvenueHoulBoumi/devzone.git}"
23
23
 
24
- argocd_values() { printf '%s/.devcontainer/argocd/values.yaml' "$RACINE"; }
24
+ # Wrapper chart installed by the workstation and by the container (#538)
25
+ argocd_chart() { printf '%s/charts/devzone-argocd' "$RACINE"; }
25
26
  argocd_generator() { printf '%s/.devcontainer/argocd/application.sh' "$RACINE"; }
26
27
  argocd_secrets_dir() { printf '%s/workspace/.argocd' "$PWD"; }
27
28
 
@@ -140,12 +141,13 @@ argocd_install() {
140
141
  echo "▶ Argo CD $ARGOCD_CHART_VERSION in $ARGOCD_NS (helm, up to ${ARGOCD_WAIT}s)…"
141
142
  ak create namespace "$ARGOCD_NS" --dry-run=client -o yaml | ak apply -f - >/dev/null
142
143
  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
144
+ # Wrapper chart: the dependency argo-cd (pinned in Chart.yaml) is built
145
+ # first, then installed from the local chart (#538)
146
+ helm dependency build "$(argocd_chart)" >/dev/null
145
147
  # 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
148
+ helm $(drapeau_helm) upgrade --install argocd "$(argocd_chart)" \
149
+ --namespace "$ARGOCD_NS" \
150
+ --timeout "${ARGOCD_WAIT}s" --wait || return 1
149
151
  argocd_save_admin_password
150
152
  echo "✔ Argo CD ready: https://localhost:$ARGOCD_LOCAL_PORT once devzone workspace ports runs; user admin, password in .password"
151
153
  }
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env bash
2
- # DNS publics pour le Docker d'un runner GitHub Actions (#468) : le DNS des
3
- # runners ubuntu échoue parfois à résoudre archive.ubuntu.com pendant la
4
- # construction du conteneur. Ajoute 1.1.1.1 et 8.8.8.8 à daemon.json (les clés
5
- # existantes sont gardées), redémarre Docker et attend qu'il réponde.
6
- # Garde-fou : refuse hors CI, jamais lancé sur un poste.
2
+ # Public DNS for Docker on a GitHub Actions runner (#468): runner ubuntu DNS
3
+ # sometimes fails to resolve archive.ubuntu.com while building the container.
4
+ # Adds 1.1.1.1 and 8.8.8.8 to daemon.json (existing keys are kept), restarts
5
+ # Docker and waits until it responds.
6
+ # Guard: refuses outside CI, never run on a workstation.
7
7
  set -euo pipefail
8
8
 
9
9
  if [ "${CI:-}" != true ] || [ "${GITHUB_ACTIONS:-}" != true ]; then
10
- echo "ci-dns.sh : réservé à GitHub Actions (CI et GITHUB_ACTIONS doivent valoir true)" >&2
10
+ echo "ci-dns.sh: reserved for GitHub Actions (CI and GITHUB_ACTIONS must be true)" >&2
11
11
  exit 1
12
12
  fi
13
13
 
14
- # Chemin surchargeable pour les tests
14
+ # Overridable path for tests
15
15
  daemon="${DEVZONE_CI_DOCKER_DAEMON:-/etc/docker/daemon.json}"
16
16
  tmp="$(mktemp)"
17
17
  trap 'rm -f "$tmp"' EXIT
18
18
 
19
- # Fusion avec le fichier existant, ou création s'il n'existe pas
19
+ # Merge with existing file, or create it if missing
20
20
  if [ -s "$daemon" ]; then
21
21
  jq '. + {"dns": ["1.1.1.1", "8.8.8.8"]}' "$daemon" >"$tmp"
22
22
  else
@@ -27,12 +27,12 @@ sudo cp "$tmp" "$daemon"
27
27
 
28
28
  sudo systemctl restart docker
29
29
 
30
- # Attente de Docker : 20 secondes au plus
30
+ # Wait for Docker: at most 20 seconds
31
31
  for _ in $(seq 1 20); do
32
32
  if docker info >/dev/null 2>&1; then
33
33
  exit 0
34
34
  fi
35
35
  sleep 1
36
36
  done
37
- echo "ci-dns.sh : Docker ne répond pas après 20 s" >&2
37
+ echo "ci-dns.sh: Docker did not respond after 20 s" >&2
38
38
  exit 1