Skip to content

feat(oabctl): K8sDriver skeleton — apply/scale/delete against a Deployment (slice 3b) - #99

Open
brettchien wants to merge 1 commit into
feat/k8s-driver-slice3a-trait-extractionfrom
feat/k8s-driver-slice3b-k8sdriver-skeleton
Open

feat(oabctl): K8sDriver skeleton — apply/scale/delete against a Deployment (slice 3b)#99
brettchien wants to merge 1 commit into
feat/k8s-driver-slice3a-trait-extractionfrom
feat/k8s-driver-slice3b-k8sdriver-skeleton

Conversation

@brettchien

Copy link
Copy Markdown
Contributor

Summary

Sub-slice 3b of #97 (K8s driver — ADR #63 slice 3): K8sDriver, a second ProvisionDriver implementation behind kube-rs, alongside EcsDriver.

  • apply() — builds a k8s Deployment from an OABServiceManifest and server-side-applies it: image, command = ["openab","run","-c",configFrom] (same convention EcsDriver uses), env NAMESPACE/NAME/BOOTSTRAP_FROM, cpu/memory as resource requests+limits, serviceAccountName/nodeSelector/tolerations from KubernetesRuntime.
  • scale() — patches spec.replicas, same 0/1-only constraint as ECS (single bot token).
  • delete() — deletes the Deployment, idempotent on 404.
  • K8sDriver::from_context(Option<&str>) — kubeconfig context resolution; None uses the kubeconfig's current context (same "ambient default, explicit override" shape aws_config gives EcsDriver). This is also the path orbstack's local cluster will use later (3f) — just another context.
  • Naming: Deployment = oab-{name}, in the k8s namespace = OAB's own metadata.namespace directly (a k8s namespace is already an isolation boundary, same job OAB's namespace does for ECS's flat oab-{ns}-{name}) — so no need to fold namespace into the resource name like ECS does.

Explicitly out of scope (bails loudly, doesn't silently mis-deploy)

  • spec.bundleFrom — needs a ConfigMap/volume carrier. Sub-slice 3c.
  • spec.secrets — ECS resolves into Secret.valueFrom ARNs; k8s needs a different output shape (a Secret key selector). Sub-slice 3d.
  • Observing k8s state into the canonical 6-state (status.rs's ECS service_status/instance_status has no k8s counterpart — needs a new agent-lifecycle RuntimeDriver impl per ADR-2's 6-state⇄k8s mapping table). Big enough to be its own follow-up rather than growing this PR.
  • Wiring K8sDriver into studio_api's actual dispatch — studio_api's functions take aws_config::SdkConfig, meaningless for k8s; real dispatch needs the driver-selection input FleetBinding (3f) provides. K8sDriver conforms to ProvisionDriver and has its own test suite, same "declare the seam, second side fills in when it exists" precedent as manifest::Runtime::Kubernetes itself.

Stacking note

Branched from #98 (3a, still unmerged) — 3a's own follow-up commit fixed ProvisionDriver's ECS-leaky signature (cluster moved onto the driver instance) right before this, which K8sDriver needed anyway. GitHub will show 3a+3b combined in the diff until #98 merges; the diff narrows to just this once it does.

Testing

cargo test -p oabctl (92/92, 7 new) + cargo clippy -p oabctl --all-targets -- -D warnings — both clean, via CARGO_PROFILE_DEV_DEBUG=0 (this box's 21G disk + memory can't build full debug info for the aws-sdk+kube dependency tree — full-workspace build deferred to CI as usual here).

Ref #97.

…yment (slice 3b)

Second ProvisionDriver impl, behind kube-rs. Scope deliberately narrow:

- apply(): builds a k8s Deployment from an OABServiceManifest (image,
  command = `openab run -c <configFrom>` — same convention EcsDriver uses,
  env NAMESPACE/NAME/BOOTSTRAP_FROM, cpu/memory as resource requests+limits,
  service account / node selector / tolerations from KubernetesRuntime),
  server-side-applies it. Deployment name is `oab-{name}` — OAB's own
  `namespace` maps directly onto the k8s namespace (already an isolation
  boundary, the same job it does for ECS's flat `oab-{ns}-{name}` naming),
  so unlike ECS there's no need to fold namespace into the resource name.
- scale(): patches replicas, same 0/1-only constraint as EcsDriver.
- delete(): deletes the Deployment, idempotent on 404.
- Kubeconfig context resolution: `K8sDriver::from_context(Option<&str>)` —
  `None` uses the kubeconfig's current context, same "ambient default,
  explicit override" shape aws_config uses. This is also how orbstack's
  local cluster gets targeted later (3f) — just another context, no
  special-casing.

Explicitly NOT handled yet, and apply() bails loudly rather than silently
mis-deploying if a manifest needs them:
- spec.bundleFrom (persona/skills bundle) — needs a ConfigMap/volume carrier,
  sub-slice 3c.
- spec.secrets — ECS resolves into Secret.valueFrom ARNs; k8s needs a
  different output shape (a Secret key selector), sub-slice 3d.

Also out of scope for this PR: observing k8s state into the canonical
6-state (status.rs's ECS service_status/instance_status has no k8s
counterpart yet — a new agent-lifecycle RuntimeDriver impl per ADR-2's
6-state<->k8s mapping table). Substantial enough to land as its own
follow-up rather than growing this one further.

Adds kube 0.99 + k8s-openapi 0.24 (rustls-tls, no openssl).

Stacked on #98 (3a) — this branch is 3a's branch + the K8sDriver commit;
GitHub will show 3a+3b combined in the diff until #98 merges, at which point
the diff narrows to just this. 7 new unit tests, 92/92 total green, clippy
-D warnings clean.

Ref: studio#97 (K8s driver — ADR #63 slice 3, sub-slice tracking)
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