-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.sh
More file actions
executable file
·99 lines (85 loc) · 4.57 KB
/
Copy pathconfig.sh
File metadata and controls
executable file
·99 lines (85 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# config.sh — central configuration for the PostgreSQL DR drill.
# Sourced by run.sh and every script under scripts/.
# All values can be overridden by exporting them before invoking run.sh.
# ---------------------------------------------------------------------------
# Run identity
# ---------------------------------------------------------------------------
# RUN_ID makes the cluster name unique per run. In GHA pass github.run_id;
# locally it falls back to a UTC timestamp.
: "${RUN_ID:=$(date -u +%Y%m%d%H%M%S)}"
: "${CLUSTER_NAME:=pg-backup-test-${RUN_ID}}"
# ---------------------------------------------------------------------------
# DigitalOcean / DOKS
# ---------------------------------------------------------------------------
: "${REGION:=nyc3}"
: "${NODE_SIZE:=s-4vcpu-8gb}"
: "${NODE_COUNT:=2}"
# DIGITALOCEAN_TOKEN must be exported by the caller (GHA secret or local env).
# doctl auth is assumed to be already initialised by the CI dependency step,
# but we re-init defensively if a token is present (see lib/preflight.sh).
# ---------------------------------------------------------------------------
# Kubernetes / app config
# ---------------------------------------------------------------------------
: "${NAMESPACE:=prod-postgresql}"
: "${RECOVERY_TAG:=postgreql-recovery-sync}"
: "${ARGOCD_CHART_VERSION:=9.5.22}"
# Repo-relative path to the app-of-app helm chart.
# Resolved against REPO_ROOT (computed in run.sh).
: "${APP_OF_APP_CHART:=kubernetes/argocd/app-of-app}"
# ---------------------------------------------------------------------------
# Timeouts (seconds unless noted)
# ---------------------------------------------------------------------------
: "${ARGOCD_ROLLOUT_TIMEOUT:=120s}"
: "${HELM_INSTALL_TIMEOUT:=3m}"
: "${CLUSTER_HEALTHY_ATTEMPTS:=90}" # x10s sleep => 15 min
: "${CLUSTER_HEALTHY_INTERVAL:=10}"
# ---------------------------------------------------------------------------
# JuiceFS (read-only DR mount)
# ---------------------------------------------------------------------------
: "${JUICEFS_ENABLED:=true}"
: "${JUICEFS_READONLY:=true}" # injects the `ro` mount option
: "${JUICEFS_MONITORING:=false}"
: "${JUICEFS_NAMESPACE:=juicefs}"
: "${JUICEFS_SECRET_NAME:=cloudflare-r2}"
: "${JUICEFS_VOLUME_NAME:=cloudflare-r2-prod}"
: "${JUICEFS_BUCKET:=https://4c8ad4e9fa8213af3fd284bb97b68b5e.r2.cloudflarestorage.com/juicefs-prod}"
# Assigned with a plain conditional: the JSON braces collide with ${VAR:=...}.
if [ -z "${JUICEFS_ENVS:-}" ]; then
JUICEFS_ENVS='{"JFS_MOUNT_TIMEOUT": 300}'
fi
# Metadata engine (the restored CNPG cluster holding the juicefs_prod DB).
# The rw service for a CNPG cluster named "postgresql" is "postgresql-rw".
: "${JUICEFS_META_USER:=juicefs}"
: "${JUICEFS_META_HOST:=postgresql-rw.${NAMESPACE}.svc}"
: "${JUICEFS_META_DB:=juicefs}"
# JUICEFS_META_PASSWORD must be exported (the juicefs DB role password from the
# restored cluster). If you'd rather supply the whole URL, set JUICEFS_METAURL.
: "${JUICEFS_METAURL:=postgres://${JUICEFS_META_USER}:${JUICEFS_META_PASSWORD:-}@${JUICEFS_META_HOST}:5432/${JUICEFS_META_DB}?sslmode=disable}"
# Label selector for CSI node/controller readiness.
: "${JUICEFS_CSI_SELECTOR:=app.kubernetes.io/name=juicefs-csi-driver}"
# ---------------------------------------------------------------------------
# Vaultwarden (validated against the read-only JuiceFS mount)
# ---------------------------------------------------------------------------
: "${VAULTWARDEN_NAMESPACE:=vaultwarden}"
: "${VAULTWARDEN_DEPLOYMENT:=vaultwarden}"
: "${VAULTWARDEN_SERVICE:=vaultwarden}"
: "${VAULTWARDEN_DATA_PATH:=/data}" # JuiceFS-backed data dir in the pod
: "${VAULTWARDEN_LOCAL_PORT:=8080}"
: "${VAULTWARDEN_ROLLOUT_TIMEOUT:=300s}"
# Optional: set VW_ADMIN_TOKEN to additionally assert restored user count.
# ---------------------------------------------------------------------------
# Validation expectations
# ---------------------------------------------------------------------------
# Space-separated list of databases that must exist after recovery.
: "${EXPECTED_DBS:=sonarqube}"
# ---------------------------------------------------------------------------
# Secrets (required for the secrets step). Exported by caller.
# ---------------------------------------------------------------------------
# R2_ACCESS_KEY
# R2_SECRET_KEY
# ---------------------------------------------------------------------------
# Behaviour flags
# ---------------------------------------------------------------------------
# Set SKIP_DESTROY=1 to leave the cluster running for inspection after a run.
: "${SKIP_DESTROY:=0}"