Run boxfork on a few Linux machines with k3s
This guide is for a team that has a few Linux machines and no Kubernetes, and wants sandboxes on all of them. It makes a small Kubernetes cluster from three plain machines with k3s, and installs boxfork on it. At the end, your agents create, fork and kill sandboxes on the three machines from the Python SDK, as on one machine. When you drain a machine, its sandboxes move to a different machine with their files and their IDs. It takes about one hour, most of it for the commands on each of the three machines.
For one machine, install.md is simpler. For a cluster that you have, read install.md. Decision 17 gives the reason for Kubernetes.
The guide uses CPU sandboxes only, because the API service on Kubernetes refuses a sandbox with a GPU at this time. For GPUs, use one machine: see gcp.md. On 6 December 2026, a script did all steps of this guide on three new machines: What ran on real machines gives the record.
Before you start
Section titled “Before you start”You need three machines:
| Item | Value |
|---|---|
| System | Ubuntu 24.04, x86_64 or arm64. Other distributions of Linux with systemd can work, but we did not try them. |
| Size | 4 CPUs, 16 GB of memory and 50 GB of disk for each machine |
| Network | One private network for the three machines, and access to the internet |
| Access | SSH from your computer to each machine, with sudo |
The guide calls one machine the server and the two other machines the agents, and all three run sandboxes.
The machines must reach each other at these ports. The k3s documentation gives the full list.
| Port | From | To | Use |
|---|---|---|---|
| 6443/tcp | The agents | The server | The Kubernetes API server |
| 8472/udp | Each machine | Each machine | The pod network of k3s (flannel VXLAN) |
| 10250/tcp | Each machine | Each machine | The kubelet |
Caution: Do not open these ports, or the port 30500, to the internet. Port 30500 is the registry of the snapshots on each node.
Your computer needs:
- a checkout of boxfork
kubectland Helm- Docker or Podman, to build the images
- Python 3.9 or later, for the SDK
Step 3 builds the images on your computer, as the recorded run did. Since version 0.1.0, each release also publishes the images on GHCR, and the chart uses them by default. This guide was not run with the published images.
In the commands, replace these names with your values:
| Name | Value |
|---|---|
SERVER |
The SSH address of the server, for example ubuntu@203.0.113.10 |
AGENT1, AGENT2 |
The SSH addresses of the agents |
SERVER_IP |
The private IP address of the server, for example 10.128.0.5 |
NODE_CIDR |
The address range of the private network of the machines, for example 10.128.0.0/20 |
1. Install k3s
Section titled “1. Install k3s”-
On the server, install k3s:
Terminal window curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.37.3+k3s1 sh - -
On the server, show the join token. Keep it secret, because with it a machine can join the cluster.
Terminal window sudo cat /var/lib/rancher/k3s/server/node-token -
On each agent, put the token in a file that only root can read:
Terminal window sudo mkdir -p /etc/rancher/k3ssudo sh -c 'umask 077; cat > /etc/rancher/k3s/token'Paste the token, push Enter, then push Ctrl-D.
-
On each agent, install k3s as an agent of the server:
Terminal window curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.37.3+k3s1 \K3S_URL=https://SERVER_IP:6443 K3S_TOKEN_FILE=/etc/rancher/k3s/token sh - -
On your computer, get the kubeconfig of the server:
Terminal window ssh SERVER sudo cat /etc/rancher/k3s/k3s.yaml > ~/.kube/k3s-boxforkchmod 600 ~/.kube/k3s-boxforkexport KUBECONFIG=~/.kube/k3s-boxfork -
In a different terminal, open an SSH tunnel to the API server. The kubeconfig gives the address
https://127.0.0.1:6443.Terminal window ssh -N -L 6443:127.0.0.1:6443 SERVER -
Make sure that the three nodes are
Ready:Terminal window kubectl get nodes -o wide
The column CONTAINER-RUNTIME gives the version of containerd. k3s 1.37 has containerd 2.
2. Install gVisor on each node
Section titled “2. Install gVisor on each node”Each sandbox is a pod that runs under gVisor, so each node needs the programs of gVisor and two runtimes in containerd: runsc and runsc-offline.
k3s writes the configuration of its containerd itself, from a template, so you add the runtimes to the template, not to config.toml.
Do steps 1 to 5 on each of the three machines.
-
Download a release of gVisor, and make sure that it is correct:
Terminal window cd "$(mktemp -d)"url=https://storage.googleapis.com/gvisor/releases/release/20261130.0/$(uname -m)curl -fsSL -O $url/gvisor.tar.bz2 -O $url/gvisor.tar.bz2.sha512sha512sum -c gvisor.tar.bz2.sha512 -
Install the programs:
Terminal window tar -xjf gvisor.tar.bz2sudo install -m 755 runsc containerd-shim-runsc-v1 /usr/local/bin/sudo mkdir -p /usr/local/bin/gvisor-binsudo cp -r gvisor-bin/. /usr/local/bin/gvisor-bin/sudo chmod -R a+rx /usr/local/bin/gvisor-bin -
Write the settings of the two runtimes.
overlay2 = "none"puts the files of a sandbox on the disk, where a snapshot finds them.Terminal window sudo mkdir -p /etc/containerdprintf '[runsc_config]\n overlay2 = "none"\n' | sudo tee /etc/containerd/runsc.tomlprintf '[runsc_config]\n overlay2 = "none"\n network = "none"\n' | sudo tee /etc/containerd/runsc-offline.toml -
Write the template of containerd,
/var/lib/rancher/k3s/agent/etc/containerd/config-v3.toml.tmpl. The first line keeps the configuration that k3s makes:{{ template "base" . }}[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runsc]runtime_type = "io.containerd.runsc.v1"[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runsc.options]TypeUrl = "io.containerd.runsc.v1.options"ConfigPath = "/etc/containerd/runsc.toml"[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runsc-offline]runtime_type = "io.containerd.runsc.v1"[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runsc-offline.options]TypeUrl = "io.containerd.runsc.v1.options"ConfigPath = "/etc/containerd/runsc-offline.toml"The name
config-v3.toml.tmplis for containerd 2. A k3s with containerd 1.7 readsconfig.toml.tmpl, with the section names of the version 2 of the configuration. -
Restart k3s. The service is
k3son the server andk3s-agenton an agent:Terminal window sudo systemctl restart k3s # on the serversudo systemctl restart k3s-agent # on an agentThen
/var/lib/rancher/k3s/agent/etc/containerd/config.tomlcontains the two runtimes.
Then, on your computer:
-
Make the two RuntimeClasses:
Terminal window kubectl apply -f - <<'EOF'apiVersion: node.k8s.io/v1kind: RuntimeClassmetadata:name: gvisorhandler: runsc---apiVersion: node.k8s.io/v1kind: RuntimeClassmetadata:name: gvisor-offlinehandler: runsc-offlineEOF -
Start a pod under gVisor, and read its kernel:
Terminal window kubectl run gvisor-check --image=busybox:1.37 --restart=Never \--overrides='{"spec":{"runtimeClassName":"gvisor"}}' -- sleep 300kubectl wait --for=condition=Ready pod/gvisor-check --timeout=3mkubectl exec gvisor-check -- uname -rkubectl delete pod gvisor-checkThe kernel must end in
-gvisor, for example4.19.0-gvisor.
3. Put the images on the nodes
Section titled “3. Put the images on the nodes”The chart needs two images, boxfork-operator and boxfork-helper.
You build them for the chip type of the nodes and import them into the containerd of k3s on each node.
You can also push them to a registry that the nodes can use, and give their names to the chart in step 4.
-
In the checkout of boxfork, build the two images and save them to one file. For arm64 nodes, give
linux/arm64.Terminal window docker build --platform linux/amd64 -f operator/Dockerfile -t localhost/boxfork-operator:k3s .docker build --platform linux/amd64 -f operator/helper.Dockerfile -t localhost/boxfork-helper:k3s .docker save -o boxfork-images.tar localhost/boxfork-operator:k3s localhost/boxfork-helper:k3sWith Podman, use
podmanin place ofdocker. -
Copy the file to each machine, and import it there:
Terminal window scp boxfork-images.tar SERVER:/tmp/ssh SERVER sudo k3s ctr -n k8s.io images import /tmp/boxfork-images.tarDo this step for
AGENT1andAGENT2too. -
On each machine, make sure that containerd has the two images:
Terminal window sudo k3s crictl images | grep boxfork
4. Install the chart
Section titled “4. Install the chart”k3s has a network policy controller, so the network policies of boxfork keep the sandboxes apart with no more work.
It also has a default storage class, local-path, which keeps each volume on the disk of one node.
The API service and the registry of the snapshots each have a volume, so they stay on the node of their volume.
Put them on the server, because the agents are the machines that you drain.
-
Cordon the two agents, so that the parts of boxfork start on the server. Use the names of the nodes from
kubectl get nodes:Terminal window kubectl cordon <agent1> <agent2> -
Make the namespace, and let it admit only pods of the Pod Security level
baseline:Terminal window kubectl create namespace boxforkkubectl label namespace boxfork pod-security.kubernetes.io/enforce=baseline -
Find the address of the flannel tunnel of each node. It is the first address of the pod range of the node:
Terminal window kubectl get nodes -o jsonpath='{range .items[*]}{.spec.podCIDR}{"\n"}{end}'For the range
10.42.1.0/24, the address is10.42.1.0/32. Use the ranges of your nodes: a node that joins again gets a new range. You need these addresses because a node pulls the snapshots from the registry through its node port. If the registry is on a different node, the traffic comes from this address. -
Install the chart. Give the address ranges of k3s, the tunnel addresses, and the socket of the containerd of k3s:
Terminal window helm install bf operator/chart -n boxfork \--set image.repository=localhost/boxfork-operator --set image.tag=k3s \--set helperImage.repository=localhost/boxfork-helper --set helperImage.tag=k3s \--set 'networkPolicy.podCIDRs={10.42.0.0/16}' \--set 'networkPolicy.serviceCIDRs={10.43.0.0/16}' \--set 'networkPolicy.nodeCIDRs={NODE_CIDR,10.42.0.0/32,10.42.1.0/32,10.42.2.0/32}' \--set snapshots.agent.containerdSocket=/run/k3s/containerd/containerd.sock \--wait --timeout 10mIn
nodeCIDRs, putNODE_CIDRand the tunnel addresses from item 3.10.42.0.0/16and10.43.0.0/16are the default ranges of the pods and the services of k3s. If you gave--cluster-cidror--service-cidrto k3s, give those ranges. When a node joins later, add its tunnel address withhelm upgrade --reuse-values. Without the tunnel addresses, the registry refuses the other nodes. A fork or a move to a different node then fails withErrImagePull. -
Uncordon the agents:
Terminal window kubectl uncordon <agent1> <agent2> -
Make sure that the API service saw the network keep the sandboxes apart:
Terminal window kubectl -n boxfork logs deploy/bf-api | grep 'is serving'The line must give
"network_isolated":trueand"snapshots":true. Ifnetwork_isolatedisfalse, read “If the network plugin ignores network policies” in install.md.
5. Use it from your computer
Section titled “5. Use it from your computer”-
Make the API service available on your computer, in a different terminal:
Terminal window kubectl -n boxfork port-forward svc/bf-api 7070:7070 -
Install the SDK from the checkout, and give the address and the key to it:
Terminal window pip install ./sdk/pythonexport BOXFORK_URL=http://127.0.0.1:7070export BOXFORK_API_KEY=$(kubectl -n boxfork get secret bf-api-key -o jsonpath='{.data.api-key}' | base64 -d) -
Create a sandbox, write a file in it, and fork it into 3 copies:
from boxfork import Sandboxsbx = Sandbox.create("ubuntu:24.04", timeout=1800)print("sandbox", sbx.id, sbx.run("uname -r").stdout.strip())sbx.files.write("/work/hello.txt", "hello from k3s\n")print("read", sbx.files.read("/work/hello.txt").strip())for copy in sbx.fork(3, timeout=1800):print("copy", copy.id, copy.files.read("/work/hello.txt").strip())timeout=1800keeps each sandbox for 30 minutes. The default of the chart is 5 minutes. -
Find the node of each sandbox:
Terminal window kubectl -n boxfork get sandboxes -o wideThe scheduler puts the copies of one sandbox on different nodes when it can.
6. Drain a node
Section titled “6. Drain a node”A drain of a node moves each sandbox on it to a different node, and the files and the ID of the sandbox stay. Its processes stop, because a move keeps only the files, as a snapshot does. install.md gives the details, and decision 20 gives the design.
Caution: Do not drain the server. The API service and the registry cannot move from it, because their volumes are on its disk.
-
Select an agent that has sandboxes in the column
NODEofkubectl -n boxfork get sandboxes -o wide. -
Drain it:
Terminal window kubectl drain <agent> --ignore-daemonsets --delete-emptydir-data --timeout=10m -
Make sure that each sandbox runs on a different node now:
Terminal window kubectl -n boxfork get sandboxes -o wide -
Read the file of a sandbox that moved, with its ID:
from boxfork import Sandboxprint(Sandbox.connect("<id>").files.read("/work/hello.txt")) -
When the work on the node is done, uncordon it:
Terminal window kubectl uncordon <agent> -
Kill the sandboxes:
from boxfork import Sandboxfor sbx in Sandbox.list():sbx.kill()
7. Remove it
Section titled “7. Remove it”Caution: Kill all sandboxes before you uninstall the chart, as in step 6. Without the operator, a Sandbox object stays, and the namespace does not go.
-
Delete the snapshots, then uninstall the chart. The snapshots go first, because the node agents must delete their images. The uninstall also removes the namespace
boxfork-bf-system, which the chart made.Terminal window kubectl -n boxfork delete sandboxsnapshots --allhelm uninstall bf -n boxfork --waitkubectl delete namespace boxforkkubectl delete crd sandboxes.boxfork.dev sandboxsnapshots.boxfork.devkubectl delete runtimeclass gvisor gvisor-offline -
On each agent, remove k3s:
Terminal window sudo /usr/local/bin/k3s-agent-uninstall.sh -
On the server, remove k3s:
Terminal window sudo /usr/local/bin/k3s-uninstall.sh -
On each machine, remove gVisor:
Terminal window sudo rm -rf /usr/local/bin/runsc /usr/local/bin/containerd-shim-runsc-v1 /usr/local/bin/gvisor-binsudo rm -f /etc/containerd/runsc.toml /etc/containerd/runsc-offline.toml
The uninstall scripts of k3s remove /var/lib/rancher/k3s, with the template of containerd, and /etc/rancher/k3s, with the token.
What ran on real machines
Section titled “What ran on real machines”On 6 December 2026, scripts/proof/k3s-guide.sh did all steps of this guide on three new machines, from the start to the end. The script runs the commands of each step through SSH from a Mac, and checks the result. It runs the first Python block of this page as it is. 46 checks passed, and 0 failed.
| Item | Value |
|---|---|
| Machines | 3 Google Cloud VMs, e2-standard-4 (4 CPUs, 16 GB), in us-central1-a, on the default network |
| System | Ubuntu 24.04.5, kernel 7.0.0-1021-gcp, x86_64 |
| k3s | v1.37.3+k3s1, with containerd 2.3.7-k3s1, flannel VXLAN and kube-router |
| gVisor | release-20261130.0 |
| Your computer | A Mac with arm64, Podman, Helm 4.3.2, kubectl 1.37.3 |
| Step | Time |
|---|---|
1. k3s on the server and two agents, until the 3 nodes are Ready |
59 s |
| 2. gVisor on 3 nodes, with the check pods | 93 s |
| 3. The images to the 3 nodes, 57 MB. The first build of the images for amd64 on the Mac took 5 minutes, because Podman emulates amd64. | 91 s |
| 4. The chart, until the API service is ready | 52 s |
6. kubectl drain of an agent with 2 sandboxes |
18 s |
| 7. The removal of the chart and of k3s from 3 nodes | 59 s |
These checks passed:
| Check | Result |
|---|---|
A pod with gvisor on each node |
4.19.0-gvisor, and dmesg says “Starting gVisor” |
A pod with gvisor-offline |
Only the network device lo |
| The API service | isolation gvisor, network_isolated true, metadata_blocked true, snapshots true |
Each node pulls from the registry at localhost:30500 |
It gets HTTP 401 without the login |
| A sandbox and the internet | It connects to 1.1.1.1:443, and it finds kubernetes.default |
| A sandbox and the cluster | It cannot connect to a different sandbox, the metadata service, the API service, the Kubernetes API server or a kubelet. A pod that is not a sandbox connects to each of them. |
| The Python block of step 5 | It ran in 12 s. The 3 copies have the file, and they are on 3 different nodes. |
| The drain | Each of the 2 sandboxes moved to a different node in 10 s. Each kept its ID, its Sandbox object, its file and a 20 MB file with the same SHA-256. |
| The removal | No namespace and no CRD of boxfork. No k3s, no gVisor and no process of k3s or containerd on the 3 nodes. |
The first runs found two problems. We corrected them before the run above:
- kube-router rejects the traffic that a network policy blocks. A sandbox then gets “connection refused”, not a timeout. The check of the API service took this as a sandbox that reached another sandbox, and reported
network_isolatedasfalse. The check now uses a port that takes connections. See internals/kubernetes.md. - flannel sends the traffic of a node to the registry on a different node from its tunnel address. The policy of the registry refused it, and forks to other nodes failed with
ErrImagePull. Step 4 now gives the tunnel addresses innetworkPolicy.nodeCIDRs.
Limits
Section titled “Limits”- The API service and the registry stay on one node, because
local-pathkeeps a volume on one node. If that node stops, the cluster has no API service and no snapshots until it starts again. - A sandbox with a volume cannot move to a different node:
local-pathkeeps the volume on its node. Thus a drain waits for such a sandbox. - No GPUs. The API service on Kubernetes refuses a sandbox with a GPU.
- The probe of the operator counts only a timeout as the policy. On k3s, it got a timeout from each sandbox pod. A plain pod got “connection refused” from the same pods.
- We do not know why the operator got a timeout. We think that the policy of the operator pod drops the ICMP error of kube-router, but we did not prove it.
If a different setup of k3s gives the operator “connection refused”,
network_isolatedstaysfalse. See internals/kubernetes.md.
Not proven:
- the guide by a person other than its author
- a server with more than one machine (k3s with an embedded etcd)
- network plugins other than flannel with kube-router, and machines that are not on Google Cloud
- arm64 nodes, other distributions of Linux, and other versions of k3s
- a node that joins after the install, and a drain of the server
- large sandboxes, volumes, pools and many sandboxes at the same time