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:
@@ -8,6 +8,7 @@
|
||||
| `rootnode/gateway` | `platform/gateway/Dockerfile` | `{{ registry }}/rootnode/gateway` |
|
||||
| `rootnode/provisioner` | `platform/provisioner/Dockerfile` | `{{ registry }}/rootnode/provisioner` |
|
||||
| `rootnode/egress-proxy` | `platform/egress-proxy/Dockerfile` | `{{ registry }}/rootnode/egress-proxy` |
|
||||
| `rootnode/lab-router` | `platform/lab-router/Dockerfile` (Phase 4.1) | `{{ registry }}/rootnode/lab-router` |
|
||||
| `rootnode/lab` | root `Dockerfile` (the student Lab image) | `{{ registry }}/rootnode/lab` |
|
||||
|
||||
## Tagging
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -88,6 +88,11 @@ services:
|
||||
image: "{{ registry }}/rootnode/platform-api:{{ image_tag }}"
|
||||
restart: unless-stopped
|
||||
env_file: /etc/rootnode/platform.env
|
||||
environment:
|
||||
# Phase 4.1 §25 — not a secret, just the deployed tag; set directly here rather than in
|
||||
# the env template since it's the same value already used for the image tag above, not a
|
||||
# separately-managed setting.
|
||||
GIT_SHA: "{{ image_tag }}"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
@@ -99,6 +104,10 @@ services:
|
||||
image: "{{ registry }}/rootnode/gateway:{{ image_tag }}"
|
||||
restart: unless-stopped
|
||||
env_file: /etc/rootnode/gateway.env
|
||||
volumes:
|
||||
# mTLS client identity for the Lab Host Router (data plane) — see gateway.env.j2's
|
||||
# LAB_ROUTER_TLS_* vars. Read-only; the private key never leaves this one bind mount.
|
||||
- /etc/rootnode/lab-router-tls:/tls:ro
|
||||
depends_on: [provisioner, api]
|
||||
networks: [rn-platform-internal]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user