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
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# GitLab installed from the wrapper chart charts/devzone-gitlab (#538): the
|
|
3
|
-
# official gitlab 9.11.16 and gitlab-runner 0.88.2 are dependencies pinned in
|
|
4
|
-
# the chart, its values.yaml holds the values of the GitLab of devzone
|
|
5
|
-
# (under the gitlab and gitlab-runner keys). This file is the helm-direct
|
|
6
|
-
# path, the Application of Argo CD is argocd.sh. Sourced by installation.sh.
|
|
7
|
-
# gitlab_chart_depend repository HTTP gitlab added, dependency build
|
|
8
|
-
# gitlab_helm_pass <replicas> upgrade --install of the chart, runner replicas
|
|
9
|
-
# gitlab_runner_ancien_retirer release gitlab-runner of before #538 removed
|
|
10
|
-
# The runner is held back (replicas 0) on the first pass: its Secret
|
|
11
|
-
# gitlab-runner-secret is written by the seed, and a runner pod waiting for it
|
|
12
|
-
# would hold --wait until the timeout.
|
|
13
|
-
|
|
14
|
-
# The dependencies come from https://charts.gitlab.io (no OCI repository is
|
|
15
|
-
# published): the repository is added before the build, idempotent
|
|
16
|
-
gitlab_chart_depend() {
|
|
17
|
-
helm repo add gitlab https://charts.gitlab.io --force-update >/dev/null 2>&1 || true
|
|
18
|
-
helm dependency build "$RACINE/charts/devzone-gitlab" >/dev/null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
# One helm pass of the wrapper chart. The webservice URL of the runner follows
|
|
22
|
-
# the namespace of the instance: the chart value is not templated, its default
|
|
23
|
-
# is the main instance, so it is passed here
|
|
24
|
-
gitlab_helm_pass() {
|
|
25
|
-
local replicas="$1"
|
|
26
|
-
account_helm "$(account_context)" upgrade --install gitlab "$RACINE/charts/devzone-gitlab" \
|
|
27
|
-
--namespace "$GITLAB_NS" \
|
|
28
|
-
--create-namespace \
|
|
29
|
-
--timeout "${GITLAB_ATTENTE}s" \
|
|
30
|
-
--wait \
|
|
31
|
-
--set "gitlab-runner.gitlabUrl=http://gitlab-webservice-default.$GITLAB_NS.svc:8181" \
|
|
32
|
-
--set "gitlab-runner.replicas=$replicas"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# Release gitlab-runner of the installations before the wrapper chart (#396):
|
|
36
|
-
# its runner now comes with the chart, the release leaves without touching data
|
|
37
|
-
gitlab_runner_ancien_retirer() {
|
|
38
|
-
account_helm "$(account_context)" uninstall gitlab-runner --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
39
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# GitLab module: test GitLab in the services cluster (#396).
|
|
3
|
-
# To enable it: devzone enable gitlab
|
|
4
|
-
# To disable it: devzone disable gitlab
|
|
5
|
-
# set -euo pipefail so that nothing fails silently.
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
# Root of the devzone repository (two levels above the module); DEVZONE_ROOT for the tests
|
|
9
|
-
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
10
|
-
RACINE="${DEVZONE_ROOT:-$(dirname "$(dirname "$ICI")")}"
|
|
11
|
-
# shellcheck source=SCRIPTDIR/../cluster.sh
|
|
12
|
-
. "$ICI/../cluster.sh"
|
|
13
|
-
# shellcheck source=SCRIPTDIR/../password.sh
|
|
14
|
-
# shellcheck disable=SC1091
|
|
15
|
-
. "$ICI/../password.sh"
|
|
16
|
-
# Network isolation: namespace_isolate, set with the devzone-gitlab namespace
|
|
17
|
-
# shellcheck source=SCRIPTDIR/../isolation.sh
|
|
18
|
-
# shellcheck disable=SC1091
|
|
19
|
-
. "$ICI/../isolation.sh"
|
|
20
|
-
|
|
21
|
-
# ---- Delay variables (seconds) ----
|
|
22
|
-
# GITLAB_ATTENTE: global wait for the installation (default 1200)
|
|
23
|
-
GITLAB_ATTENTE="${GITLAB_ATTENTE:-1200}"
|
|
24
|
-
|
|
25
|
-
# ---- Secret paths ----
|
|
26
|
-
# Secrets stored in $RACINE/workspace/.gitlab/ (chmod 600), never shown.
|
|
27
|
-
GITLAB_SECRETS_DIR="$RACINE/workspace/.gitlab"
|
|
28
|
-
|
|
29
|
-
# Grouped view of the credentials: a failure never prevents the operation
|
|
30
|
-
regenerer_identifiants() {
|
|
31
|
-
password_regenerate ||
|
|
32
|
-
echo "devzone : gitlab : grouped credentials not updated (devzone passwords)" >&2
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# ---- /etc/hosts of the container ----
|
|
36
|
-
# DEVZONE_HOSTS for the tests (never the real /etc/hosts)
|
|
37
|
-
HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
|
|
38
|
-
GITLAB_HOST_MARK="# devzone:gitlab"
|
|
39
|
-
|
|
40
|
-
# GitLab Rails secret (#347): kept in workspace/.gitlab, applied again
|
|
41
|
-
# before helm upgrade --install, and the password can be regenerated
|
|
42
|
-
# shellcheck source=SCRIPTDIR/secrets.sh
|
|
43
|
-
# shellcheck disable=SC1091
|
|
44
|
-
. "$ICI/secrets.sh"
|
|
45
|
-
|
|
46
|
-
# ---- Installation, migration and relay of the services cluster ----
|
|
47
|
-
# New logic outside this file (#396): devzone-gitlab namespace,
|
|
48
|
-
# allocatable memory, Helm with the devzone context, migration from kind-gitlab.
|
|
49
|
-
# shellcheck source=SCRIPTDIR/installation.sh
|
|
50
|
-
# shellcheck disable=SC1091
|
|
51
|
-
. "$ICI/installation.sh"
|
|
52
|
-
# Wrapper chart (direct helm, chart.sh), Argo CD (argocd.sh), seed (seed.sh) (#538)
|
|
53
|
-
# shellcheck source=SCRIPTDIR/chart.sh
|
|
54
|
-
# shellcheck disable=SC1091
|
|
55
|
-
. "$ICI/chart.sh"
|
|
56
|
-
# shellcheck source=SCRIPTDIR/argocd.sh
|
|
57
|
-
# shellcheck disable=SC1091
|
|
58
|
-
. "$ICI/argocd.sh"
|
|
59
|
-
# shellcheck source=SCRIPTDIR/seed.sh
|
|
60
|
-
# shellcheck disable=SC1091
|
|
61
|
-
. "$ICI/seed.sh"
|
|
62
|
-
|
|
63
|
-
# ---- host-set / host-remove: gitlab.localhost in /etc/hosts ----
|
|
64
|
-
# Why: ssh (clone ssh://git@gitlab.localhost:2224/…), glab and getent go through
|
|
65
|
-
# the system resolver. curl and git (libcurl) ignore /etc/hosts for the
|
|
66
|
-
# *.localhost names (RFC 6761) and go through the TCP relay above, which
|
|
67
|
-
# listens on 127.0.0.1. The name therefore points to 127.0.0.1 so that ssh and
|
|
68
|
-
# glab take the same path. /etc/hosts is a Docker mount that Docker regenerates
|
|
69
|
-
# when the container starts, hence the set again at each start (startup.sh) and
|
|
70
|
-
# at each activation. Never sed -i nor mv: the mount cannot be renamed (in-place
|
|
71
|
-
# write only); direct if the file is writable, otherwise sudo -n. A failure never
|
|
72
|
-
# fails: a warning on stderr and exit code 0, so that the installation does not
|
|
73
|
-
# fail for a host name.
|
|
74
|
-
gitlab_host_set() {
|
|
75
|
-
local line tmp
|
|
76
|
-
line="$(printf '127.0.0.1\tgitlab.localhost %s' "$GITLAB_HOST_MARK")"
|
|
77
|
-
# Already the right line, once: nothing (idempotent)
|
|
78
|
-
if [ "$(grep -c "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null || true)" = 1 ] &&
|
|
79
|
-
grep -qxF "$line" "$HOSTS" 2>/dev/null; then
|
|
80
|
-
return 0
|
|
81
|
-
fi
|
|
82
|
-
if grep -q "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null; then
|
|
83
|
-
# Line marked with another address (IPv6 of #320) or duplicate:
|
|
84
|
-
# it is replaced by the right one, keeping the rest of the file.
|
|
85
|
-
tmp="$(mktemp)"
|
|
86
|
-
grep -v "$GITLAB_HOST_MARK" "$HOSTS" >"$tmp" 2>/dev/null || true
|
|
87
|
-
printf '%s\n' "$line" >>"$tmp"
|
|
88
|
-
if [ -w "$HOSTS" ]; then
|
|
89
|
-
cp "$tmp" "$HOSTS" 2>/dev/null ||
|
|
90
|
-
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (insufficient write rights)" >&2
|
|
91
|
-
elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
|
|
92
|
-
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (sudo -n unavailable or refused)" >&2
|
|
93
|
-
fi
|
|
94
|
-
rm -f "$tmp"
|
|
95
|
-
return 0
|
|
96
|
-
fi
|
|
97
|
-
if [ -w "$HOSTS" ]; then
|
|
98
|
-
printf '%s\n' "$line" >>"$HOSTS" 2>/dev/null ||
|
|
99
|
-
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (insufficient write rights)" >&2
|
|
100
|
-
elif ! printf '%s\n' "$line" | sudo -n tee -a "$HOSTS" >/dev/null 2>&1; then
|
|
101
|
-
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (sudo -n unavailable or refused)" >&2
|
|
102
|
-
fi
|
|
103
|
-
return 0
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
gitlab_host_remove() {
|
|
107
|
-
# No line found: nothing (including an unreadable file)
|
|
108
|
-
if ! grep -q "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null; then
|
|
109
|
-
return 0
|
|
110
|
-
fi
|
|
111
|
-
local tmp
|
|
112
|
-
tmp="$(mktemp)"
|
|
113
|
-
grep -v "$GITLAB_HOST_MARK" "$HOSTS" >"$tmp" 2>/dev/null || true
|
|
114
|
-
if [ -w "$HOSTS" ]; then
|
|
115
|
-
cp "$tmp" "$HOSTS" 2>/dev/null ||
|
|
116
|
-
echo "devzone : gitlab : gitlab.localhost line not removed from $HOSTS (insufficient write rights)" >&2
|
|
117
|
-
elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
|
|
118
|
-
echo "devzone : gitlab : gitlab.localhost line not removed from $HOSTS (sudo -n unavailable or refused)" >&2
|
|
119
|
-
fi
|
|
120
|
-
rm -f "$tmp"
|
|
121
|
-
return 0
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
# ---- status: check the state of GitLab ----
|
|
125
|
-
gitlab_status() {
|
|
126
|
-
# Disabled if the devzone-gitlab namespace does not exist
|
|
127
|
-
if ! gitlab_installed; then
|
|
128
|
-
echo "disabled"
|
|
129
|
-
return 0
|
|
130
|
-
fi
|
|
131
|
-
|
|
132
|
-
# Check that GitLab answers the readiness probe
|
|
133
|
-
if curl -sf http://gitlab.localhost:8929/-/readiness >/dev/null 2>&1 || curl -sf http://gitlab.localhost:8929/users/sign_in >/dev/null 2>&1; then
|
|
134
|
-
# Check whether the runner is online or offline
|
|
135
|
-
local runner_status="offline"
|
|
136
|
-
if [ -f "$GITLAB_SECRETS_DIR/root-token" ]; then
|
|
137
|
-
local token count
|
|
138
|
-
token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
139
|
-
count="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/runners/all?status=online" 2>/dev/null | jq -r 'length' 2>/dev/null || true)"
|
|
140
|
-
if [ "${count:-0}" -gt 0 ] 2>/dev/null; then
|
|
141
|
-
runner_status="online"
|
|
142
|
-
fi
|
|
143
|
-
fi
|
|
144
|
-
echo "ready: http://gitlab.localhost:8929, runner ${runner_status}"
|
|
145
|
-
else
|
|
146
|
-
echo "failed: devzone apply"
|
|
147
|
-
fi
|
|
148
|
-
return 0
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
# Subcommand dispatch
|
|
152
|
-
case "${1:-}" in
|
|
153
|
-
install) gitlab_install ;;
|
|
154
|
-
uninstall) gitlab_uninstall "${@:2}" ;;
|
|
155
|
-
migrate) shift; gitlab_migrate "$@" ;;
|
|
156
|
-
installe) gitlab_installed ;;
|
|
157
|
-
status) gitlab_status ;;
|
|
158
|
-
seed) gitlab_seed_command ;;
|
|
159
|
-
new-password) gitlab_new_password "${@:2}" ;;
|
|
160
|
-
relay-start) gitlab_relay_start ;;
|
|
161
|
-
relay-stop) gitlab_relay_stop ;;
|
|
162
|
-
relay-status) gitlab_relay_status ;;
|
|
163
|
-
hote-poser) gitlab_host_set ;;
|
|
164
|
-
hote-retirer) gitlab_host_remove ;;
|
|
165
|
-
*) echo "devzone : unknown command : ${1:-} (devzone gitlab --help)" >&2
|
|
166
|
-
exit 1
|
|
167
|
-
;;
|
|
168
|
-
esac
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Installation and migration of GitLab in the services cluster (#396).
|
|
3
|
-
# Sourced by gitlab.sh: devzone-gitlab namespace (suffixed per instance),
|
|
4
|
-
# check of the allocatable memory, Helm with the devzone context, port-forward
|
|
5
|
-
# relay, runner and migration from the old kind cluster.
|
|
6
|
-
# The wrapper chart charts/devzone-gitlab (#538) holds the dependencies and the
|
|
7
|
-
# values; chart.sh (direct helm) and argocd.sh (Application) install it.
|
|
8
|
-
|
|
9
|
-
# Shared memory check of the services cluster (#608): quantity_ki,
|
|
10
|
-
# memory_cluster_ki and check_module_memory.
|
|
11
|
-
# shellcheck source=SCRIPTDIR/../memory.sh
|
|
12
|
-
# shellcheck disable=SC1091
|
|
13
|
-
. "$ICI/../memory.sh"
|
|
14
|
-
|
|
15
|
-
# Namespace isolated from the module: one per instance, like postgres
|
|
16
|
-
GITLAB_NS="devzone-gitlab${INSTANCE_SUFFIX}"
|
|
17
|
-
# Old kind cluster of GitLab, deleted by "devzone gitlab migrate"
|
|
18
|
-
GITLAB_OLD_CLUSTER="gitlab${INSTANCE_SUFFIX}"
|
|
19
|
-
GITLAB_OLD_CONTEXT="kind-gitlab${INSTANCE_SUFFIX}"
|
|
20
|
-
|
|
21
|
-
# Namespace present in the services cluster: GitLab is installed.
|
|
22
|
-
# Reading the namespaces is reserved to the administrator (#430).
|
|
23
|
-
gitlab_installed() {
|
|
24
|
-
account_admin "$(account_context)" get namespace "$GITLAB_NS" >/dev/null 2>&1
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
# Creates the namespace, labels it and allows the limited account (#430), sets the isolation.
|
|
28
|
-
gitlab_namespace_prepare() {
|
|
29
|
-
local ctx
|
|
30
|
-
ctx="$(account_context)"
|
|
31
|
-
account_namespace "$ctx" "$GITLAB_NS"
|
|
32
|
-
namespace_isolate "$GITLAB_NS"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# Installs GitLab and its runner in the services cluster, then prepares the
|
|
36
|
-
# access (web/SSH relay, /etc/hosts) and the seed of the test data.
|
|
37
|
-
gitlab_install() {
|
|
38
|
-
echo "▶ Checking the allocatable memory of the services cluster…"
|
|
39
|
-
check_module_memory gitlab 8 || return 2
|
|
40
|
-
|
|
41
|
-
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
42
|
-
gitlab_namespace_prepare
|
|
43
|
-
|
|
44
|
-
# Rails secret (#347): reinstallation -> apply the kept secret again before
|
|
45
|
-
# the installation (the chart reuses it, browser sessions stay valid)
|
|
46
|
-
gitlab_secrets_apply
|
|
47
|
-
gitlab_runner_ancien_retirer
|
|
48
|
-
|
|
49
|
-
# Argo CD holds the chart when the module is on (#538): the Application
|
|
50
|
-
# syncs it and the seed runs once GitLab answers. Otherwise the wrapper chart
|
|
51
|
-
# is installed by helm, the runner held back until the seed wrote its Secret
|
|
52
|
-
local par_argocd=0
|
|
53
|
-
if gitlab_argocd_active; then
|
|
54
|
-
par_argocd=1
|
|
55
|
-
gitlab_release_adopter
|
|
56
|
-
gitlab_application_apply || return 1
|
|
57
|
-
else
|
|
58
|
-
echo "▶ Installing the GitLab chart in ${GITLAB_NS}…"
|
|
59
|
-
gitlab_chart_depend
|
|
60
|
-
gitlab_helm_pass 0 || return 1
|
|
61
|
-
fi
|
|
62
|
-
|
|
63
|
-
# Relay before the wait: curl and git in HTTP resolve *.localhost to the
|
|
64
|
-
# loopback and reach GitLab only through these port-forwards (#320)
|
|
65
|
-
gitlab_relay_start || return 1
|
|
66
|
-
|
|
67
|
-
# gitlab.localhost name in /etc/hosts before the wait: ssh, glab and
|
|
68
|
-
# getent need it as soon as the service is up (curl resolves it itself)
|
|
69
|
-
gitlab_host_set || true
|
|
70
|
-
|
|
71
|
-
gitlab_wait_ready
|
|
72
|
-
gitlab_seed
|
|
73
|
-
if [ ! -f "$GITLAB_RAILS_FILE" ]; then
|
|
74
|
-
gitlab_secrets_copy
|
|
75
|
-
fi
|
|
76
|
-
if [ "$par_argocd" = 0 ]; then
|
|
77
|
-
echo "▶ GitLab Runner executor…"
|
|
78
|
-
gitlab_helm_pass 1 || return 1
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
gitlab_secrets_warn
|
|
82
|
-
|
|
83
|
-
echo "▶ Installation complete."
|
|
84
|
-
echo " URL: http://gitlab.localhost:8929"
|
|
85
|
-
echo " User: root"
|
|
86
|
-
echo " Root password: $GITLAB_SECRETS_DIR/root-password (chmod 600)"
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
# Removes GitLab: relays, Helm releases and the namespace of the instance only.
|
|
90
|
-
# The Rails secret is kept (browser sessions valid at the reinstallation),
|
|
91
|
-
# unless a complete uninstall is wanted (--yes): it then goes with the data.
|
|
92
|
-
gitlab_uninstall() {
|
|
93
|
-
local delete_secret="" arg
|
|
94
|
-
for arg in "$@"; do
|
|
95
|
-
case "$arg" in
|
|
96
|
-
--yes) delete_secret=1 ;;
|
|
97
|
-
*) echo "devzone : gitlab uninstall : unknown argument : $arg" >&2; return 2 ;;
|
|
98
|
-
esac
|
|
99
|
-
done
|
|
100
|
-
echo "▶ Uninstalling GitLab…"
|
|
101
|
-
gitlab_relay_stop
|
|
102
|
-
rm -rf "$(relay_dir gitlab-web)" "$(relay_dir gitlab-ssh)" \
|
|
103
|
-
"$(relay_dir gitlab-8929)" "$(relay_dir gitlab-2224)"
|
|
104
|
-
# Application held by Argo CD (#538): its resources go with it
|
|
105
|
-
gitlab_application_retirer || true
|
|
106
|
-
account_helm "$(account_context)" uninstall gitlab --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
107
|
-
gitlab_runner_ancien_retirer
|
|
108
|
-
# RoleBinding removed, then the namespace deleted by the administrator (#430)
|
|
109
|
-
account_remove "$(account_context)" "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
110
|
-
account_admin "$(account_context)" delete namespace "$GITLAB_NS" --ignore-not-found >/dev/null 2>&1 || true
|
|
111
|
-
if [ -n "$delete_secret" ]; then
|
|
112
|
-
rm -rf "$GITLAB_SECRETS_DIR"
|
|
113
|
-
echo "Rails secret deleted with the GitLab data."
|
|
114
|
-
elif [ -d "$GITLAB_SECRETS_DIR" ]; then
|
|
115
|
-
find "$GITLAB_SECRETS_DIR" -mindepth 1 ! -name rails-secret.yaml -exec rm -rf {} + 2>/dev/null || true
|
|
116
|
-
if [ -f "$GITLAB_RAILS_FILE" ]; then
|
|
117
|
-
echo "Rails secret kept in workspace/.gitlab/rails-secret.yaml (browser sessions valid at reinstallation)"
|
|
118
|
-
fi
|
|
119
|
-
fi
|
|
120
|
-
gitlab_host_remove
|
|
121
|
-
echo "✔ GitLab uninstalled."
|
|
122
|
-
regenerer_identifiants
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
# Migration: installs and seeds in the services cluster, then deletes the old
|
|
126
|
-
# kind-gitlab cluster after confirmation (or --yes).
|
|
127
|
-
gitlab_migrate() {
|
|
128
|
-
local yes_flag="" arg answer
|
|
129
|
-
for arg in "$@"; do
|
|
130
|
-
case "$arg" in
|
|
131
|
-
--yes) yes_flag=1 ;;
|
|
132
|
-
*) echo "devzone : gitlab migrate : unknown argument : $arg (devzone gitlab migrate [--yes])" >&2; return 2 ;;
|
|
133
|
-
esac
|
|
134
|
-
done
|
|
135
|
-
|
|
136
|
-
echo "▶ Migrating GitLab from the old kind cluster…"
|
|
137
|
-
echo " This is a test GitLab: the demo project and the runner are recreated, the rest is lost."
|
|
138
|
-
gitlab_install || return $?
|
|
139
|
-
|
|
140
|
-
if ! kind get clusters 2>/dev/null | grep -qx "$GITLAB_OLD_CLUSTER"; then
|
|
141
|
-
echo "✔ No old cluster $GITLAB_OLD_CONTEXT to delete."
|
|
142
|
-
return 0
|
|
143
|
-
fi
|
|
144
|
-
|
|
145
|
-
if [ -z "$yes_flag" ]; then
|
|
146
|
-
if ! cluster_interactive; then
|
|
147
|
-
echo "devzone : gitlab : confirmation impossible without a terminal: devzone gitlab migrate --yes (old cluster $GITLAB_OLD_CONTEXT kept)" >&2
|
|
148
|
-
return 2
|
|
149
|
-
fi
|
|
150
|
-
printf "Delete the old cluster %s and its data? [y/N] " "$GITLAB_OLD_CONTEXT" >&2
|
|
151
|
-
read -r answer || answer=""
|
|
152
|
-
case "$answer" in
|
|
153
|
-
y | Y | yes) ;;
|
|
154
|
-
*) echo "Aborted: old cluster $GITLAB_OLD_CONTEXT kept."; return 0 ;;
|
|
155
|
-
esac
|
|
156
|
-
fi
|
|
157
|
-
|
|
158
|
-
kind delete cluster --name "$GITLAB_OLD_CLUSTER"
|
|
159
|
-
kubectl config delete-context "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
|
|
160
|
-
kubectl config delete-cluster "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
|
|
161
|
-
kubectl config delete-user "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
|
|
162
|
-
echo "✔ Old cluster $GITLAB_OLD_CONTEXT deleted."
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
# Web and SSH access: port-forward to the ClusterIP services of the namespace.
|
|
166
|
-
gitlab_relay_start() {
|
|
167
|
-
relay_start gitlab-web devzone "$GITLAB_NS" svc/gitlab-webservice-default 8929:8181
|
|
168
|
-
relay_start gitlab-ssh devzone "$GITLAB_NS" svc/gitlab-gitlab-shell 2224:22
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
# Stops the two relays of the module.
|
|
172
|
-
gitlab_relay_stop() {
|
|
173
|
-
relay_stop gitlab-web
|
|
174
|
-
relay_stop gitlab-ssh
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
# State of the relays: code 0 only if both are running.
|
|
178
|
-
gitlab_relay_status() {
|
|
179
|
-
local missing=""
|
|
180
|
-
relay_active gitlab-web || missing="$missing 8929"
|
|
181
|
-
relay_active gitlab-ssh || missing="$missing 2224"
|
|
182
|
-
if [ -n "$missing" ]; then
|
|
183
|
-
echo "gitlab relay stopped on${missing}"
|
|
184
|
-
return 1
|
|
185
|
-
fi
|
|
186
|
-
return 0
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
# True if an old kind-gitlab cluster still exists (warning of the summary,
|
|
190
|
-
# as long as the migration has not been done).
|
|
191
|
-
gitlab_old_cluster_exists() {
|
|
192
|
-
kind get clusters 2>/dev/null | grep -qx "$GITLAB_OLD_CLUSTER"
|
|
193
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# GitLab Rails secret (#347): kept in workspace/.gitlab, the gitlab-rails-secret
|
|
3
|
-
# secret of the devzone-gitlab namespace, source of the Rails secrets.
|
|
4
|
-
# At the first installation, the secret of the cluster is copied to
|
|
5
|
-
# workspace/.gitlab/rails-secret.yaml (600, ignored by git); at a reinstallation,
|
|
6
|
-
# if it exists, it is applied again before helm upgrade --install (the chart
|
|
7
|
-
# reuses it and the browser sessions stay valid, without 422). Otherwise, if the
|
|
8
|
-
# secrets were lost, the end of the installation and the summary warn.
|
|
9
|
-
|
|
10
|
-
# Name of the Rails secret and source file of the secrets of the module
|
|
11
|
-
GITLAB_RAILS_SECRET="gitlab-rails-secret"
|
|
12
|
-
GITLAB_RAILS_FILE="$GITLAB_SECRETS_DIR/rails-secret.yaml"
|
|
13
|
-
|
|
14
|
-
# jq filter: removes the fields specific to the cluster (identity, version,
|
|
15
|
-
# management, annotations of the last apply) and keeps a re-appliable JSON manifest.
|
|
16
|
-
GITLAB_RAILS_JQ='del(.metadata.resourceVersion, .metadata.uid, .metadata.creationTimestamp, .metadata.managedFields, .metadata.ownerReferences, .metadata.annotations["kubectl.kubernetes.io/last-applied-configuration"])'
|
|
17
|
-
|
|
18
|
-
# Reads the Rails secret of the cluster and writes a real Secret manifest in JSON
|
|
19
|
-
# (first installation). Nothing is written if the read fails or if the secret is missing.
|
|
20
|
-
gitlab_secrets_copy() {
|
|
21
|
-
local secret tmp
|
|
22
|
-
secret="$(kubectl --context devzone get secret -n "$GITLAB_NS" \
|
|
23
|
-
"$GITLAB_RAILS_SECRET" -o json 2>/dev/null)" || return 0
|
|
24
|
-
[ -n "$secret" ] || return 0
|
|
25
|
-
mkdir -p "$GITLAB_SECRETS_DIR" || return 0
|
|
26
|
-
tmp="$(umask 077; mktemp "$GITLAB_SECRETS_DIR/.rails-secret.XXXXXX")" || return 0
|
|
27
|
-
if ! printf '%s\n' "$secret" | jq "$GITLAB_RAILS_JQ" >"$tmp" || [ ! -s "$tmp" ]; then
|
|
28
|
-
rm -f "$tmp"
|
|
29
|
-
return 0
|
|
30
|
-
fi
|
|
31
|
-
chmod 600 "$tmp" || {
|
|
32
|
-
rm -f "$tmp"
|
|
33
|
-
return 0
|
|
34
|
-
}
|
|
35
|
-
mv -f "$tmp" "$GITLAB_RAILS_FILE"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
# Applies the Rails secret again from the source file before a helm upgrade
|
|
39
|
-
# --install: the chart reuses the existing secret, the browser sessions stay
|
|
40
|
-
# valid after a reinstallation. A failure is shown and returned.
|
|
41
|
-
gitlab_secrets_apply() {
|
|
42
|
-
if [ ! -f "$GITLAB_RAILS_FILE" ]; then
|
|
43
|
-
return 0
|
|
44
|
-
fi
|
|
45
|
-
kubectl --context devzone -n "$GITLAB_NS" apply -f "$GITLAB_RAILS_FILE"
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
# Warns if the Rails secret could not be kept: the reinstallation generates a new
|
|
49
|
-
# secret and the browser sessions are invalidated (422).
|
|
50
|
-
gitlab_secrets_warn() {
|
|
51
|
-
if [ ! -f "$GITLAB_RAILS_FILE" ]; then
|
|
52
|
-
echo "GitLab reinstalled: if the browser shows 422, delete the site data of gitlab.localhost"
|
|
53
|
-
fi
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
# Random password (root | dev): Ruby script passed on the standard input of
|
|
57
|
-
# gitlab-rails runner (never on the pod command line), then the source file and
|
|
58
|
-
# the grouped .password are updated if the runner confirms. Nothing is shown,
|
|
59
|
-
# only the path.
|
|
60
|
-
gitlab_new_password() {
|
|
61
|
-
local user="${1:-}" pass pod script output file
|
|
62
|
-
case "$user" in
|
|
63
|
-
root | dev) ;;
|
|
64
|
-
*)
|
|
65
|
-
echo "devzone : gitlab : unknown user : ${user:-(missing)} (devzone gitlab new-password [root|dev])" >&2
|
|
66
|
-
return 2
|
|
67
|
-
;;
|
|
68
|
-
esac
|
|
69
|
-
pass="$(openssl rand -hex 24)"
|
|
70
|
-
pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
|
|
71
|
-
if [ -z "$pod" ]; then
|
|
72
|
-
echo "devzone : gitlab : toolbox pod (label app=toolbox) not found, password not changed." >&2
|
|
73
|
-
return 1
|
|
74
|
-
fi
|
|
75
|
-
script="u = User.find_by_username(\"$user\")
|
|
76
|
-
u.password = \"$pass\"
|
|
77
|
-
u.password_confirmation = \"$pass\"
|
|
78
|
-
u.save!
|
|
79
|
-
puts \"OK\""
|
|
80
|
-
if ! output="$(printf '%s\n' "$script" | kubectl --context devzone exec -i -n "$GITLAB_NS" "$pod" -- gitlab-rails runner -)"; then
|
|
81
|
-
echo "devzone : gitlab : password (gitlab-rails runner) not applied." >&2
|
|
82
|
-
return 1
|
|
83
|
-
fi
|
|
84
|
-
if [[ "$output" != *OK* ]]; then
|
|
85
|
-
echo "devzone : gitlab : password not confirmed by gitlab-rails runner." >&2
|
|
86
|
-
return 1
|
|
87
|
-
fi
|
|
88
|
-
file="$GITLAB_SECRETS_DIR/$user-password"
|
|
89
|
-
mkdir -p "$GITLAB_SECRETS_DIR" || return 1
|
|
90
|
-
(umask 077 && printf '%s' "$pass" >"$file") || return 1
|
|
91
|
-
chmod 600 "$file"
|
|
92
|
-
password_regenerate ||
|
|
93
|
-
echo "devzone : gitlab : grouped credentials not updated (devzone passwords)" >&2
|
|
94
|
-
printf '%s\n' "$RACINE/.password"
|
|
95
|
-
}
|