Monorepo for Tangled forked from tangled.org/core
core spindle engines microvm
32 files

agent.go
args.go
bench-boot.sh
budget.go
cgroup_oom_test.go
cgroup_test.go
cgroup.go
dns_proxy_test.go
dns_proxy.go
engine_test.go
engine.go
image_test.go
image.go
models_test.go
models.go
netns_wrapper.sh.tmpl
networking.go
nixos_toplevel_cache.go
qemu.go
read_cache_proxy_test.go
read_cache_proxy.go
README.md
runner.go
start-test-cache.sh
test-spindle-microvm.sh
upload_cache_http.go
upload_cache_narinfo.go
upload_cache_nix_store_test.go
upload_cache_nix_store.go
upload_cache_proxy_test.go
upload_cache_proxy.go
vm.go
README.md
# spindle microVM engine This document describes the architecture of the microvm engine for spindle. In short it allows the spindle to spin up microvm guests, and implements a guest [agent protocol](../../agentproto) for communicating with those guests (via the [shuttle](../../../shuttle) implementation of that proto). It implements some fairly simple resource budgeting and optionally sets up cgroups for better enforcing resource limits, and hardens the VM network access. It has Nix cache integration for any paths built in the VM, those will get pushed to a Nix cache by the spindle (if one is configured). The runner is abstracted behind an interface; right now only the QEMU microVM impl is supported, but others (e.g. firecracker) can slot in later. Currently two kinds of images are supported: - NixOS images: these allow configuration such as `dependencies`, `services`, `virtualisation`, `registry`, `caches` in the workflow file itself. The guest agent will build (or if it's cached, spindle will send the store path for realization) and activate it before any workflow steps are ran. - Non-NixOS: this is mainly just Alpine for now, but can be anything else. Workflow-level configuration like NixOS aren't supported while using these. If Nix exists inside the image (like in our Alpine image) it will still be able to make use of the spindle cache. (For testing, you can run `bash spindle/engines/microvm/test-spindle-microvm.sh` from repo root. These test the Alpine & NixOS, and features like if Docker works, public internet is reachable, and so on.) ## Image builds Image builds right now are done via Nix: - For NixOS, we use [microvm.nix](https://github.com/microvm-nix/microvm.nix), and layer our own configs on-top, see [here](../../../nix/microvm). - For Alpine we have a small-ish Nix definition that includes fetching the kernel, initrd, kernel modules; setting up the init script that configures the VM proper; copying dependencies (like `nix` or `git`) into a rootfs and creating a squashfs fro…