feat(studio-cp): k8s fleet binding config schema — separate fleets-k8s.toml (slice 3f) - #102
Open
brettchien wants to merge 1 commit into
Open
Conversation
…s.toml (slice 3f) K8sFleetBinding/K8sFleetBindings, the k8s counterpart to the existing AWS FleetBinding/FleetBindings: a fleet's context+namespace instead of cluster+profile, resolve_binding_driver -> oabctl::K8sDriver instead of resolve_binding_config -> aws_config::SdkConfig. Deliberately a **separate file** (fleets-k8s.toml, $OAB_K8S_FLEETS_CONFIG), not a second [k8s_fleet.*] table in the existing fleets.toml. Reason: save_bindings_text/save_k8s_bindings_text are both whole-file verbatim writes (the console's TOML editor round-trips exact text, comments and all). Two tables sharing one file means saving either one from the UI would silently clobber the other's edits on the next write -- concretely, editing a k8s fleet in the console could wipe Brett's actual prod fleets.toml ([fleet.orca]/[fleet.mira], the ECS bindings that already gate real AWS credential selection -- see the fleets-toml-binding incident history). Separate files make that class of bug structurally impossible rather than relying on a careful merge in the write path. read_bindings_text/write_bindings_atomic are reused as-is for the k8s file (they're already path+text generic, no AWS types) -- only the TOML-shaped type being parsed differs. Scope: backend config-schema + load/save only. The console UI panel that actually lets an operator pick AWS-vs-k8s and edit fleets-k8s.toml is frontend work, not attempted here. Stacked on #100 (3d) -- resolve_binding_driver needs oabctl::K8sDriver, which only exists on the unmerged 3a/3b branch chain. 8 new tests (23/23 total in studio-cp), clippy introduces no new warnings (2 pre-existing ones elsewhere in studio-cp/studio-compose, untouched). Ref: studio#97 (K8s driver — ADR #63 slice 3, sub-slice tracking)
brettchien
added a commit
that referenced
this pull request
Aug 22, 2026
…pre_seed (slice 3c) Root-cause fix for the gap studio#97's slice-3c investigation found: nothing in openab downloads bundleFrom's loose-file S3 prefix back into ~ at boot. push_bundle (slice 2, already merged) only ever built the upload half; no restore mechanism was ever wired to the other end, on ECS or anywhere else. openab's only "S3 -> ~" feature is hooks.pre_seed, and it consumes zip archives, not a prefix of individual objects -- a different shape nothing bridged. Fix: reuse pre_seed instead of building a bespoke restore mechanism per platform. - studio_compose::Bundle::zip_bytes() -- a deterministic zip of the bundle's files (still pure/no-I/O: ZipWriter writes to an in-memory Cursor<Vec<u8>>). - oabctl::studio_api::bundle_zip_uri/inject_pre_seed_hook -- the zip's S3 URI, and appending a [hooks.pre_seed] section to a config.toml's bytes pointing at it. Appends rather than re-parsing+re-serializing, so an operator's existing comments/formatting survive; a no-op if hooks.pre_seed is already present (never overrides an operator's own hook). - control_plane::resolve_bucket exposed pub, so a caller can resolve the bucket before constructing objects (needed to compute the zip URI ahead of upload) instead of after, avoiding a second implicit resolution. - provision_from_library (studio-cp): resolves the bucket once, injects the hook into the composed config.toml object, uploads the zip alongside the existing per-file objects (kept for now -- harmless, and removing them is a separable decision). - K8sDriver: removed the bundle_from bail entirely. This is the actual payoff -- pre_seed is orchestrator-agnostic (S3 GetObject + extract, same binary/feature regardless of what started the process), and build_deployment already points the container's command at configFrom exactly like EcsDriver does, so a k8s pod restores its bundle through the identical mechanism with zero k8s-specific carrier code. No ConfigMap, no volume, no init-container -- slice 3c's original scope turned out not to exist once the actual restore path was fixed. Fixes both the ECS gap and the k8s driver in one change; the two platforms now share one restore mechanism instead of doubling the maintenance surface with a bespoke k8s carrier. 11 new tests across oabctl/studio-compose/studio-cp (145/145 total across the three crates), clippy clean (no new warnings; 3 pre-existing ones elsewhere untouched). Stacked on #102 (3f) -- needs K8sDriver + the driver-side test fixtures from the earlier branches in the chain. Ref: studio#97 (K8s driver — ADR #63 slice 3, sub-slice tracking)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sub-slice 3f of #97 (K8s driver — ADR #63 slice 3):
K8sFleetBinding/K8sFleetBindings, the k8s counterpart to the existing AWSFleetBinding/FleetBindings(runtime-identity-context ADR-19).FleetBinding, existing)K8sFleetBinding, this PR)cluster(ECS cluster name)context(kubeconfig context,None= current-context) +namespaceprofile/region→resolve_binding_config→aws_config::SdkConfigresolve_binding_driver→oabctl::K8sDriverexpected_principal(IdentityMismatch)fleets.tomlfleets-k8s.toml(own file, see below)Why a separate file, not a second table in
fleets.tomlsave_bindings_textis a whole-file verbatim write — the console's TOML editor round-trips exact text (comments, layout) for one file. If AWS and k8s bindings sharedfleets.tomlas two tables, saving either one from the UI would silently clobber the other's edits on the next write. Concretely: editing a k8s fleet in the console could wipe Brett's actual prodfleets.toml([fleet.orca]/[fleet.mira]— the ECS bindings that already gate real AWS credential selection, see the fleets-toml-binding incident this ADR exists because of). Two files makes that bug class structurally impossible instead of relying on a careful merge in the write path.read_bindings_text/write_bindings_atomicare reused as-is (already path+text generic, no AWS types) — only the parsed type differs.Not ported:
expected_principal/IdentityMismatchAWS's
expected_principalreconciles the resolved STS ARN against a declared expectation. A k8s equivalent (comparingobserve_k8s_identity's resolvedSelfSubjectReviewusername against a declared expectation) is a real, do-able follow-up, but not required for the config schema itself to be useful — left out to keep this PR to the schema+load/save surface.Scope note
Backend only (config schema + load/save, mirroring the existing AWS side exactly). The console UI panel that lets an operator actually pick AWS-vs-k8s per fleet and edit
fleets-k8s.tomlis frontend work, not attempted here.Stacking note
Branched from #100 (3d) —
resolve_binding_driverneedsoabctl::K8sDriver, which only exists on the unmerged 3a→3b→3d branch chain.Testing
cargo test -p studio-cp(23/23, 8 new) clean.cargo clippy -p studio-cpintroduces no new warnings (2 pre-existing ones elsewhere instudio-cp/studio-compose, untouched by this diff).Ref #97.