authoravatarclover caruso<git@paperclover.net>2026-11-22 13:23:26-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-22 20:28:52-08:00
loga2539c07f874120f95bf837528a1d40dbc61e8ec
treef73b8bda625dc2b8ef1af88581e1da4ec87e09fb
parent6f74560e1efd492076d18c4f79ca691a64be6aa4
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Run Spacebar on the sandbox network

Jobs select the CNI network with a group network mode, and Nomad publishes their ports instead of the Podman driver. Assisted-by: claude-sonnet-5.5

5 files changed, 15 insertions(+), 2 deletions(-)

config/Service.pkl+2
...@@ -90,6 +90,8 @@ class Container {...@@ -90,6 +90,8 @@ class Container {
90 devices: Listing<String> = new {}90 devices: Listing<String> = new {}
91 extraHosts: Listing<String> = new {}91 extraHosts: Listing<String> = new {}
92 hostNetwork: Boolean = false92 hostNetwork: Boolean = false
93 /// Nomad CNI `sandbox` network: public internet and PostgreSQL only, no other host or LAN address.
94 restrictedEgress: Boolean = false
93 imageUser: Boolean = false95 imageUser: Boolean = false
94 /// Prestart tasks finish first; prestart sidecars stay up for the main tasks.96 /// Prestart tasks finish first; prestart sidecars stay up for the main tasks.
95 lifecycle: "main"|"prestart"|"prestartSidecar" = "main"97 lifecycle: "main"|"prestart"|"prestartSidecar" = "main"
service/spacebar/service.pkl+1
...@@ -27,6 +27,7 @@ secrets {...@@ -27,6 +27,7 @@ secrets {
2727
28container {28container {
29 build = "build"29 build = "build"
30 restrictedEgress = true
30 cpu = 100031 cpu = 1000
31 memory = 307232 memory = 3072
3233
tools/__pycache__/snowglobe.cpython-39.pyc created
Binary files /dev/null and b/tools/__pycache__/snowglobe.cpython-39.pyc differ
tools/snowglobe.py+7-2
...@@ -284,6 +284,9 @@ def render(data, definitions):...@@ -284,6 +284,9 @@ def render(data, definitions):
284 host_network = any(task["hostNetwork"] for task in data["containers"].values())284 host_network = any(task["hostNetwork"] for task in data["containers"].values())
285 if host_network and not all(task["hostNetwork"] for task in data["containers"].values()):285 if host_network and not all(task["hostNetwork"] for task in data["containers"].values()):
286 raise ValueError("mixed host and bridge networking in one group")286 raise ValueError("mixed host and bridge networking in one group")
287 restricted = any(task["restrictedEgress"] for task in data["containers"].values())
288 if restricted and (host_network or not all(task["restrictedEgress"] for task in data["containers"].values())):
289 raise ValueError("restricted egress must cover every container in a bridge group")
287 for task_name, task in data["containers"].items():290 for task_name, task in data["containers"].items():
288 for kind, endpoint in [("http", task.get("http")), *((port["name"], port) for port in task["tcp"])]:291 for kind, endpoint in [("http", task.get("http")), *((port["name"], port) for port in task["tcp"])]:
289 if endpoint:292 if endpoint:
...@@ -299,10 +302,12 @@ def render(data, definitions):...@@ -299,10 +302,12 @@ def render(data, definitions):
299 if endpoint.get("loopback") or (not task["hostNetwork"] and kind == "http" and endpoint.get("hostPort") is None):302 if endpoint.get("loopback") or (not task["hostNetwork"] and kind == "http" and endpoint.get("hostPort") is None):
300 network.append(' host_network = "loopback"')303 network.append(' host_network = "loopback"')
301 network.append(" }")304 network.append(" }")
302 if network:305 if network or restricted:
303 lines.append(" network {")306 lines.append(" network {")
304 if host_network:307 if host_network:
305 lines.append(' mode = "host"')308 lines.append(' mode = "host"')
309 elif restricted:
310 lines.append(' mode = "cni/sandbox"')
306 lines += network + [" }"]311 lines += network + [" }"]
307 for provider_id in sorted(dependencies(data)):312 for provider_id in sorted(dependencies(data)):
308 provider = definitions[provider_id]313 provider = definitions[provider_id]
...@@ -403,7 +408,7 @@ def render(data, definitions):...@@ -403,7 +408,7 @@ def render(data, definitions):
403 if task.get("readOnlyRoot"):408 if task.get("readOnlyRoot"):
404 lines.append(' readonly_rootfs = true')409 lines.append(' readonly_rootfs = true')
405 task_ports = [label for (owner, _), label in ports.items() if owner == task_name]410 task_ports = [label for (owner, _), label in ports.items() if owner == task_name]
406 if task_ports and not task["hostNetwork"]:411 if task_ports and not task["hostNetwork"] and not restricted:
407 lines.append(f" ports = {q(task_ports)}")412 lines.append(f" ports = {q(task_ports)}")
408 for field, values in (("cap_add", task["capAdd"]), ("devices", task["devices"]), ("extra_hosts", task["extraHosts"])):413 for field, values in (("cap_add", task["capAdd"]), ("devices", task["devices"]), ("extra_hosts", task["extraHosts"])):
409 if values:414 if values:
tools/spacebar.md+5
...@@ -70,3 +70,8 @@ Snow Globe's tailnet address as upstream. Its gateway relay sets...@@ -70,3 +70,8 @@ Snow Globe's tailnet address as upstream. Its gateway relay sets
70`X-Snowcord-Voice-Relay: phoenix-loopback` so voice advertises the VM's loopback70`X-Snowcord-Voice-Relay: phoenix-loopback` so voice advertises the VM's loopback
71address. The guest profile lets Phoenix bind and receive UDP on its temporary71address. The guest profile lets Phoenix bind and receive UDP on its temporary
72ports and send UDP only to the local relay port.72ports and send UDP only to the local relay port.
73
74The container runs on the `sandbox` CNI network (`restrictedEgress`), so the API,
75voice processes and SFU reach the public internet and PostgreSQL only. Forwarded
76traffic to private, tailnet and link-local addresses is dropped in the raw table
77(`nixos/snowglobe.nix`), including Snow Globe's own sshd and the router.