Skip to content

feat(dev_env): support hybrid kind control plane with remote k8s data plane - #799

Merged
VLukiantsev merged 5 commits into
mainfrom
feat/tools-dev-env-remote-k8s-hybrid
Sep 8, 2026
Merged

VLukiantsev merged 5 commits into
mainfrom
feat/tools-dev-env-remote-k8s-hybrid

Conversation

@VLukiantsev

@VLukiantsev VLukiantsev commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Introduces automated developer tooling in tools/dev_env for the hybrid KinD control plane + remote Kubernetes data plane workflow, allowing local developers to target a remote GKE cluster for WorkUnit execution via --remote-k8s, accompanied by complete developer documentation in tools/dev_env/README.md, README.md, and docs/developer.md.

Motivation & Context

Developing and testing XMC features that interact with real Kubernetes controllers (JobSet, Kueue admission, hardware-dependent pods on GPUs/TPUs) historically required deploying the entire heavy control plane to GKE, which takes 15–20 minutes per iteration. This PR enables a hybrid model where developers run the lightweight control plane locally in KinD (with 5-second reload cycles via dev_env reload) while automatically dispatching compute workloads to a remote GKE cluster.

Key Changes

  • Remote K8s Manager: Added tools/dev_env/remote_k8s_manager.py to discover API server endpoints and CA data, mint self-contained ServiceAccount bearer tokens via kubectl create token, and generate static remote-k8s-config Secrets in KinD with zero gcloud dependencies inside containers.
  • Config & Flags: Extended tools/dev_env/config.py with remote_k8s_context, remote_k8s_namespace, remote_k8s_service_account, and auto-derivation of GKE contexts and workload SAs.
  • CLI Integration: Added --remote-k8s-context (and --remote-k8s shorthand), --remote-k8s-namespace, and --remote-k8s-service-account flags to dev_env up in tools/dev_env/dev_env.py.
  • Kind & Helm Orchestration: Integrated secret provisioning into kind_manager.py and Helm value overrides into helm_deployer.py.
  • Diagnostics & Status: Updated kind_manager.py and local_runner.py status displays to report hybrid mode and target remote clusters.
  • Comprehensive Documentation: Expanded tools/dev_env/README.md with an end-to-end Hybrid Mode guide (context discovery, prerequisites, step-by-step quickstart, verification, troubleshooting), updated root README.md Documentation Index, and linked from docs/developer.md.

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Unit Tests:
    • bazel test //tools/dev_env/... (14/14 test targets passing, including new tests in config_test.py and remote_k8s_manager_test.py).
    • ./.githooks/pre-commit (Clean pass across all linters and security scanners).
  • Diff Sizing:
    • Production code: 367 lines (< 400 threshold)
    • Test code: 353 lines (< 1000 threshold)
    • Total code: 720 lines (< 1000 threshold)
    • Documentation: 185 lines (< 1000 threshold)
  • Live Hybrid Prototype Verification:
    • Bootstrapped hybrid KinD cluster targeting remote GKE cluster ... and Cloud Spanner instance ....
    • Created experiment experiments/6002, submitted WorkUnit 4 targeting cpu-queue.
    • Actuator in KinD consumed Redis task, validated token, and created JobSet on remote GKE.
    • Remote Kueue admitted JobSet, pod executed on real GKE node outputting "Hello from Hybrid KinD-GKE XMC".
    • Reconciler in KinD observed completion on remote GKE and transitioned state in Cloud Spanner to COMPLETED (state: 10).

TAG=agy
CONV=4adc92f3-5e2b-459f-bf97-73230c96ba0e


Stack created with GitHub Stacks CLI • Give Feedback 💬

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a hybrid execution model to the development environment, allowing local control plane services in KinD to orchestrate workloads on a remote GKE cluster. The reviewer identified a critical bug in remote_k8s_manager.py where captured command output is not decoded from bytes, which would result in a malformed token in the generated kubeconfig. Additionally, a bug in config.py was flagged where falsy boolean-like strings are incorrectly treated as context names, and a corresponding test update was suggested to mock stdout as bytes to properly validate the decoding logic.

Comment thread tools/dev_env/remote_k8s_manager.py Resolved
Comment thread tools/dev_env/config.py Resolved
@VLukiantsev
VLukiantsev force-pushed the feat/tools-dev-env-remote-k8s-hybrid branch from acf0b8d to 822369b Compare September 7, 2026 11:35
@VLukiantsev
VLukiantsev force-pushed the feat/tools-dev-env-remote-k8s-hybrid branch 3 times, most recently from ea941af to d4ac24c Compare September 7, 2026 14:42
@VLukiantsev
VLukiantsev marked this pull request as ready for review September 7, 2026 14:45
@VLukiantsev
VLukiantsev force-pushed the feat/tools-dev-env-remote-k8s-hybrid branch from d4ac24c to 2224ac3 Compare September 7, 2026 15:05
Base automatically changed from feat/actuator-helm-remote-k8s to main September 7, 2026 15:10
… plane

Enable a hybrid development and verification workflow where the lightweight
XMC control plane (Web UI, Dex OIDC, Redis, ESS, Actuator, Reconciler) runs
locally inside KinD with sub-second reload cycles, while workload compute
execution (JobSets, Kueue) and Cloud Spanner run against a remote GKE cluster.

Key changes:
- cmd/actuator/k8s_client: check KUBECONFIG before falling back to in-cluster config.
- deploy/helm: add remoteK8s configuration to mount remote-k8s-config kubeconfig secret
  and project GCP SA credentials alongside backend-oauth-secrets.
- tools/dev_env: introduce RemoteK8sManager to generate static, self-contained kubeconfig
  secrets directly from remote cluster contexts without requiring gcloud inside KinD containers.
- tools/dev_env: add --remote-k8s and --remote-k8s-context flags to dev_env CLI and auto-derive
  cluster context and workload service accounts.

TAG=agy
CONV=4adc92f3-5e2b-459f-bf97-73230c96ba0e
Address code review comments on PR #799:
- Decode `res.stdout` if bytes in `extract_remote_cluster_endpoint_and_ca` and `mint_service_account_token` to prevent TypeError when `capture_output=True` returns bytes.
- Introduce `_is_bool_flag` in `tools/dev_env/config.py` to recognize both truthy and falsy boolean flags so strings like "false" or "no" are not treated as cluster context names.
- Update `test_mint_service_account_token_success` unit test to return bytes.

TAG=agy
CONV=4adc92f3-5e2b-459f-bf97-73230c96ba0e
…ation index

- Expand tools/dev_env/README.md with a comprehensive user guide for the Hybrid Execution Model (`--remote-k8s`), including prerequisites, quickstart commands, configuration reference, security model, and troubleshooting.
- Add Local & Hybrid Development Guide to Documentation Index in root README.md.
- Add Local Development & Hybrid Execution section to docs/developer.md.
- Streamline _is_bool_flag in tools/dev_env/config.py using _BOOL_STRINGS frozenset.

TAG=agy
CONV=4adc92f3-5e2b-459f-bf97-73230c96ba0e
@VLukiantsev
VLukiantsev force-pushed the feat/tools-dev-env-remote-k8s-hybrid branch from 2224ac3 to 72a4201 Compare September 7, 2026 15:10
Comment thread tools/dev_env/config.py Resolved
Comment thread tools/dev_env/config.py Resolved
Comment thread tools/dev_env/config.py Resolved
Comment thread tools/dev_env/README.md Resolved
- Unify _parse_bool and _is_bool_flag in tools/dev_env/config.py.
- Extract _resolve_field helper to standardize CLI > Env > YAML precedence.
- Remove redundant aliases and standardize on REMOTE_K8S_CONTEXT and REMOTE_K8S_NAMESPACE.
- Clarify gcloud credentials command reference in tools/dev_env/README.md.

Comment links:
- #799 (comment)
- #799 (comment)
- #799 (comment)
- #799 (comment)

TAG=agy
CONV=4adc92f3-5e2b-459f-bf97-73230c96ba0e
janzak-dev
janzak-dev previously approved these changes Sep 8, 2026
Comment thread tools/dev_env/config.py Resolved
…799

- Sync branch with origin/main and resolve conflicts in tools/dev_env/dev_env.py and config_test.py.
- Unify REMOTE_K8S and enable_remote_k8s to canonical remote_k8s flag in tools/dev_env/config.py.
- Add test_remote_k8s_from_yaml unit test in tools/dev_env/config_test.py.

Comment link:
- #799 (comment)

TAG=agy
CONV=4adc92f3-5e2b-459f-bf97-73230c96ba0e
@VLukiantsev
VLukiantsev added this pull request to the merge queue Sep 8, 2026
Merged via the queue into main with commit ec219b2 Sep 8, 2026
11 checks passed
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.

2 participants