feat(studio-cp): k8s identity/context observation — RuntimeContext for kubeconfig contexts (slice 3e) - #101
Open
brettchien wants to merge 1 commit into
Open
Conversation
…r kubeconfig contexts (slice 3e)
observe_k8s_identity(context) is the k8s counterpart to the existing AWS
observe_identity(aws_config) — same RuntimeContext struct, per ADR-19's
AWS-driver/k8s-driver field mapping table:
principal <- SelfSubjectReview username (authentication.k8s.io/v1,
stable since k8s 1.28 — the literal API `kubectl auth
whoami` calls; a live server round-trip, not a value read
out of the kubeconfig file, matching how observe_identity
uses a live STS GetCallerIdentity rather than trusting the
configured profile)
principal_kind <- "service-account" / "user" / "unknown", mirrors
principal_kind's role/user/unknown split
scope <- "{cluster}/{namespace}" from the kubeconfig context entry
location <- left empty: k8s has no first-class region/zone concept
the way AWS does, so there's nothing honest to fill in
(same "empty if unset" contract location already has)
source <- "kubeconfig context: <name>"
caller_id <- SelfSubjectReview's UserInfo.uid
context = None uses the kubeconfig's current-context, mirroring
K8sDriver::from_context's "ambient default, explicit override" shape.
Adds kube 0.99 + k8s-openapi 0.24 to studio-cp (same versions oabctl
already pulls in slice 3b). 1 new test (k8s_principal_kind), 18/18 total
green in studio-cp. clippy clean for this code specifically — studio-cp/
studio-compose already carry a few pre-existing warnings elsewhere in the
crate, untouched by this change, not part of CI's gate for these crates.
Not stacked on #98/#99/#100 — this only touches studio-cp, independent of
oabctl's driver work, so it branches from main directly.
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 3e of #97 (K8s driver — ADR #63 slice 3):
observe_k8s_identity, the k8s counterpart to the already-shipped AWSobserve_identity(runtime-identity-contextADR-19). SameRuntimeContextstruct, populated per ADR-19's AWS-driver/k8s-driver field mapping table:observe_identity, existing)observe_k8s_identity, this PR)principalSelfSubjectReviewusernameprincipal_kindscope{cluster}/{namespace}locationsourcekubeconfig context: <name>caller_idUserIdSelfSubjectReview'sUserInfo.uidprincipal/caller_idcome from a liveSelfSubjectReviewcall (authentication.k8s.io/v1, stable since k8s 1.28 — the literal APIkubectl auth whoamiuses), not a value read out of the kubeconfig file. That matchesobserve_identity's own shape: a live STSGetCallerIdentity, not trust in the configured profile — this ADR exists specifically because a configured identity silently not being the effective one was a real incident.context = Noneuses the kubeconfig'scurrent-context, mirroringK8sDriver::from_context's (#99) "ambient default, explicit override" shape — same path orbstack's local cluster will use later (3f).locationis deliberately left empty — k8s has no first-class region/zone concept the way AWS does, so there's nothing honest to fill in (same "empty if unset" contractobserve_identity's ownlocationalready has when region is unset).Scope note
This isn't stacked on #98/#99/#100 — it only touches
studio-cpand doesn't useK8sDriverat all (does its own kubeconfig resolution, same patternobserve_identityalready uses for AWS — it doesn't go throughEcsDrivereither). Branches frommaindirectly.Wiring this into the console panel itself, and
FleetBindinggaining k8s fields (context/cluster/namespace) to select which identity to show, is 3f.Testing
cargo test -p studio-cp(18/18, 1 new) — clean.cargo clippy -p studio-cpshows a couple of pre-existing warnings elsewhere instudio-cp/studio-compose(untouched by this change, not part of CI's gate for these crates) — nothing new from this diff.Ref #97.