You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: architecture/gateway.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -605,7 +605,7 @@ The gateway reaches the sandbox exclusively through the supervisor-initiated `Co
605
605
606
606
-**Create**: The VM driver process allocates a sandbox-specific rootfs from its own embedded `rootfs.tar.zst`, injects an explicitly configured guest mTLS bundle when the gateway callback endpoint is `https://`, then re-execs itself in a hidden helper mode that loads libkrun directly and boots the supervisor.
607
607
-**Networking**: The helper starts an embedded `gvproxy`, wires it into libkrun as virtio-net, and gives the guest outbound connectivity. No inbound TCP listener is needed — the supervisor reaches the gateway over its outbound `ConnectSupervisor` stream.
608
-
-**Gateway callback**: The guest init script configures `eth0` for gvproxy networking, prefers the configured `OPENSHELL_GRPC_ENDPOINT`, and falls back to host aliases or the gvproxy gateway IP (`192.168.127.1`) when local hostname resolution is unavailable on macOS.
608
+
-**Gateway callback**: The guest init script configures `eth0` for gvproxy networking, seeds `/etc/hosts` so `host.openshell.internal` resolves to the gvproxy gateway IP (`192.168.127.1`), preserves gvproxy's legacy `host.containers.internal` / `host.docker.internal` DNS answers, prefers the configured `OPENSHELL_GRPC_ENDPOINT`, and falls back to those aliases or the raw gateway IP when local hostname resolution is unavailable on macOS.
609
609
-**Guest boot**: The sandbox guest runs a minimal init script that starts `openshell-sandbox` directly as PID 1 inside the VM.
610
610
-**Watch stream**: Emits provisioning, ready, error, deleting, deleted, and platform-event updates so the gateway store remains the durable source of truth.
`start.sh` handles runtime setup, builds, codesigning, and environment wiring. From the repo root:
35
34
36
35
```shell
37
-
crates/openshell-driver-vm/start.sh
36
+
mise run gateway:vm
38
37
```
39
38
40
-
or equivalently:
41
-
42
-
```shell
43
-
make -C crates/openshell-driver-vm start
44
-
```
45
39
46
-
First run takes a few minutes while `mise run vm:setup` stages libkrun/libkrunfw/gvproxy and `mise run vm:rootfs -- --base` builds the embedded rootfs. Subsequent runs are cached. State lives under `target/openshell-vm-driver-dev/` (SQLite DB + per-sandbox rootfs + `compute-driver.sock`).
40
+
First run takes a few minutes while `mise run vm:setup` stages libkrun/libkrunfw/gvproxy and `mise run vm:rootfs -- --base` builds the embedded rootfs. Subsequent runs are cached. To keep the Unix socket path under macOS `SUN_LEN`, `mise run gateway:vm` and `start.sh` default the state dir to `/tmp/openshell-vm-driver-dev-$USER-port-$PORT/` (SQLite DB + per-sandbox rootfs + `compute-driver.sock`) unless `OPENSHELL_VM_DRIVER_STATE_DIR` is set.
41
+
The wrapper also prints the recommended gateway name (`vm-driver-port-$PORT` by default) plus the exact repo-local `scripts/bin/openshell gateway add` and `scripts/bin/openshell gateway select` commands to use from another terminal. This avoids accidentally hitting an older `openshell` binary elsewhere on your `PATH`.
42
+
It also exports `OPENSHELL_DRIVER_DIR=$PWD/target/debug` before starting the gateway so local dev runs use the freshly built `openshell-driver-vm` instead of an older installed copy from `~/.local/libexec/openshell` or `/usr/local/libexec`.
Run multiple dev gateways side by side by giving each one a unique port. The wrapper derives a distinct default state dir from that port automatically:
53
+
54
+
```shell
55
+
OPENSHELL_SERVER_PORT=8080 mise run gateway:vm
56
+
OPENSHELL_SERVER_PORT=8081 mise run gateway:vm
57
+
```
58
+
59
+
If you want a custom suffix instead of `port-$PORT`, set `OPENSHELL_VM_INSTANCE`:
60
+
61
+
```shell
62
+
OPENSHELL_SERVER_PORT=8082 \
63
+
OPENSHELL_VM_INSTANCE=feature-a \
64
+
mise run gateway:vm
65
+
```
66
+
67
+
If you want a custom CLI gateway name, set `OPENSHELL_VM_GATEWAY_NAME`:
The gateway resolves `openshell-driver-vm` in this order: `--driver-dir`, conventional install locations (`~/.local/libexec/openshell`, `/usr/local/libexec/openshell`, `/usr/local/libexec`), then a sibling of the gateway binary.
@@ -97,7 +117,7 @@ The gateway resolves `openshell-driver-vm` in this order: `--driver-dir`, conven
97
117
| Flag | Env var | Default | Purpose |
98
118
|---|---|---|---|
99
119
|`--drivers vm`|`OPENSHELL_DRIVERS`|`kubernetes`| Select the VM compute driver. |
100
-
|`--grpc-endpoint URL`|`OPENSHELL_GRPC_ENDPOINT`| — | Required. URL the sandbox guest calls back to. Use a host alias that resolves to the gateway's host from inside the VM (gvproxy answers `host.containers.internal`and`host.openshell.internal` to `192.168.127.1`). |
120
+
|`--grpc-endpoint URL`|`OPENSHELL_GRPC_ENDPOINT`| — | Required. URL the sandbox guest calls back to. Use a host alias that resolves to the gateway's host from inside the VM (`host.containers.internal`comes from gvproxy DNS; the guest init script also seeds`host.openshell.internal` to `192.168.127.1`). |
101
121
|`--vm-driver-state-dir DIR`|`OPENSHELL_VM_DRIVER_STATE_DIR`|`target/openshell-vm-driver`| Per-sandbox rootfs, console logs, and the `compute-driver.sock` UDS. |
102
122
|`--driver-dir DIR`|`OPENSHELL_DRIVER_DIR`| unset | Override the directory searched for `openshell-driver-vm`. |
103
123
|`--vm-driver-vcpus N`|`OPENSHELL_VM_DRIVER_VCPUS`|`2`| vCPUs per sandbox. |
0 commit comments