Repository navigation
Description
Context
Thrust's Postgres is CNPG thrust-pg (production) and thrust-pg-dev in woven-o11y. Both are built from the infra repository's shared chart modules/kube/cnpg-cluster/chart and reached through the tunnel thrust-pg and two Workers VPC TCP services (hosts thrust-pg-rw.thrust.svc.cluster.local and thrust-pg-dev-rw.thrust.svc.cluster.local), with Hyperdrive on top (ADR-0094 Option 1; research/0010 §11 and §12). pg_hba accepts TLS only, and the hop runs TLSv1.3. Because verify_ca failed against CNPG's private CA, both VPC services run with cert_verification_mode = disabled, which is now the default in products/thrust/cloudflare/variables.tf (ADR-0094:111; research/0010:324). The work happens in the infra repository (ApiraTech/infrastructure); this issue tracks it.
Problem
The database is not authenticated: whoever answers the connector's connection to the -rw Service becomes Hyperdrive's TLS peer. That was the finding of the PR #810 security review (ADR-0094:120). The owner accepted the state as temporary, with the deadline "closed before Thrust holds real data" (ADR-0094:120; Q-0094.9, QUESTIONS.md:351; beads plane-byd.9 and infra-qnyi). Q-0094.9 lists three options and picks none.
Two documented facts narrow the choice:
- Workers VPC trusts publicly trusted certificates and Cloudflare Origin CA, and in
verify_camode it verifies the certificate chain only and skips hostname verification (workers-vpc/configuration/vpc-services; ADR-0094:82). - Hyperdrive's own CA upload cannot be used with VPC-service origins (ADR-0094:82).
Proposal
Implements the ADR-0094 round-29 note. Start after the engine decision in #37; if the Durable Object cell wins, this issue is moot.
- Issue a Cloudflare Origin CA certificate for a hostname in a zone the account owns (validity up to 15 years).
verify_caskips hostname verification, so the name does not have to match the cluster-local Service host. - Expose
spec.certificates(serverTLSSecret,serverCASecret) in the shared chart as a strictly opt-in value, with the same shape aszoneSpread(research/0010:289-296). The nine other releases then see a chart version bump with byte-identical manifests; Q-0094.8 accepts that churn. Give the green copy inApiraTech/helm-chartsthe same value. - Deliver the certificate and key through ESO like the other Thrust secrets, never through the repository. Mount them on
thrust-pg-devfirst, then onthrust-pg. - Set both VPC services back to
verify_ca, and makeverify_cathe default invariables.tf. - Fallback, if Workers VPC rejects the chain: ADR-0094 Option 2, i.e. the tunnel plus an Access application and a service token, which is a connection-string origin. Upload CNPG's CA to Hyperdrive (
wrangler cert upload certificate-authority, then--ca-certificate-idand--sslmode verify-full). - Neither path has been tested. The first
hyperdrive.sh ensureagainst the new mode is the test.
Acceptance criteria
-
thrust-pg-devpresents the Origin CA chain. Verify with OpenSSL 3s_client -starttls postgres -CAfile <origin-ca.pem>and expectVerify return code: 0. Control: an unrelated throwaway CA must give a non-zero code; if the control passes, both results are void. - A clean
tofu planshows both VPC services atcert_verification_mode = verify_ca,hyperdrive.sh checkpasses for both configs, and a Worker readsssl = truefrompg_stat_ssl. - Control for the mode itself: a server certificate from a private CA still fails under
verify_ca, as it did on 2026-10-18, so the check discriminates. - Chart change:
just cnpg-cluster-conformancepasses with the existing goldens unchanged, a rawhelm templateof the nine other releases is byte-identical before and after, and a mutation that always rendersspec.certificatesfails the conformance check. - Q-0094.9 is answered with the measured result,
plane-byd.9andinfra-qnyiare closed, and the ADR-0094 note records which path shipped.
References
- Review: .agents/plans/contrail/reviews/2026-10-19-fable-architecture-review.md (FR-09)
- ADR-0094 (
.agents/plans/contrail/adrs/infra/0094-postgres-hosting-cnpg-tunnel-vpc.md:53-56,82,111,120); infra repo ADR 0022 (D4, TLS wording, per ADR-0094:96) - Q-0094.9 (
QUESTIONS.md:351), Q-0094.8 (QUESTIONS.md:345), Q-0094.2 (QUESTIONS.md:301) research/0010-thrust-postgres-infra-plan.md:280-282,289-296,311,324- Cloudflare docs: workers-vpc/configuration/vpc-services; Hyperdrive CA upload (changelog 2025-04-09)
- Beads: plane-byd.9, infra-qnyi
Blocked by: #37
Finding: FR-09
Activity
worker-pgcell and an instance-levelworker-doSQLite cell #37docs: ADR-0040 accepted as Postgres; spike 0002 decided; the worker-d…
feat(db): engine pass, search routes and the FR-22 order; spike 0002 …
docs(plans): record the thrust-pg-dev authenticated-TLS results (Q-00…
docs(plans): record that thrust-pg serves the Origin CA certificate t…
docs(plans): record the smoke test through the live Hyperdrive config…