Skip to content

feat(studio-cp,oab-mcp): K8sFleetBinding.expected_principal + k8s_fleet_config_write (studio#104) - #107

Open
brettchien wants to merge 1 commit into
feat/k8s-onboarding-namespace-sa-toolsfrom
feat/k8s-onboarding-fleet-config-write
Open

feat(studio-cp,oab-mcp): K8sFleetBinding.expected_principal + k8s_fleet_config_write (studio#104)#107
brettchien wants to merge 1 commit into
feat/k8s-onboarding-namespace-sa-toolsfrom
feat/k8s-onboarding-fleet-config-write

Conversation

@brettchien

Copy link
Copy Markdown
Contributor

Summary

Third sub-item of #104, stacked on #106 (please merge #105#106 → this in order).

  • K8sFleetBinding.expected_principal: Option<String> — deliberately named to match FleetBinding's AWS-side field. The verify machinery already exists symmetrically: observe_k8s_identity's SelfSubjectReview-derived principal + k8s_principal_kind classification is the same shape as observe_identity/identity_matches for AWS — this just wires the config schema field, no new verify logic needed. Typically system:serviceaccount:<ns>:<name> for a service account, or a plain username; unset = no identity check for that fleet (same "unset = don't check" contract AWS has).
  • k8s_fleet_config_write — new MCP tool mirroring fleet_config_write's AWS-side write path: validate text parses before writing, store bytes verbatim (comments/layout preserved), return the parsed fleets + raw text.

save_k8s_bindings_text (already existed, studio-cp/lib.rs:924) needed zero changes — it's a generic toml::from_str + verbatim write, so it picked up the new expected_principal field automatically once added to the schema structs (K8sFleetBinding, K8sFleetBody, the From<K8sFleetsDoc> conversion).

Unlike AWS bindings, k8s bindings aren't cached anywhere in OabMcp yet — nothing here dispatches provisioning to K8sDriver yet either (that's the separate deploy_provision provider-param item, still open in #104). So this write tool is a plain validate-then-write with no in-memory state to invalidate, unlike t_fleet_write which also drops a memoized-config cache.

Testing

Added a TOML round-trip test (k8s_fleet_expected_principal_parses_and_defaults_to_none) and updated the two existing K8sFleetBinding struct-literal tests for the new field.

Same local-build caveat as #105/#106: cargo check -p studio-cp -p oab-mcp OOM-kills on aws-sdk-ec2 on this machine (6th identical failure today, same pre-existing environment constraint) — hand-verified K8sFleetBindings/default_k8s_bindings_path/save_k8s_bindings_text signatures directly against source in this repo before writing this. CI is the real gate.

Scope note

deploy_provision's provider param (dispatch to K8sDriver) and console-side wiring are still open in #104 — this PR is backend-schema-and-write-path only.

Ref #104. Stacks on #106 (which stacks on #105) — merge in order.

…et_config_write (studio#104)

Third sub-item of #104, stacked on #106.

- K8sFleetBinding gets expected_principal: Option<String>, deliberately
  named to match FleetBinding's AWS-side field — the verify machinery
  already exists symmetrically (observe_k8s_identity's SelfSubjectReview-
  derived principal + k8s_principal_kind, same shape as observe_identity/
  identity_matches for AWS), this just wires the config schema to it.
  Typically a system:serviceaccount:<ns>:<name> string, or a plain
  username; unset = no identity check for that fleet.
- k8s_fleet_config_write: new MCP tool mirroring fleet_config_write's
  AWS-side write path (validate text parses, write bytes verbatim so
  comments/layout survive, return the parsed fleets + raw text).
  save_k8s_bindings_text (studio-cp/lib.rs) already existed and needed
  zero changes — it's a generic toml::from_str + verbatim write, so it
  picked up the new field automatically once added to the schema structs.
  Unlike AWS bindings, k8s bindings aren't cached anywhere in OabMcp yet
  (nothing dispatches provisioning to K8sDriver yet either — separate
  item), so this is a plain validate-then-write, no in-memory state to
  invalidate.

Ref: studio#104.
brettchien added a commit that referenced this pull request Aug 27, 2026
…104)

t_provision now branches on a new provider arg (default "aws", unchanged
behavior): "k8s" calls provision_from_library_k8s (#114) with context/
expected_principal taken as direct args, not resolved via a fleet name —
the console's identity form already collects context/namespace/service-
account directly (#108/#109), and for a brand-new fleet there's no existing
K8sFleetBinding to look up anyway. Fleet-scoped k8s lookup (for redeploying
into an already-known k8s fleet) is left as explicit future work, not
needed for this dispatch to exist.

Also updates deploy_provision's tool description, which was stale after
#113 (redeploy no longer requires an existing manifest) and needed the new
provider/context/expected_principal params documented.

NOTE — branch lineage: this stack (#112#113#114→this) was cut from `main`
before #104's original stack (#105-110) merged, not from #110 — so
K8sFleetBinding.expected_principal (originally #107) is re-added here too.
Identical field in both places; trivial merge conflict to resolve whenever
both land, flagging explicitly rather than silently duplicating without a
note.

With this, deploy_provision fully supports k8s end-to-end (provisioning
side) — the remaining piece for full onboarding is unblocking console's
k8s "Next" button (#108/#109's placeholder), a separate follow-up.

Ref: studio#104.
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.

1 participant