Repository navigation
feat(deploy): the control plane on a single machine, Compose side (part of #377) - #381
Conversation
TRUST_PROXY accepts none, loopback or one IP address, never a range or a list: the gateway through which the server's Caddy reaches the API on a single machine (ADR 0021). Signed-off-by: samuel mbabhazi <[email protected]>
…chine No Caddy of its own, HTTP on loopback only, a fixed subnet whose gateway is the trusted proxy, the control plane's containers in shipkeep-controlplane.slice and PostgreSQL, the API and their namespace at oom_score_adj -900 (ADR 0021). Shipped in the bundle; compose.yml alone is unchanged. Signed-off-by: samuel mbabhazi <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Signed-off-by: samuel mbabhazi <[email protected]>
Parts 5 and 6 of #377 (ADR 0021): the installers' single-machine form, and its docs. Stacked on #381 (the Compose override). ## What changed **Control plane installer** (`deploy/control-plane/install.sh`): - Asks *Run applications on this machine too?* (default yes; `--single-machine yes|no`), and with yes the first organization's name (`--organization`). - Checks before anything: 2 CPUs, 3 GiB, cgroup v2 with `memory_recursiveprot`, port 3000 free; after Docker is installed, the `systemd` cgroup driver. - Creates `shipkeep-controlplane.slice` (`MemoryLow` = the reservation), runs Compose with `compose.single-machine.yml`, creates the first account, then the organization (`organization create`), reads the CA fingerprint (`server ca-fingerprint`), takes the agent and the server installer **from its own image** (`/app/web/browser/install`, each checked against the image's manifest), and runs the server installer with the join token piped from `server join-token`, never shown or stored by this script. - Waits for HTTPS through the server's Caddy (via the network gateway), and points at `journalctl -u shipkeep-caddy` and at both compose files in its messages. **Server installer** (`deploy/install.sh`): - `--local-control-plane 127.0.0.1:<port>` and `--agent-file <path>` (still checked against the pinned SHA-256). - Same machine checks; the agent's configuration gets `connect`, `route`, `reservation`, `workloads_slice` and `workloads_oom_score_adj` 1000; `shipkeep.slice` gets `MemoryLow`; `shipkeep-workloads.slice` gets `MemoryMax` = memory − reservation and `CPUWeight` 50. **Docs**: `INSTALL.md` (One machine for everything), threat model D4, ARCHITECTURE. ## Why ADR 0021: one rented server is enough to install Shipkeep and deploy to it. ## How it was tested - `deploy/install_test.sh` and `deploy/control-plane/install_test.sh`: the new checks (mounts, meminfo, the local address, the slice unit, yes/no answers, organization names and slugs), refused options stop before anything changes and never show the token, both installers carry the same reservation values. ShellCheck clean. - **End to end, on a fresh Ubuntu 24.04 with systemd and no Docker** (privileged container, nested Docker 29.10, cgroup v2), with a bundle built from these branches and the image pulled by digest from a TLS registry; the installer driven through a real terminal with the default answers: - Docker, the control plane, the first account, the organization and this server installed in one run; the password never appeared in the output. The agent enrolled over `127.0.0.1:7443` (one retry while Docker restarted for the egress proxy). - Caddy owns 80 and 443; the API listens on `127.0.0.1:3000` only; the control plane's route is first in Caddy. - `shipkeep.slice` and `shipkeep-controlplane.slice` `memory.low` = 1 GiB; `shipkeep-workloads.slice` `memory.max` = memory − 1 GiB, CPU weight 50; PostgreSQL, the API and `net` in `shipkeep-controlplane.slice` with `oom_score_adj` -900; Docker in `shipkeep.slice`. - The node reports `reserved_cpu_millis` 500 and `reserved_memory_bytes` 1 GiB. A deployed application runs in `shipkeep-workloads.slice` with `oom_score_adj` 1000, pulled through the egress proxy. - A 16 GiB application deployed; its redeployment refused before anything started with *the old and the new release do not fit together beside the control plane reservation…*, the old release still serving. - A login carrying `X-Forwarded-For: 6.6.6.6` recorded the real client address, not the forged one nor the internal gateway. - From the application's network, port 3000 of the control plane is unreachable by every address (its container, both gateways, loopback). - After `DELETE /config/apps/http` in Caddy, the route was back in 12 s; after a reboot of the machine, every service, the route, the slices and scores, and both applications came back, node ready. - The `.test` name gets no public certificate, so the installer ends with its certificate message, as in earlier labs; the rest of the run used an internal TLS policy added to the lab's Caddy. ## Not tested Memory pressure (the kill order and `memory.low` under reclaim) and a public certificate: the lab machine shares the host's memory, and a `.test` name has no certificate. Both need the test VM (#200). ## Security considerations The join token goes from one command to the other through a pipe, never on a terminal or in a file of the installer. The agent and the server installer come from the control plane image the bundle pins by digest, and are checked against its manifest; the server installer still checks the agent's SHA-256. The installer refuses the single-machine form on a machine where memory protection would not work, rather than install it half-protected. The threat model says that a single machine shares a kernel and recommends two machines for untrusted code. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added an option to install the control plane and workloads on one machine, with resource reservations and deployment-fit checks; separate-server installations remain available. * Interrupted installations can resume from incomplete steps while preserving the organization identity. * Organization creation can reuse a specified ID, returning the existing organization when its details match and rejecting conflicts. * **Bug Fixes** * Installation now validates required files and system prerequisites before setup. * **Documentation** * Updated installation, architecture, and security guidance for single-machine setup, troubleshooting, and teardown. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: samuel mbabhazi <[email protected]>
…machine check remains (#415) Part of #413. ## What changed Step 1 of the first stable version (#377, the single-machine installation of ADR 0021) said it waited for nothing. In fact its code and docs were merged on 2026-11-20 in #378, #379, #380, #381 and #382, as the last comment on #377 says. Only the ADR's last acceptance criterion remains: a real machine with a public name and certificate. - Step 1 now says that, and points to step 5. - Step 5 lists #377 with the other real-machine checks. ## How it was tested Prettier check. Documentation only. ## Security considerations None: documentation only. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Documentation** * Clarified that step 1 covers single-machine installation and requires step 5 to complete real-machine acceptance. * Added issue `#377` to step 5 and identified it as a prerequisite for step 1 acceptance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: samuel mbabhazi <[email protected]>
Part 4 of #377 (ADR 0021): the Compose side of the single-machine form.
What changed
TRUST_PROXYaccepts a third form, one IP address (IPv4 or IPv6), besidesnoneandloopback. Ranges, lists, keywords such asuniquelocaland anything with spaces are refused at startup.deploy/control-plane/compose.single-machine.yml, an override used withcompose.yml(docker compose -f compose.yml -f compose.single-machine.yml up -d):caddygets a profile nobody enables): the server's Caddy owns 80 and 443 and reaches the control plane through the route the agent keeps (feat(agent): the control plane's route on the machine that hosts it (ADR 0021, part of #377) #378);127.0.0.1:3000only, the agent gateway on every address;172.31.250.0/24, whose gateway172.31.250.1is the only trusted proxy;net) and the one-shot steps inshipkeep-controlplane.slice; PostgreSQL, the API andnetwithoom_score_adj-900.compose.ymlalone is unchanged, so two-machine installations and their upgrades are not affected.TRUST_PROXYform.Why
ADR 0021 needs the control plane to run without its own Caddy, to be reachable only through the server's Caddy, and to trust forwarding headers from that path only.
How it was tested
docker compose ... config(Compose 2.40) on the merged files: services withoutcaddy; ports127.0.0.1:3000and7443; slices and adjustments as listed; the subnet and gateway;TRUST_PROXY172.31.250.1.127.0.0.1:3000:172.31.250.1as its client, with Docker's userland proxy on and with it off, which the ADR asked to check;X-Forwarded-For: 6.6.6.6arrives withX-Forwarded-For: 127.0.0.1: Caddy replaces the forged value, so the API records the real client;The node was restored (its
daemon.json, the lab network and container removed) afterwards.config.schema.spec.ts: the accepted and refusedTRUST_PROXYvalues.api:lint,api:typecheck: green.Security considerations
Forwarding headers are trusted from one address, which only the host's processes reach through a loopback-only port; the server's Caddy overwrites them. A range or list cannot be configured by mistake. Not yet used by any installer: the installer's single-machine form is the next part.
Summary by CodeRabbit
none,loopback, or one valid IP address; the default remainsnone.