diff --git a/tools/just/cluster.just b/tools/just/cluster.just index 0ca3d289..fe082d98 100644 --- a/tools/just/cluster.just +++ b/tools/just/cluster.just @@ -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" @@ -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. @@ -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" } @@ -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 @@ -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.