Right-size sandbox to the worker pod's CPU/memory - #679
Open
Chenyi Wang (chw120) wants to merge 1 commit into
Open
Right-size sandbox to the worker pod's CPU/memory#679Chenyi Wang (chw120) wants to merge 1 commit into
Chenyi Wang (chw120) wants to merge 1 commit into
Conversation
Both sandbox runtimes (gVisor and micro-VM) previously sized themselves to the whole host rather than the ateom worker pod they run in. Add a common seam that discovers the pod's limits (Kubernetes downward API) and applies them, so each sandbox matches its pod. internal/sizing (shared by both runtimes): - Discover() reads ATEOM_SIZE_CPU_MILLI / ATEOM_SIZE_MEMORY_BYTES, injected by the controller via resourceFieldRef against the pod's limits.cpu / limits.memory. - ApplyToOCISpec() writes cgroup v2 CPU quota/period + memory.max into the OCI spec (skips unset fields; no-op when neither is set). - VCPUs() rounds milliCPU up to whole vCPUs. atecontroller: inject the two downward-API env vars on the ateom container. ateom-gvisor: apply sizing to the per-container cgroup leaf and pass runsc --cpu-num-from-quota on create/restore so the sentry's vCPU count is provisioned from the pod's CPU quota (not all host CPUs). ateom-microvm: size the cloud-hypervisor VmConfig (BootVcpus/MaxVcpus and Memory) to the pod, reserving a margin of guest RAM for the VMM + virtiofsd (host processes in the pod cgroup) so the pod does not OOM. The margin defaults to 256 MiB and is tunable via --vmm-mem-reserve-mib. demos: set template.resources (requests/limits) on the WorkerPools so the downward API has real limits to surface.
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.
Both sandbox runtimes (gVisor and micro-VM) previously sized themselves to the whole host rather than the ateom worker pod they run in. Add a common seam that discovers the pod's limits (Kubernetes downward API) and applies them, so each sandbox matches its pod.
internal/sizing (shared by both runtimes):
atecontroller: inject the two downward-API env vars on the ateom container.
ateom-gvisor: apply sizing to the per-container cgroup leaf and pass runsc --cpu-num-from-quota on create/restore so the sentry's vCPU count is provisioned from the pod's CPU quota (not all host CPUs).
ateom-microvm: size the cloud-hypervisor VmConfig (BootVcpus/MaxVcpus and Memory) to the pod, reserving a margin of guest RAM for the VMM + virtiofsd (host processes in the pod cgroup) so the pod does not OOM. The margin defaults to 256 MiB and is tunable via --vmm-mem-reserve-mib.
demos: set template.resources (requests/limits) on the WorkerPools so the downward API has real limits to surface.