Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tools/just/cluster.just
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ backend_deploy := "hackagon-backend"
backend_config := "hackagon-backend-config"
backend_db_secret := "hackagon-backend-db"
postgres_sts := "hackagon-postgresql"
# The Service in front of postgres_sts; the bitnami chart gives both the same name.
postgres_svc := "hackagon-postgresql"
app_db := "hackagon"
app_db_owner := "hackagon"

Expand All @@ -18,7 +20,6 @@ dev_domain := "hackagon-dev.dscompute.ch"

backup_dir := env("HOME") + "/hackagon-backups"
local_pg_port := "15432"
postgres_svc := "svc/{{postgres_sts}}"

# Runs inside the postgres pod: finds the superuser password the bitnami image
# was started with (env var or mounted file) so it never leaves the pod.
Expand Down Expand Up @@ -88,13 +89,13 @@ wipe context:
just -f "{{source_file()}}" backup "{{context}}"

kc=(kubectl --context "{{context}}" -n "{{namespace}}")
# A backend found at 0 (e.g. left there by an interrupted run) comes back
# at 1: both recipes promise a running dev, and wipe needs it to recreate
# the schema.
replicas="$("${kc[@]}" get "deploy/{{backend_deploy}}" -o jsonpath='{.spec.replicas}')"
[ "${replicas:-0}" -gt 0 ] || replicas=1

restore_backend() {
# A backend found at 0 (e.g. left there by an interrupted run)
# comes back at 1: both recipes promise a running dev,
# and wipe needs it to recreate the schema."
echo "==> Scaling backend back to $replicas (it recreates the schema on startup)"
"${kc[@]}" scale "deploy/{{backend_deploy}}" --replicas="$replicas"
}
Expand Down Expand Up @@ -145,6 +146,7 @@ reseed context:
db_password="$("${kc[@]}" get secret "{{backend_db_secret}}" -o jsonpath='{.data.password}' | base64 -d)"
[ -n "$db_password" ] || { echo "✗ {{backend_db_secret}} has no password." >&2; exit 1; }

# As in wipe: a backend found at 0 comes back at 1.
replicas="$("${kc[@]}" get "deploy/{{backend_deploy}}" -o jsonpath='{.spec.replicas}')"
[ "${replicas:-0}" -gt 0 ] || replicas=1

Expand All @@ -161,7 +163,7 @@ reseed context:
just -f "{{source_file()}}" _wipe-db "{{context}}"

echo "==> Port-forwarding postgres to localhost:{{local_pg_port}}"
"${kc[@]}" port-forward "{{postgres_svc}}" "{{local_pg_port}}:5432" >/dev/null &
"${kc[@]}" port-forward "svc/{{postgres_svc}}" "{{local_pg_port}}:5432" >/dev/null &
pf_pid=$!

# Wait up to 10s for the tunnel to open.
Expand Down
Loading