kata-qemu-longhorn backend supports disk-level snapshots of running sandboxes via Longhorn’s CSI VolumeSnapshot API. This unlocks three workflows:
- Pause — scale to 0 and (optionally) snapshot the disk for safekeeping.
- Resume — scale back to 1; the same disk re-attaches.
- Fork — clone a sandbox’s disk into a brand-new sandbox with its own pod, IP, and lifecycle.
These commands require the
kata-qemu-longhorn backend. The kata-firecracker-devmapper backend uses ephemeral devmapper LVs and doesn’t support persistent snapshots.Looking for memory-faithful or whole-cluster forking? That’s the k7d runtime, not k7’s Longhorn-based fork. k7d warm-forks a running VM in ~5 ms (memory, disk, processes, and network identity all survive) and can fork an entire live Kubernetes cluster in ~100 ms — see CoW fork and Cluster mode. The fork described on this page is disk-only: the clone boots fresh from a copy of the source’s disk.
Anatomy of a kata-qemu-longhorn sandbox
When you create a kata-qemu-longhorn sandbox, k7 provisions:
- A Longhorn PVC named
<sandbox>-root-lh, sized via--root-disk-size(default10Gi). - A Deployment with one replica, mounting the PVC at
/mnt/state(with persistence wrapper bind-mounts). - An ingress-deny
NetworkPolicyand an egress policy (CIDR or FQDN). - An optional
Secretfromenv_file.
/mnt/state (and to the rootfs via the bind-mount overlay) survives pod restarts because it lives on the PVC.
Pause
--pvc PVC_NAME— explicit PVC to snapshot. Defaults to<sandbox>-root-lh.--snapshot-class CLASS—VolumeSnapshotClass. Defaults tolonghorn(created by the playbook).
VolumeSnapshot object in the same namespace and persists until you delete it (kubectl delete volumesnapshot <name>).
Resume
/mnt/state is exactly as it was at pause time. If the pause took a snapshot, the snapshot remains available — useful for rollback if the resumed workload corrupts something.
Fork
- Create a
VolumeSnapshotof<source>-root-lh(auto-named or--snapshot). - Wait for
readyToUse: trueon the snapshot. - Create a new PVC
<new>-root-lhfrom the snapshot viadataSource. - Create a Deployment for the new sandbox using the cloned PVC.
- Wait for the new pod to be Ready.
- Delete the temporary snapshot (the cloned PVC is independent of it).
- Memory state (the new sandbox boots fresh)
- CPU registers / process state
- Network identity (the fork gets a new pod IP and is subject to its own NetworkPolicy)
Observed performance
Measured on a single Hetzner dedicated node (3× NVMe, Ubuntu 24.04, Longhornreplicas=1) — see PERFORMANCE.md:
Fork is roughly 3× slower than a cold create today — most of the time is the cloned PVC’s first attach (Longhorn replays cloned data).
Example: a parallel exploration with fork
A common AI workflow is to set up a heavy environment once, then explore many branches from it.exp-N boots from a clone of base’s disk — the heavy pip install doesn’t run again.
Cleanup
k7 delete demo removes the Deployment, the PVC, and any pause/fork snapshots associated with the sandbox. To inspect what’s still around:
tests/integration/ exercise pause/resume/fork end-to-end and detect orphaned Longhorn replicas or stuck PVCs.
Reference
- Performance baseline:
PERFORMANCE.md - Integration tests:
tests/integration/
