feat(substrate): render BYO extraContainers in the SandboxAgent ActorTemplate - #2691
Open
carlochessamp wants to merge 1 commit into
Open
Conversation
…Template buildSandboxAgentActorTemplate only ever emitted the agent container, so byo.deployment.extraContainers (and the declarative equivalent) silently disappeared for SandboxAgents on substrate — the translator pod template carries them, but every SandboxAgent reconciles through substrate on 0.10, where there is no pod. Render them as additional ActorTemplate containers. The gVisor sandbox gives them the sidecar semantics a Kubernetes pod would: one shared loopback network namespace, separate rootfs/mount namespaces. Sidecars like a credential-brokering forward proxy (127.0.0.1:<port>) work unchanged. Substrate containers are a strict subset of corev1.Container, so the conversion is explicit and fail-closed: - image must be digest-pinned (pinImageRef, per container) - command must be explicit (same rule as the BYO agent cmd) - env keeps literals and secretKeyRef; envFrom/configMapKeyRef drop - an HTTP readiness probe maps to Readyz (named ports resolve against the container's own containerPorts) - volumeMounts are rejected: ActorTemplate volumes only support a single durableDir, already consumed by the agent's /data session store - at most 10 containers (CRD MaxItems) Extras append after the agent container; applyDurableDirSessionStore keeps mounting /data on Containers[0].
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.
What
buildSandboxAgentActorTemplateonly ever emitted the agent container, sobyo.deployment.extraContainers(and the declarativedeployment.extraContainers) silently disappeared for SandboxAgents on substrate. The translator's pod template carries them, but on 0.10 every SandboxAgent reconciles through the substrate backend — there is no pod — so extra containers were dropped on the floor.This renders them as additional ActorTemplate containers. The gVisor sandbox gives them the sidecar semantics a Kubernetes pod would: one shared loopback network namespace, separate rootfs/mount namespaces per container. Sidecars like a credential-brokering forward proxy listening on
127.0.0.1:<port>work unchanged.Why
A sidecar is the standard way to attach e.g. a credential broker, log shipper, or local proxy to a workload.
byo.deployment.extraContainersalready exists in the CRD and works on the agent-sandbox platform; on substrate the same field currently no-ops, which is the worst failure mode: the CR validates, syncs, and the sidecar just never runs.How
Substrate containers are a strict subset of
corev1.Container, so the conversion is explicit and fail-closed:pinImageRef, applied per container)ValidateSubstrateSandboxAgentSpecalready enforces for the BYO agentcmd(substrate copies Command verbatim into the OCIProcess.Args, no image-entrypoint fallback)secretKeyRef(the ate control plane resolves the latter server-side, per container);envFromandconfigMapKeyRefdrop, assanitizeActorTemplateEnvVaralready does for the agent containerReadyzso actor readiness keeps gating on the sidecar; named ports resolve against the extra container's owncontainerPorts(the translator only registers the agent container'shttpport). TCP/exec probes have no substrate equivalent and are ignoredvolumeMountsare rejected: ActorTemplate volumes only support a singledurableDir, already consumed by the agent's/datasession store — silently ignoring mounts would misconfigure sidecars that depend on themMaxItems)Extras append after the agent container;
applyDurableDirSessionStorekeeps mounting/dataonContainers[0]. The shape hash covers the whole spec, so adding/removing a sidecar fans out blue-green like any other spec change (asserted in tests).Testing
go test ./core/pkg/sandboxbackend/substrate/...— newTestBuildSandboxAgentActorTemplateExtraContainerscovers: rendering alongside the agent (env literal + secretKeyRef preserved, configMapKeyRef dropped, no volume mounts, readyz mapped, image stays pinned, shape-hash/template-name change), named readiness-port resolution, and the failure modes (unpinned image, missing command, volume mounts, unresolvable named port, >10 containers). All pre-existing substrate/translator/api tests pass unchanged.Verified end to end against a real rendered
SandboxAgent(helm-rendered values carrying an agent-vault credential-brokering sidecar): the CR → translator pod template → patched builder produces the expected two-container ActorTemplate with per-container env isolation.