boxfork on Google Cloud
This guide tells you how to run boxfork on one Compute Engine VM in your own Google Cloud project. The machine, its data and its bill are yours. Nothing goes through a different person or company.
We did not run these steps on a real Google Cloud project. We wrote these steps from the documentation of Google and from runs of the same installer on a local Ubuntu 24.04 system. Use the first run as a test, and tell us what is different.
Choose the VM
Section titled “Choose the VM”CPU sandboxes: Use any x86_64 or arm64 machine type with the Ubuntu 24.04 LTS image.
gcloud compute instances create boxfork-1 --zone=us-central1-a \ --machine-type=e2-standard-4 \ --image-family=ubuntu-2404-lts-amd64 --image-project=ubuntu-os-cloud \ --boot-disk-size=100GB \ --no-service-account --no-scopes--no-service-account --no-scopes is in each command of this guide for a reason.
Without it, the VM gets the default service account of the project.
Then the metadata service of the VM gives tokens for that account to each program that asks from the VM.
boxfork blocks the metadata address for sandboxes in the firewall of the VM.
boxfork info shows if the block is active.
See install.md.
But a VM that holds no credentials cannot lose credentials.
If something on the VM needs a service account, give it an account of its own with only the necessary roles.
GPU sandboxes: Use a VM with NVIDIA GPUs and an image that includes the NVIDIA driver, because the installer does not install the driver.
The Deep Learning VM images of Google install the driver when you set install-nvidia-driver=True:
gcloud compute instances create boxfork-gpu-1 --zone=us-central1-a \ --machine-type=n1-standard-8 \ --accelerator=type=nvidia-tesla-t4,count=1 \ --maintenance-policy=TERMINATE \ --image-family=<a GPU image family> --image-project=deeplearning-platform-release \ --metadata=install-nvidia-driver=True \ --boot-disk-size=200GB \ --no-service-account --no-scopes- List the image families with
gcloud compute images list --project deeplearning-platform-release --no-standard-images. Select a GPU image family that has Ubuntu or Debian as its base. - The image installs the driver during the first boot.
This takes some minutes and ends with a restart.
Wait until
nvidia-smianswers on the VM before you install boxfork. - VMs with GPUs must have
--maintenance-policy=TERMINATE. - This guide cannot promise which version of the driver the image installs. The boxfork installer compares the version with the versions that gVisor supports. If the version is not one of them, the installer gives a warning.
A sandbox with a GPU gets a whole GPU. Thus a VM with four GPUs runs four GPU sandboxes at the same time.
Firewall
Section titled “Firewall”Do not change the firewall. The default network of a project lets in SSH, and also RDP and ping, from all addresses. It also lets in all traffic between the VMs of that network. None of this traffic reaches the API. The API listens only on the VM itself, and you reach it through an SSH tunnel. Thus it is not necessary to add a rule.
If you prefer to permit only SSH, use a network of your own with that one rule.
Way 1: copy and install
Section titled “Way 1: copy and install”This way works at this time, with a release that you built (make dist, see install.md).
gcloud compute scp dist/install.sh dist/boxfork-linux-amd64.tar.gz boxfork-1:~/ --zone=us-central1-agcloud compute ssh boxfork-1 --zone=us-central1-a \ --command "sudo sh install.sh --from ./boxfork-linux-amd64.tar.gz"On an arm64 VM, use boxfork-linux-arm64.tar.gz.
Way 2: install at first boot
Section titled “Way 2: install at first boot”The VM installs boxfork by itself while it starts. For this, the release must be at an https address that the VM can read. An example is a folder in a Cloud Storage bucket of yours. The files contain nothing secret.
-
Build the release with the address that it will have. Then publish the release:
Terminal window make dist VERSION=0.1.0 RELEASE=https://storage.googleapis.com/<bucket>/boxfork/0.1.0gcloud storage cp dist/* gs://<bucket>/boxfork/0.1.0/The VM must be able to read the objects without a sign-in. For this, the bucket needs the role
Storage Object ViewerforallUsers. Thus use a bucket that contains nothing else. If the bucket or the organization enforces “public access prevention”, you cannot give that role. In that case, use Way 1, or serve the folder from an https address that you already have. -
If you did not put
RELEASE=on themakeline, setRELEASEat the top ofdist/cloud-startup.shmanually.dist/cloud-startup.shnow contains that address and the checksums of the installer and the archives of this release. Thus the VM installs those files or nothing, and it is not important who can write to the bucket. -
Create the VM with the script:
Terminal window gcloud compute instances create boxfork-1 --zone=us-central1-a \--machine-type=e2-standard-4 \--image-family=ubuntu-2404-lts-amd64 --image-project=ubuntu-os-cloud \--boot-disk-size=100GB \--no-service-account --no-scopes \--metadata-from-file=startup-script=dist/cloud-startup.shCompute Engine runs a startup script at each boot. This script does nothing after boxfork is installed and its service answers. If an installation did not get to that point, the script tries it again at the next boot. A VM that already has an boxfork with settings of its own keeps those settings and that build. A VM from which you removed boxfork with
install.sh --uninstallstays without boxfork. -
After some minutes, look at the result:
Terminal window gcloud compute ssh boxfork-1 --zone=us-central1-a \--command "sudo tail -40 /var/log/boxfork-install.log"If that file does not exist, the script did not start. In that case, look at
sudo journalctl -u google-startup-scripts.service.
On a GPU VM, the installation of the NVIDIA driver is not complete at the first boot.
Thus the startup script finds no GPU at that time and installs boxfork without a GPU.
The installation of the driver ends with a restart.
At that boot, the script sees the GPU and runs the installer one more time to set up the GPU.
This run keeps the settings of the service.
Use boxfork info to make sure that it counts the GPUs.
If you use Way 1 after nvidia-smi answers, you get the same result in one step.
The first-boot script sets up the service only for the VM itself.
To change this later, run the installer that the script kept.
This is also the way to change to HTTPS.
Use sudo sh /etc/boxfork/install.sh --from /usr/local/bin/boxfork with the options from install.md.
Use it
Section titled “Use it”The boxfork command on your own computer is the same binary, built for your computer.
make build in the source tree puts the binary in bin/boxfork.
The commands below assume that the binary is on your PATH (export PATH="$PWD/bin:$PATH").
gcloud compute ssh boxfork-1 --zone=us-central1-a --command "sudo cat /var/lib/boxfork/api-key"gcloud compute ssh boxfork-1 --zone=us-central1-a -- -N -L 7070:127.0.0.1:7070 &export BOXFORK_URL=http://127.0.0.1:7070export BOXFORK_API_KEY=<the key>boxfork info # isolation should say gvisor; GPUs, how many it found; # "kept from the cloud metadata service" should say yesServing it to other machines
Section titled “Serving it to other machines”Other VMs in the same VPC network can use the API over the private network:
- Install with
--listen <internal address>:7070. - Add a firewall rule that permits that port only from those VMs.
For all use outside a private network, serve the API over HTTPS. HTTPS also needs port 80 open to the internet, for the issue and the renewal of the certificate. install.md describes the two ways.
The VM costs money while it runs, also when no sandbox uses it.
Stop the VM when you do not need it.
For a stopped VM, you pay only for its disk.
Sandboxes do not stay after a stop of the machine, but snapshots stay.
serve --gpu-idle-suspend releases a GPU from an idle sandbox for other sandboxes.
It does not decrease the bill.