Skip to content

Database Provider

The database provider places tenant databases on shared Postgres shards (Percona PG clusters) and hands the connection details to the calling cluster. It runs inside the cluster that hosts the shards. A consumer (for example an operator in another cluster) calls a small, token-authenticated, TLS-only HTTP API; everything else is declarative.

flowchart LR
    C([Consumer cluster\noperator]) -->|HTTPS /v1 + bearer token| P[database provider\n2 replicas]
    P -->|state| K[(Shard / Consumer /\nDatabase CRs)]
    P -->|DDL via primary Service\nas role provisioner| S[(Percona PG shard\nprimary)]
    C -.->|SQL via pgBouncer LB\nwith returned credentials| B[pgBouncer LB]
    B --> S

What it does

  • Create (idempotent PUT): picks the accepting, ready shard with the fewest databases, generates a role and a database name (t_ plus 20 random characters, never derived from caller input), creates both, revokes PUBLIC access to the database and grants CONNECT to the owner only.
  • Read (GET): returns phase and, once Ready, host, port, database, user, password, sslmode. The credentials stay retrievable, so a lost consumer-side Secret needs no reset.
  • Delete (DELETE): a soft delete. Login is revoked, the database is closed and sessions are terminated at once; the database and role are dropped after a grace period (default 7 days). Deleting the Kubernetes object instead (kubectl delete, a Flux prune) does not delete the tenant: the provider holds it and alerts (hold versus soft delete).

What it deliberately does not do (v1)

Restore, password rotation, resize, move between shards, and un-delete. See Recover a soft-deleted database for what an operator can do by hand.

The three resources

Kind Scope Who writes it Meaning
Shard cluster you (GitOps) one Percona PG cluster the provider may place into
Consumer cluster you (GitOps) one calling cluster: token hash reference, optional quota, disabled
Database release namespace the provider one provisioned database; do not create these by hand

Guides

  1. Install: chart, CRDs, the required TLS certificate.
  2. Configure shards and consumers.
  3. Rotate a consumer token.
  4. Add a shard.
  5. Recover a soft-deleted database.
  6. API reference.

Operational notes (metrics, alerts, audit events) are in Configure shards and consumers.