Skip to content
jingyugaoPublic

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Cellbox

Cellbox gives you isolated sandboxes over an HTTP API. On Kubernetes, it can automatically checkpoint idle HTTP services to free node memory and resume them on the next request. With a warm-pool hit, a sandbox resumes in about 100 ms with its process memory intact.

A sandbox runs in gVisor on Kubernetes. You create it from a versioned template, run time-limited commands in it, read and write its files, proxy HTTP to services inside it, and suspend and resume it. Resume continues the same processes where they stopped; it does not start them again.

Status: alpha. The API is v1alpha1 and may change. Cellbox currently targets a single Kubernetes node on linux/amd64, and needs a patched gVisor build (see Requirements). Read Limitations before relying on it.

Run HTTP services on demand

An internal dashboard, for example, can release its memory between visits and keep its in-memory cache across them. Run the service in a Cellbox sandbox, set httpService.port when creating the sandbox, and route all application traffic through the Cellbox middleware on your Traefik Ingress.

Once the last request finishes and the service stays idle for httpService.idleTimeoutSeconds (five minutes by default), Cellbox saves a checkpoint on the node and deletes the workload Pod. Open streams such as SSE or WebSocket connections keep the sandbox running. The next request to the same URL triggers a restore. Traefik waits until the service port accepts connections, then forwards that original request to the resumed process.

See the Traefik plugin configuration and the sandbox settings, middleware and Ingress example.

Why resume is fast

Restoring a gVisor checkpoint normally means creating a Pod, setting up its network and sandbox, and loading all memory before the application runs again. Cellbox moves most of that out of the request:

  • Warm pool. Pods and gVisor sandboxes are prepared ahead of time, based on the checkpoints that exist on the node. A resume claims a ready slot instead of creating a Pod.
  • Deferred checkpoint. A warm sandbox starts without a checkpoint; the checkpoint and the persistent HOME are bound only when a sandbox claims the slot.
  • Lazy checkpoint load. After restore, memory pages are read when the application touches them, not in one pass up front.

With a warm-pool hit, a suspended sandbox with 1 GB of memory is running again in about 100 ms (median, one machine, memory not yet touched, no client overhead). A first command through the API finishes after about 150 ms. The figures apply to a resume on the same node that finds a ready warm slot. A resume that misses the pool falls back to a normal checkpoint restore, which keeps process memory but takes longer (about 870 ms in one test). How the number is measured and where the time goes is described in Resume on Kubernetes; the warm pool is explained in warm pool.

What you can do

  • Build templates and immutable revisions from a base image and a build command, then create sandboxes from a template or a pinned revision.
  • Run commands with a time limit, read and write files, and proxy HTTP to ports inside a sandbox.
  • Suspend and resume a sandbox on the same node, with process memory preserved.
  • Keep state in persistent HOME volumes, with backups and exports, and move a stopped sandbox's workspace into a new one with archives (needs S3-compatible storage).
  • Drive everything from the REST API or the Go SDK; trace requests with OpenTelemetry.

The Kubernetes provider supports all of this. A Docker provider offers only create, query, commands, files, service proxying and destroy; everything else returns UNSUPPORTED_CAPABILITY.

How it works

client / Go SDK
      | HTTP
      v
+------------------ cellbox-server (one process, pinned to one node) ------------------+
|  API + operations -> controller + warm pool -> node runtime (CRI, checkpoint, HOME)  |
|        |                    |                                                         |
|     SQLite           Kubernetes API (Cellbox custom resource, Pods, Service)          |
+---------------------------------------------------------------------------------------+
      |                                      |
      v                                      v
 BuildKit (image builds)        containerd -> gVisor (runsc) -> guest agent -> your program

cellbox-server serves the API, reconciles Kubernetes objects and drives the node runtime in one process. Template, revision and operation records live in a local SQLite database; each sandbox's desired and observed state lives in a Cellbox custom resource that owns its Pod and Service. See concepts for the vocabulary and architecture for the full request flows.

Requirements

  • A Kubernetes node on linux/amd64 with containerd (tested: k3s v1.36, containerd 2.3, Ubuntu 24.04), and root access to it.
  • A Cellbox gVisor build. Upstream gVisor does not yet have the options the fast path uses, so install the build published at jingyugao/gvisor. The node installation guide covers it.
  • BuildKit, if you build templates from a base image (the Helm chart can deploy it).
  • S3-compatible object storage, only if you use archives.

Getting started

  1. Prepare the node. Install the gVisor build, the Cellbox runsc wrapper and a containerd handler: Node installation.
  2. Deploy. Build the server image, configure values.yaml and install the Helm chart: Deployment.
  3. Try it. Create a template, build a revision, create a sandbox, run a command, then suspend and resume it: REST quick start or Go SDK guide.

No cluster? The local quick start runs Cellbox on one Linux host with the local-runsc provider. It has no warm pool, so the resume figure above does not apply to it.

Documentation

Guide Contents
Concepts Terms used everywhere: Box, template, revision, generation, checkpoint, warm pool
Node installation gVisor build, wrapper, containerd handler
Local quick start Run on one Linux host without Kubernetes
Deployment Image, Helm values, upgrade
Configuration Every flag, configuration field, environment variable and Helm value
Usage Templates, revisions and the sandbox lifecycle
REST quick start curl examples
Go SDK Client usage and examples
Resume on Kubernetes What the resume figure means, how it is achieved, measurements and limits
Resume timeline Where the time goes in one resume, layer by layer, and what is being optimized
Warm pool How warm slots are sized, claimed and reclaimed
Architecture Components and the create and resume flows
End-to-end validation The acceptance suite and what it proves
OpenAPI The full HTTP contract

Limitations

  • Single node. cellbox-server is pinned to one node. A suspended sandbox resumes only on the node that took its checkpoint; there is no cross-node migration and no scheduler across nodes.
  • No built-in authentication. The API does not authenticate callers, and the X-Cellbox-Client-ID header only selects a data namespace. Put an authenticating gateway in front of it.
  • Privileged server. The server Pod runs privileged with hostPID and host mounts. Run it only on a node you trust, and do not treat it as an unprivileged API deployment.
  • Alpha API and data. v1alpha1 can change. Upgrading across the API-group rename (cellbox.local to cellbox.jingyugao.github.io) does not migrate existing sandboxes.
  • linux/amd64 only, and one gVisor build.

Build and test

Building needs Go 1.26 or later.

make check    # unit tests (with -race), go vet, gofmt check, script syntax
make build    # binaries, chart, docs and SDK source into dist/release

License

Apache License 2.0. See LICENSE.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages