Skip to content

infra(dev): cut dev Postgres over to shared Aurora (database-per-dev) - #96

Merged
athvin merged 1 commit into
mainfrom
dev-aurora-cutover
Oct 16, 2026
Merged

athvin merged 1 commit into
mainfrom
dev-aurora-cutover

Conversation

@athvin

@athvin athvin commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Follows #94 (which created the Aurora Serverless v2 cluster). Retires the per-developer in-cluster er-postgres StatefulSet in favour of the shared cluster, database-per-dev: each developer gets erctl_{dev} + role er_{dev} on the one cluster — same isolation the private pod gave, but pay-per-use (Aurora pauses to 0 ACU when idle).

Changes

er-dev-namespace chart

  • delete postgres.yaml (StatefulSet + Service + init ConfigMap) and externalsecret-postgres.yaml
  • add bootstrap.yaml: two ExternalSecrets (shared Aurora master creds er/{env}/shared/postgres; this dev's role pw er/{env}/{dev}/postgres) + an er-db-bootstrap post-install/post-upgrade hook Job that idempotently creates er_{dev} + erctl_{dev} as the master. psql runs under a restricted securityContext; helm blocks on the hook so dev-up installs er-platform only once the DB exists.
  • values.yaml: drop the StatefulSet shape; keep the pinned postgres image for the Job's psql.

scripts/dev_env.sh

  • postgres secret now carries only ER_ROLE_PASSWORD
  • read the Aurora endpoint from er/{env}/shared/postgres; point both ERSERVER_DSN and ERWEB_DATABASE_URL at er_{dev}@aurora/erctl_{dev} (sslmode=require). Hyphens in the DNS-safe dev name fold to underscores for the PG identifiers.
  • drop ERSERVER_MAINT_DSN / ERSERVER_TENANT_DSN_TEMPLATE — the Rust control plane uses a single DSN (per-org catalogs are DuckLake, not per-tenant Postgres DBs).

Makefile

  • dev-up: drop the StatefulSet rollout wait (helm blocks on the hook Job)
  • dev-suspend/dev-resume: no StatefulSet to scale (Aurora auto-pauses); fix the stale er-api/er-web/er-dispatcher names → the merged web-api deployment

Validation

  • Offline: bash -n on dev_env.sh, helm lint, helm template (renders the Job + 2 ExternalSecrets, no StatefulSet/Service/ConfigMap). ✅
  • Live reachability already confirmed: a cluster pod connects to Aurora with sslmode=require. ✅
  • Pending SSO re-auth: run the bootstrap SQL against Aurora (create/idempotency/role-connect) + a throwaway make dev-up DEV=auroratest end-to-end before merge.

NetworkPolicy is Ingress-only (egress unrestricted), so web-api reaches Aurora in the VPC with no policy change.

🤖 Generated with Claude Code

Retires the per-developer in-cluster er-postgres StatefulSet in favour of the
shared Aurora Serverless v2 cluster (rds.tf). Each developer gets their own
role + control-plane database (erctl_{dev}) on the one cluster — the same
isolation the private pod gave, but pay-per-use (Aurora pauses to 0 ACU idle).

er-dev-namespace chart:
  - delete postgres.yaml (StatefulSet + Service + init ConfigMap) and
    externalsecret-postgres.yaml.
  - add bootstrap.yaml: two ExternalSecrets (the shared Aurora master creds
    er/{env}/shared/postgres; this dev's role password er/{env}/{dev}/postgres)
    + an er-db-bootstrap Job (post-install/post-upgrade hook) that idempotently
    creates role er_{dev} + database erctl_{dev} as the master. psql runs under a
    restricted securityContext; helm blocks on the hook so dev-up installs
    er-platform only once the DB exists.
  - values.yaml: drop the StatefulSet shape (storage/resources); keep the pinned
    postgres image for the bootstrap Job's psql.

scripts/dev_env.sh:
  - postgres secret now carries only ER_ROLE_PASSWORD (the per-dev role pw).
  - read the Aurora endpoint from er/{env}/shared/postgres; point both
    erserver.ERSERVER_DSN and erweb.ERWEB_DATABASE_URL at
    er_{dev}@aurora/erctl_{dev} (sslmode=require). Postgres identifiers fold the
    DNS-safe dev name's hyphens to underscores.
  - drop ERSERVER_MAINT_DSN / ERSERVER_TENANT_DSN_TEMPLATE: the Rust control
    plane uses a single DSN (per-org catalogs are DuckLake, not Postgres DBs).

Makefile:
  - dev-up: drop the StatefulSet rollout wait (helm blocks on the hook Job).
  - dev-suspend/dev-resume: no StatefulSet to scale (Aurora auto-pauses); fix
    the stale er-api/er-web/er-dispatcher names to the merged web-api deployment.

NetworkPolicy is Ingress-only (egress unrestricted), so web-api reaches Aurora
in the VPC with no policy change. Validated offline: bash -n, helm lint, helm
template (renders the Job + ExternalSecrets, no StatefulSet). Live validation
(bootstrap SQL against Aurora + a throwaway dev-up) pending SSO re-auth.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@athvin
athvin merged commit fd11a15 into main Oct 16, 2026
6 checks passed
@athvin
athvin deleted the dev-aurora-cutover branch October 16, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants