feat(sandbox): Add kubernetes sandbox support - #126
Open
whatever wants to merge 3 commits into
Open
Conversation
whatever
marked this pull request as draft
August 3, 2026 23:46
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 5, 2026 19:17
3240829 to
f187ec8
Compare
This was referenced Aug 5, 2026
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
2 times, most recently
from
August 5, 2026 20:44
24824d2 to
1e9e6f9
Compare
whatever
force-pushed
the
context-shortener-node
branch
from
August 5, 2026 20:51
41a012b to
94a629f
Compare
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 5, 2026 20:51
1e9e6f9 to
3a7d243
Compare
whatever
force-pushed
the
context-shortener-node
branch
from
August 5, 2026 20:56
94a629f to
cac23a9
Compare
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 5, 2026 20:58
3a7d243 to
b29c350
Compare
whatever
force-pushed
the
context-shortener-node
branch
from
August 5, 2026 21:03
cac23a9 to
d09e9fe
Compare
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 5, 2026 21:04
b29c350 to
34e02ca
Compare
whatever
marked this pull request as ready for review
August 5, 2026 23:20
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 6, 2026 00:54
34e02ca to
6140030
Compare
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 6, 2026 01:30
6140030 to
8970347
Compare
Introduces a sandbox backend factory that dispatches between Docker (default) and Kubernetes, so cwpro deployments without Docker-in-Docker can run hunter agents as K8s Pods. New modules: - sandbox/factory.py: backend dispatcher (CLEARWING_SANDBOX_BACKEND env) - sandbox/kube_sandbox.py: KubeSandboxContainer — same interface as SandboxContainer but backed by K8s Pods with exec-based I/O - sandbox/kube_builder.py: on-cluster image building via Kaniko Jobs with content-hash tagging and registry push HunterSandbox changes: - build_image() short-circuits for k8s: resolves images from CLEARWING_SANDBOX_IMAGE override or builds on-cluster via Kaniko - spawn() uses create_sandbox() factory instead of direct SandboxContainer Also updates the sandbox-unavailable warning to reference k8s as an alternative to Docker.
…afety Fixes critical issues identified during code review: - exec() now uses WSClient with separate channels + parses the real exit code from channel 3 status JSON (was silently returning 0 for everything) - write_file/copy_tree_into pipe tar directly via stdin instead of base64-in-shell (no arg size limits, no injection risk, single round-trip) - Sandbox pods get activeDeadlineSeconds (3x timeout, floor 15min) so zombies self-terminate if our process crashes - ownerReference set to parent pod when running in-cluster — k8s GC cascades deletion on parent crash - Extracted shared kube_client.py (cached ApiClient, namespace(), owner ref helper) — eliminates duplicated config loading and repeated token file reads
whatever
force-pushed
the
feat/kubernetes-sandbox
branch
from
August 6, 2026 02:35
8970347 to
b86e547
Compare
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
CLEARWING_SANDBOX_BACKEND=kubernetes) so cwpro deployments without Docker-in-Docker can run hunter agent containers as Kubernetes PodsKubeSandboxContainerimplements the sameSandboxContainerinterface (start/exec/write_file/read_file/copy_tree_into/stop) backed by K8s Pod lifecycle + execCLEARWING_SANDBOX_REGISTRY)HunterSandbox.build_image()short-circuits for k8s: resolves fromCLEARWING_SANDBOX_IMAGEoverride or builds on-clusterspawn()usescreate_sandbox()factory dispatch instead of directSandboxContainerinstantiationEnvironment variables
CLEARWING_SANDBOX_BACKENDdocker(default) orkubernetesCLEARWING_SANDBOX_IMAGECLEARWING_SANDBOX_REGISTRYCLEARWING_SANDBOX_NAMESPACECLEARWING_KANIKO_IMAGECLEARWING_KANIKO_SERVICE_ACCOUNTTest plan
_effective_agent_modefallback)