feat(selfhost): chart-managed RDS CA (global.rdsCa), no bundle download or hash pins (agent-relay 0.7.85)

Merged
KH
7d ago
+7352-179

Self-hosted EKS installs on RDS no longer download the RDS CA bundle, create the rds-ca ConfigMap or paste its sha256 into the values. The Automation Anywhere sandbox rehearsal hit both failure modes: pods stuck in ContainerCreating with configmap "rds-ca" not found, and an example hash left on some lines so the TLS pin did not match.

What changes for operators

global:
  rdsCa:
    bundle: us-east-1   # the RDS region, or global

That one value replaces the rds-ca download, kubectl create configmap and the four hand-pinned hashes. examples/aws/values.yaml now uses it and drops every postgresCa / caConfigMap / caSha256 block.

Design

  • Owner: the agent-relay umbrella. It ships AWS's public bundles in files/rds-ca/ (34 commercial regions plus global, fetched from truststore.pki.rds.amazonaws.com; manifest.yaml records URL, fetch date, bytes and sha256). templates/rds-ca.yaml renders the ConfigMap (ca.crt, name global.rdsCa.configMapName, default rds-ca) with .Files.Get and computes sha256sum at render time.

  • How the hash reaches the subcharts: through globals. A subchart cannot read the umbrella's files, so the umbrella's values.yaml carries a generated table, global.rdsCa.bundleSha256. The ConfigMap template fails if the bytes it renders do not hash to that table entry, so the mounted bytes and the pins cannot disagree. Each consuming chart has the same helper, templates/_rds-ca.tpl, synced from ci/rds-ca/_rds-ca.tpl by ci/rds-ca/sync.sh. CI fails when a copy drifts. The helper computes the effective CA for:

    • relaycast postgresCa (PostgreSQL backend only) and relay-control postgresCa;
    • in sessions-pipeline: the worker's postgresCa (which feeds nativeBrief's NATIVE_BRIEF_CA_SHA256), alleyoop's postgresCa, the read API's postgresCa (tlsProfile: custom-ca), the postgres blocks of the ingest edge, search indexer and native consumer, and sessionAnalysis.postgresTls (custom-ca).

    The native consumer's cross-chart equality checks compare these effective values.

  • Override (bring your own CA): a component that names another ConfigMap or a Secret keeps its own CA and hash, for a private CA or a database that is not RDS.

  • Fail loudly: with global.rdsCa set, a component that names rds-ca or nothing gets the managed CA. The render fails on:

    • a hand-set hash that differs from the bundle's;
    • a key other than ca.crt;
    • an unknown or malformed bundle;
    • a tampered bundleSha256 table;
    • global.rdsCa on a subchart installed without the umbrella.

    The all-zero placeholders in values-eks-rds-native.yaml count as unset, so that profile needs no hash override. Missing-hash errors in BYO mode now name global.rdsCa.bundle.

  • Backward compatible: with global.rdsCa.bundle empty, which is the default, nothing changes. Values that set configMap: rds-ca and explicit hashes render as before. examples/aws/values.yaml from origin/main renders byte-identical, the subdomain-golden hashes match without re-recording, and every chart's ci/*-values.yaml render is unchanged.

  • An rds-ca the release does not own: an existing rds-ca created by hand or by rds-setup.sh pre fails the install, via lookup, with kubectl -n <ns> delete configmap rds-ca. I tested on kind with Helm 3.17 and 4.1: taking it over in place with Helm's ownership label and annotations does not work under Helm 4's server-side apply. kubectl keeps owning .data.ca.crt, so the first different bundle (for example global after a regional pre) conflicts. Clearing managedFields did not help: the field then shows up as before-first-apply. Deleting the ConfigMap is safe: a running pod kept its mount, and the chart then owns the field alone. The ConfigMap carries helm.sh/resource-policy: keep, so turning global.rdsCa off leaves it in place for BYO values.

  • Scripts:

    • rds-setup.sh pre uses the checkout's shipped bundle (curl only when run standalone) and never rewrites a chart-managed rds-ca.
    • configure-rds.sh deletes pre's copy when the values set global.rdsCa.bundle, and no longer prints a hash to paste.
    • diagnose-install.py reports a ConfigMap that a release pod mounts but nobody created, a chart-managed rds-ca whose bytes no longer match its pin, and an invalid global.rdsCa.bundle.
  • Rotation: scripts/selfhost/refresh-rds-ca-bundles.sh (refresh, --check, --verify) plus a weekly RDS CA bundles workflow. When AWS changes a bundle, the workflow fails and posts the refresh diff and a patch artifact. --verify (offline) runs in the lint job through ci/rds-ca/test.sh.

databaseGuard (#552)

The guard used to read each component's CA straight from the values. Under global.rdsCa those values are empty, so it now resolves each component's effective CA with the same _rds-ca.tpl rules (the umbrella has its own synced copy). Its pre-install hook runs before rds-ca exists, so the hook carries the managed bundle in its own ConfigMap. Renders without global.rdsCa, the guard included, are byte-identical to origin/main. The guard's kind test brings its own test CA, so it now layers ci/rds-ca/legacy-values.yaml; all 17 cases pass locally.

Review fixes

  • Rolling restarts: Node workloads (relaycast, relay-control, worker, alleyoop) carry the pod annotation agentworkforce.dev/rds-ca-sha256, so a new bundle rolls them.
  • Fixed name: configMapName is removed; the managed ConfigMap is always rds-ca.
  • configure-rds.sh: it decides managed mode from the full helm template render with every values file, with errors shown. It keeps an rds-ca this release already manages and refuses one that another release owns.
  • Disabled blocks: a disabled block keeps its values untouched.
  • rds-setup.sh saves ca.crt byte for byte.
  • diagnose-install.py ignores optional mounts.

Size (Helm release Secret, 1 MiB limit)

Only the umbrella's own files go into the release. Subcharts are not serialized there, because Chart.dependencies is unexported in Helm's JSON. Estimated with ci/rds-ca/release-size.py, which mirrors Helm's base64(gzip(json)) encoding:

release Secret
origin/main (with #552), EKS example185,480 B (0.18 MiB)
this PR, EKS example, us-east-1490,860 B (0.47 MiB)
this PR, global (175 KB bundle rendered in rds-ca and the databaseGuard hook)707,436 B (0.67 MiB)

Shipping all regions fits, so the chart ships them all. self-hosted/requirements.yaml lists no regions to narrow to, and .Files.Get would not shrink the release anyway, because every chart file is stored. ci/rds-ca/test.sh fails above 0.9 MiB.

Tests

  • ci/rds-ca/test.sh (new, in Lint) runs 57 checks (including databaseGuard's hook CA, the restart annotations and a disabled component):

    • default off;
    • region: the ConfigMap bytes equal the shipped file, and every workload mounts rds-ca and pins the same hash (read API, ingest edge, search indexer and its bootstrap Job, nativeBrief), with NODE_EXTRA_CA_CERTS on relaycast, relay-control and worker;
    • global; a renamed ConfigMap;
    • override: a private ConfigMap or a Secret source is kept; a matching hand-set hash and the zero placeholder are accepted;
    • 11 failure cases;
    • legacy values (ci/rds-ca/legacy-values.yaml) and the eks-rds-native profile with site values render unchanged; legacy values whose hash matches the bundle work under global.rdsCa;
    • helper sync, bundle/manifest/table agreement, release size.
  • scripts/selfhost/tests/rds-setup-test.sh: two new cases (shipped bundle used; a chart-managed rds-ca is left alone). scripts/support/tests: two new cases (39 tests).

  • I ran Lint's suites in a Linux container (helm v4.3.1, the CI version) on this branch and on origin/main. Both trees give the same results:

    • pass on both: selfhost tests, registry and its regression tests, subdomain golden, render.sh, rds-ca.
    • charts.sh static fails on both with the same single error (relaychief-control: the server must run the image default command).
    • matrix.sh static fails on both with the same two HOOPDB_DB_MODE errors.

    I believe these two come from the container's yq version and say nothing about this branch; CI will show.

  • version-bump.sh passes. The lock files change only in the bumped file:// versions, the digest and the generated time.

Charts: agent-relay 0.7.85 (#552 took 0.7.84), relaycast 0.3.18, relay-control 0.4.27, sessions-pipeline 0.8.61, sessions-pipeline-worker 0.7.16, session-ingest-api 0.4.6, session-read-api 0.2.18. Rebased on #551, #552, #555, #557 and #558.

Follow-up: configure-rds.sh downloads rds-setup.sh pinned to the 2026.11.18 tag. That older copy still re-applies rds-ca. Until the pin moves to a release with this change, configure-rds.sh deletes that copy itself in managed mode. Docs PR: AgentWorkforce/agentrelay.com#340 (it depends on this PR and on a release that includes it).

🤖 Generated with Claude Code