Watch
0
0
Fork
You've already forked hyperhive
0

full-setup and the host swarmctl reach the controller as a pod, not through a host socket

This commit is contained in:
atlas 2026-11-26 09:22:29 +01:00 • committed by maia
commit ee6b5f69f6

View file

@ -133,25 +133,25 @@ it can rebuild.
The job graph lives in memory; hive status and wanted state live in the swarm
queue, so both survive a restart.
## Why a unix socket, not a port
## The unix socket and the TCP listener
The hive-gateway's nginx is the only intended client (`swarmctl` runs as root).
A listener that is never bound to an address cannot be
reached from off-host by mistake.
The daemon binds a unix socket inside its pod, which nothing on the host can reach.
The gateway's nginx reaches the controller through the TCP listener below, and the host's
`swarmctl` goes through the gateway as the operator's own SSO account.
The socket path is `services.hyperhive.deploy.swarm-controller.socketPath`, default
`/run/swarm-controller/controller.sock`, exported to the process as
`SWARM_CONTROLLER_SOCKET`.
## The optional TCP listener
## The TCP listener
`services.hyperhive.swarm.controller.tcp.enable` (default off) adds a TLS listener beside the
socket, for a gateway that reaches the controller over the network. The routes trust their
`services.hyperhive.swarm.controller.tcp.enable` (default on wherever the swarm has a domain)
adds a TLS listener beside the socket, and it is the only way the gateway reaches the pod. The routes trust their
transport and check no caller, so the listener finishes a handshake for one client only
(`src/tcp_tls.rs`): a certificate that chains to the swarm services root, carries `clientAuth`,
and names `gateway-client.<swarm.domain>` in a subject alternative name. No certificate, another
name, or the `serverAuth`-only swarm-services leaf is refused during the handshake, before any
HTTP. The socket stays and answers exactly as before.
HTTP. The socket answers the same routes inside the pod, and checks no caller either.
The daemon takes five variables, all or none (`SWARM_CONTROLLER_TCP_LISTEN`, `_CERT`, `_KEY`,
`_CLIENT_CA`, `_CLIENT_NAME`), which the nix module sets from the options. It re-reads the server
@ -168,9 +168,8 @@ host so blast radius is unchanged."_
What keeps that safe is that the directory is `0750`, owned by the
`swarm-controller-clients` group, and holds **one** socket. nginx is in that
group through its unit's `SupplementaryGroups`; root bypasses mode bits. The host's `swarmctl` reaches the controller
through the gateway by default (`SWARMCTL_SWARM`), so nginx is the only routine client;
root opens the socket only for a verb run with `SWARMCTL_SWARM` empty. Every other local
user gets `EACCES` at the directory. The group is not `swarm-controller`'s own, which also owns the
through the gateway (`SWARMCTL_SWARM`) and sets no socket, so nginx is the only client
the module expects. Every other local user gets `EACCES` at the directory. The group is not `swarm-controller`'s own, which also owns the
state directory. So:
> **Never point `socketPath` at a directory that carries anything else.**