feat(routing): Lab Host Router closes the Gateway-to-Lab cross-VM gap
Adds platform/lab-router/ — a narrow service that runs on the Lab Host, authenticates the Gateway via mTLS, and resolves an opaque routing token to a local container purely from Docker label state (no Postgres access, no callback to the Provisioner). Replaces the Gateway's env.internal_ip assumption (only valid when Gateway and Lab share a Docker daemon) with a data-driven direct/router decision per lab_host (lab_hosts.routing_mode/router_endpoint, migration 004), resolved in one place (platform/gateway/src/lab-endpoint.js's labTarget()) that every proxy/fetch call site in server.js now goes through. Extends the existing Docker TLS CA (infra/scripts/docker-tls/generate-docker-tls.sh) with a second mTLS leaf pair (router-server/gateway-client) for this new data-plane connection, deployed by the docker-tls Ansible role into a separate directory from the control-plane pair. Firewall (rn-lab-host-01.rules) replaces the old speculative wide port-range allowance with one narrow rule: platform_ip -> the Router's port only. dev-local stays routing_mode: direct — zero behavior change for local dev, confirmed by the full existing regression suite passing unmodified.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
# Production compose for rn-lab-host-01. Deployed by infra/ansible/roles/lab-host/ to
|
||||
# /opt/rootnode/lab-host/docker-compose.yml, run as a systemd unit
|
||||
# (rootnode-lab-host.service.j2). Runs exactly one long-lived service: the shared egress proxy
|
||||
# every student Lab's outbound traffic passes through (platform/egress-proxy/, unchanged since
|
||||
# Phase 1). Student Lab containers themselves are NOT part of this compose file — they're
|
||||
# created/destroyed individually by the Provisioner over the remote Docker TLS endpoint
|
||||
# (dockerd itself, not compose), same mechanism as dev, just remote.
|
||||
# (rootnode-lab-host.service.j2). Runs the shared egress proxy every student Lab's outbound
|
||||
# traffic passes through (platform/egress-proxy/, unchanged since Phase 1) and, as of Phase
|
||||
# 4.1, the Lab Host Router (platform/lab-router/) that gives the Gateway on rn-platform-01 a
|
||||
# way to reach a running Lab without ever touching a Docker-internal address — see
|
||||
# docs/PHASE4_1_PREPRODUCTION_HARDENING.md §1-3. Student Lab containers themselves are NOT
|
||||
# part of this compose file — they're created/destroyed individually by the Provisioner over
|
||||
# the remote Docker TLS endpoint (dockerd itself, not compose), same mechanism as dev, just
|
||||
# remote; the Router finds them by label, purely from local Docker state (see its own README).
|
||||
|
||||
networks:
|
||||
rn-egress:
|
||||
@@ -22,6 +25,26 @@ services:
|
||||
# is the actual control, see platform/egress-proxy/allowlist.txt)
|
||||
networks: [rn-egress]
|
||||
|
||||
lab-router:
|
||||
image: "{{ registry }}/rootnode/lab-router:{{ image_tag }}"
|
||||
restart: unless-stopped
|
||||
# Needs the host's own routing table to reach whichever per-Lab bridge network
|
||||
# (rootnode-lab-net-<id>) the Provisioner created for a given container — those networks
|
||||
# aren't known ahead of time and aren't attachable one-by-one, the same reason egress-proxy
|
||||
# would need this too if it initiated connections outward instead of just accepting them.
|
||||
# Restricted to platform_ip on port {{ lab_router_port | default('8443') }} at the host
|
||||
# firewall (infra/firewall/rn-lab-host-01.rules) — this is the ONLY thing that makes host
|
||||
# networking here safe, same defense-in-depth pattern as the Docker TLS port.
|
||||
network_mode: host
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- /etc/rootnode/lab-router-tls:/tls:ro
|
||||
environment:
|
||||
LAB_ROUTER_PORT: "{{ lab_router_port | default('8443') }}"
|
||||
LAB_ROUTER_TLS_CA: /tls/ca.pem
|
||||
LAB_ROUTER_TLS_CERT: /tls/router-server-cert.pem
|
||||
LAB_ROUTER_TLS_KEY: /tls/router-server-key.pem
|
||||
|
||||
node-exporter:
|
||||
image: prom/node-exporter:latest
|
||||
restart: unless-stopped
|
||||
|
||||
Reference in New Issue
Block a user