| author | |
| committer | |
| log | ab54eeca0df96c59724bf78d5491bfe87b1a677d |
| tree | c996f5113ea0b1b02764ee17dcd93e2d92014d0c |
| parent | 819edbefbe5ce363a1bc53de796344792271d6bc |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Clients reach the container's Knife over the mesh, which already holds a
direct LAN path, so the signed-in web route has no user.
Assisted-by: claude-opus-5.53 files changed, 0 insertions(+), 37 deletions(-)
nixos/knife-linux.nix-20| ... | ... | @@ -15,30 +15,10 @@ let |
| 15 | 15 | exec ${pkgs.podman}/bin/podman --root=${root}/containers/storage --runroot=/run/knife-linux/containers "$@" |
| 16 | 16 | ''; |
| 17 | 17 | run = "${podman}/bin/knife-linux-podman"; |
| 18 | web = "13773"; | |
| 19 | 18 | in |
| 20 | 19 | { |
| 21 | 20 | environment.systemPackages = [ podman ]; |
| 22 | 21 | |
| 23 | # Knife listens on the container's loopback; the router publishes this port behind | |
| 24 | # Snow Globe sign-in, and Knife still requires its own paired session. | |
| 25 | systemd.services.knife-linux-web = { | |
| 26 | description = "Host port for the Knife web client"; | |
| 27 | wantedBy = [ "multi-user.target" "knife-linux.service" ]; | |
| 28 | bindsTo = [ "knife-linux.service" ]; | |
| 29 | after = [ "knife-linux.service" ]; | |
| 30 | serviceConfig = { | |
| 31 | ExecStart = pkgs.writeShellScript "knife-linux-web" '' | |
| 32 | pid=$(${run} inspect --format '{{.State.Pid}}' knife-linux) | |
| 33 | exec ${pkgs.socat}/bin/socat TCP-LISTEN:${web},bind=127.0.0.1,fork,reuseaddr \ | |
| 34 | "EXEC:${pkgs.util-linux}/bin/nsenter --target=$pid --net ${pkgs.socat}/bin/socat STDIO TCP\:127.0.0.1\:3773" | |
| 35 | ''; | |
| 36 | Restart = "always"; | |
| 37 | RestartSec = 5; | |
| 38 | }; | |
| 39 | }; | |
| 40 | systemd.services.snowglobe-router.environment.SNOWGLOBE_KNIFE_PORT = web; | |
| 41 | ||
| 42 | 22 | systemd.services.knife-linux = { |
| 43 | 23 | description = "The Knife Linux agent container"; |
| 44 | 24 | wantedBy = [ "multi-user.target" ]; |
tools/knife-linux.md-6| ... | ... | @@ -17,12 +17,6 @@ agent. Image and unit changes apply at the next manual |
| 17 | 17 | last only until then, so add them to the Containerfile too. Devices cannot be |
| 18 | 18 | added to the running container. |
| 19 | 19 | |
| 20 | `https://personal.knife.paperclover.net` serves the Knife web client behind Snow | |
| 21 | Globe sign-in for `infra-admin`. `knife-linux-web` relays host port 13773 into the | |
| 22 | container's loopback, so Knife still needs its own session: pair each browser | |
| 23 | once with `knife pair --label NAME` inside the container, then open the printed | |
| 24 | `/pair#token=…` path on that host. | |
| 25 | ||
| 26 | 20 | | Container path | Host source | |
| 27 | 21 | | --- | --- | |
| 28 | 22 | | `/Volumes/Code` | the Mac VM's NFS export, `/srv/mac-studio-vm/sandbox` | |
tools/router.py-11| ... | ... | @@ -268,17 +268,6 @@ def render(token): |
| 268 | 268 | route = routes.setdefault((listener, ""), {"upstreams": set(), "services": set()}) |
| 269 | 269 | route["upstreams"].add(upstream) |
| 270 | 270 | |
| 271 | knife_port = os.environ.get("SNOWGLOBE_KNIFE_PORT") | |
| 272 | if knife_port is not None: | |
| 273 | knife_host = "personal.knife." + os.environ["SNOWGLOBE_DOMAIN"] | |
| 274 | if not knife_port.isdecimal() or not 1 <= int(knife_port) <= 65535 or not HOST.fullmatch(knife_host): | |
| 275 | raise ValueError("invalid Knife route") | |
| 276 | if (80, knife_host) in routes: | |
| 277 | raise ValueError(f"Knife route conflicts with a Nomad service: {knife_host}") | |
| 278 | routes[(80, knife_host)] = {"upstreams": {f"127.0.0.1:{int(knife_port)}"}, "services": {"knife-linux"}, | |
| 279 | "authRole": "infra-admin", "userHeader": None, "internal": False, | |
| 280 | "realIp": False, "secureCookies": False} | |
| 281 | ||
| 282 | 271 | lines = [] |
| 283 | 272 | for (listener, host), route in sorted(routes.items()): |
| 284 | 273 | if host: |