Skip to content

feat(orchestrator): boot sandboxes with cloud-init user-data - #337

Merged
edenreich merged 1 commit into
mainfrom
feat/orchestrator-user-data
Nov 9, 2026
Merged

edenreich merged 1 commit into
mainfrom
feat/orchestrator-user-data

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

A computer-use workspace needs things its image does not ship, such as a browser. Clouds solve this with cloud-init user-data, and so does KubeVirt. This adds the same contract to the Orchestrator's Sandbox runtime: spec.userData.secretRef hands the pod a cloud-init user-data script that runs as root when it boots, before the daemon starts.

The Sandbox runtime forces pods to run as non-root with every capability dropped, and nothing in the CR could change that. The pod does not get a blanket exception. A pod with userData runs in a user namespace (hostUsers: false, GA since Kubernetes 1.36), so its root maps to an unprivileged user on the node. Pods with user namespaces also pass the Restricted Pod Security Standard. The image runs the script and then drops to the daemon's user, the way linuxserver.io images and cloud-init on a VM do.

The secretRef has the shape of KubeVirt's cloudInitNoCloud volume, and the cli stores the script under the key userdata, which is the key KubeVirt reads. A later VM runtime can then boot from the same Secret, and clients do not change.

Changes

  • api/v1alpha1/orchestrator_types.go: UserData *UserDataSpec (secretRef) on OrchestratorSpec. A CEL rule limits it to runtime: Sandbox, so the Deployment runtime never silently ignores it. Deepcopy, CRDs and manifests/ are regenerated.
  • internal/controller/orchestrator_sandbox.go: bootWithUserData, applied only when userData is set:
    • hostUsers: false, and root as the pod's user.
    • Capabilities are drop ALL, then add CHOWN, DAC_OVERRIDE, FOWNER, FSETID, SETUID, SETGID.
    • allowPrivilegeEscalation: false and seccomp RuntimeDefault stay.
    • The Secret key is mounted read-only (mode 0400) at cloud-init's NoCloud seed path, /var/lib/cloud/seed/nocloud/user-data.
    • Without userData the pod is unchanged.
  • internal/controller/orchestrator_sandbox_test.go: covers the pod shape with user-data and the CEL rejection on a Deployment.
  • README.md: a "Boot a computer with user-data" section with the node requirements: Kubernetes 1.36+, containerd 2.0+ or CRI-O 1.25+, Linux 6.3+.

Verified:

  • task generate manifests, task test and task lint pass with 0 issues.
  • On a k3s v1.37.1 / containerd 2.3.4 node, a pod with exactly this security context maps root to 2705522688 in /proc/self/uid_map. It apt-get installs a package, and after setpriv it runs as uid 1000 with CapEff 0.

The image side ships in inference-gateway/cli (ghcr.io/inference-gateway/computer, which runs the seed script), and so does the user_data workspace field. The cli gates user_data on this release as v0.35.0.

spec.userData.secretRef hands a Sandbox pod a cloud-init user-data script
that runs as root when it boots, before the daemon starts, the way a cloud
VM runs it - for example to install a browser on a computer-use image.

The pod then runs in a user namespace (hostUsers: false), so its root maps
to an unprivileged user on the node, with only the capabilities a package
install needs and still no privilege escalation. The Secret key is mounted
read-only for root at cloud-init's NoCloud seed path. The secretRef has the
shape of KubeVirt's cloudInitNoCloud volume, so a VM runtime can take the
same Secret unchanged. A CEL rule limits userData to runtime: Sandbox.
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.35.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 9, 2026
edenreich added a commit to inference-gateway/cli that referenced this pull request Nov 9, 2026
…1777)

## Summary

A computer-use workspace needs software its image does not ship, such as
a browser with the opentask extension. Instead of a custom image per
client, a kubernetes workspace now takes `user_data`: a
[cloud-init](https://cloudinit.readthedocs.io/) user-data script its pod
runs as root when it boots, before the daemon starts, the way a cloud VM
runs it.

```yaml
workspaces:
  - name: ubuntu-desktop
    kind: kubernetes
    namespace: agents
    image: ghcr.io/inference-gateway/computer:latest
    user_data: |
      #!/bin/sh
      apt-get update
      apt-get install -y --no-install-recommends gimp
```

The script never lands in the Orchestrator. It goes into the session's
Secret under the key `userdata`, the key KubeVirt's `cloudInitNoCloud`
volume reads, and the Orchestrator's `spec.userData.secretRef` points at
it. A later VM runtime can boot from the same Secret, and clients do not
change.

## Changes

- `config/daemon.go`:
  - `WorkspaceEntry.UserData` (`user_data`).
- It is kubernetes-only. The existing check is extracted into
`setsKubernetesOnlyFields()`.
  - It must start with `#!`, since `#cloud-config` is not supported yet.
- `internal/agent/infrastructure/kubernetes/workspace.go`:
- `ensureSecret` writes the script under `userdata`. Like an instance's
user-data, it is fixed for the session.
  - `orchestrator()` sets `spec.userData.secretRef`.
- `requiredOperatorVersion` names `v0.35.0` when an older operator
rejects the Orchestrator.
- Tests: config validation for the kind and the format, the spec
reference with no script in the Orchestrator, and the Secret key.
- Docs: `docs/daemon.md` (workspaces) and
`docs/configuration-reference.md`.

Depends on inference-gateway/operator#337, which runs the pod in a user
namespace and mounts the script for the image to run. Related: the
computer image PR (runs the script) and the browser-extension loopback
fix, both in this repo.

`task lint` passes with 0 issues, and the `config` and kubernetes
workspace tests pass.
edenreich added a commit to inference-gateway/cli that referenced this pull request Nov 9, 2026
…rkspaces (#1778)

## Summary

The desktop app built its own computer-use image locally: Ubuntu, Xvfb,
openbox and Firefox, and nothing else. When an agent closed the browser,
the screen went black. Only the bare X root window was left, with
nothing to click. The image pins and runs `infer` and depends on cli
contracts (X11 capture, the daemon binding, the browser relay), so the
cli now owns and publishes it.

`ghcr.io/inference-gateway/computer`, released with the CLI under the
same tags, is a minimal Ubuntu 26.04 desktop:
- `infer daemon` runs on an Xvfb display (`:99`, 1280x800) with openbox
and a wallpaper.
- A tint2 taskbar has launchers for the installed apps, the open windows
and a clock.
- Normal windows open maximized above the taskbar.

It ships no browser. Clients install what they need with cloud-init
`user_data`. The entrypoint is the container's stand-in for cloud-init:
started as root, it runs the script from the NoCloud seed path, then
drops to `infer` and starts the desktop. The pattern is the same as
linuxserver.io's `/custom-cont-init.d` and cloud-init on a VM.

## Changes

- `computer/Dockerfile`:
- Base is `ubuntu:26.04` with xvfb, openbox, `python3-xdg` (openbox's
XDG autostart), tint2, xterm, fonts, the Adwaita icons, git and curl.
- The `ubuntu` user is replaced with `infer` (uid 1000), and `USER
infer` is set.
  - openbox maximizes normal windows.
- `computer/entrypoint.sh`:
- As root, it runs `/var/lib/cloud/seed/nocloud/user-data`. It must
start with `#!`. Output is teed to `/var/log/cloud-init-output.log`.
- It then runs `HOME=/home/infer setpriv --reuid=infer --regid=infer
--init-groups` back into itself.
- As `infer`, it starts Xvfb, `xsetroot`, `openbox-session` (which runs
XDG autostart) and tint2, then `exec infer "$@"`.
- tint2 17.0.1 aborts (`buffer overflow detected`) with
`launcher_apps_dir`. The entrypoint writes `launcher_item_app` lines for
the apps in `/usr/share/applications` instead, after user-data has run,
so apps the script installs show up.
- `computer/tint2rc`: the taskbar.
- `Taskfile.yml`: `container:build:computer` and
`container:push:computer` (amd64 and arm64).
`.github/workflows/release.yml` pushes both images.
- `docs/computer-use.md`: a "The computer image" section with a
`user_data` example.

Verified locally (arm64):
- **As root with a seed script:** the script ran and `infer daemon`
became PID 1 as `infer`. Xvfb, openbox and tint2 also run as `infer`.
- **With the desktop app's default script** (Firefox ESR plus opentask):
Firefox autostarted maximized, the extension connected to the daemon,
and the taskbar showed XTerm and Firefox launchers.
- **As uid 1000 with no seed:** it boots straight to the desktop.

The image is 1.07GB. Most of it is Mesa/LLVM (Xvfb's GL stack) and GTK3
(tint2), which a browser needs anyway.

Related:
- `user_data` for workspaces: #1777
- Operator delivery: inference-gateway/operator#337
edenreich added a commit to inference-gateway/cli that referenced this pull request Nov 9, 2026
… needs client certs (#1779)

## Summary

A computer-use workspace pod now runs Firefox with the opentask
extension, so its agent can use the cheaper `browser_*` tools. The
extension dials the daemon at plain `ws://127.0.0.1:<port>/ws` and
authenticates with a token in its `browser_hello`. In a Kubernetes pod,
though, the operator serves the daemon's AG-UI binding as
`0.0.0.0:52789` with mutual TLS. That binding was the only listener, so
the extension could never connect.

When the extension backend is on and the binding requires client
certificates, the daemon now also listens on plain
`127.0.0.1:<browser_use.extension.port>` for the extension. That
listener uses the extension token, the same handshake, origin check and
handler, and none of the binding's HTTP routes, so the terminal, screen,
artifacts and peer A2A endpoint stay behind mTLS. Every other
configuration keeps its single listener.

## Changes

- `config/daemon.go`: `(*Config).ExtensionLoopback()` is a pure config
rule. It answers whether the loopback listener is needed and what it
serves, and it fails boot clearly in two cases:
- the extension port equals the binding port, including an unset
`daemon.binding.port` that falls back to it
  - the extension token is empty

  `servesMutualTLS()` is TLS on with client certificates required.
- `config/browser_use.go`: an `extensionBackend()` helper.
- `cmd/daemon/daemon.go`:
- `startExtensionLoopback` starts the listener after the main binding,
closes the main binding if the loopback fails, and closes the loopback
on stop.
  - `startThreads` builds the handler once.
- `config/daemon_test.go`: a table test covering when the listener is
needed, the port fallback, and both errors.
- `tests/e2e/daemon_test.go`: with a binding that requires client certs:
  - a TLS dial without a certificate is refused
- a `chrome-extension://` WebSocket on the loopback port gets
`browser_hello_ack`
  - `/terminal/` on the loopback port answers 404

  This test fails against the daemon without this change.
- `docs/daemon.md`: one paragraph in "The binding".

Verified:
- `task lint` reports 0 issues, and the `config`, `cmd`, `agui` and
`browser` tests pass.
- `task test:e2e` passes.
- With the computer image and Firefox ESR plus opentask configured by
policy, the extension attaches on its own (`browser extension
attached`).

Related:
- Computer image: #1778
- `user_data`: #1777
- Operator: inference-gateway/operator#337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant