Watch
0
0
Fork
You've already forked hyperhive
0

docs: the start gate describes what the pod runs

This commit is contained in:
atlas 2026-11-22 18:59:22 +01:00 • committed by maia
commit 65f7a55967

View file

@ -29,9 +29,12 @@ cluster follow the same pattern.
own section.
- `services.hyperhive.deploy.nats.runtime` (default `"host"`), with the same
rule. One switch covers the queue's server and its auth callout. It needs
the iptables firewall (`networking.nftables.enable` off), and
`deploy.nats.k8s.freshStore` says whether a fresh store may start the
server. [The queue](#the-queue) has its own section.
the iptables firewall (`networking.nftables.enable` off).
[The queue](#the-queue) has its own section.
- `services.hyperhive.deploy.<service>.k8s.freshState` (default `false`) for
each service whose pod keeps state in a volume: `swarm-controller`, `stt`,
`ci-metrics` and `nats`. It says whether the pod may start on an empty volume
([State](#state)).
With `"host"`, a host without [the cluster node](node.md) renders the same
configuration as before the option existed. With the node on and every service
@ -105,6 +108,22 @@ claims stay; `swarmctl migrate finish` deletes them.
## State
A pod with a state volume starts only on migrated state. Its first init
container, `state-gate`, mounts the volume and exits 0 when the volume holds
`.hyperhive-migrated`. A volume with no entries besides `lost+found` gets the
marker (`{"fresh": true, "at": <time>}`) and passes where the service's
`k8s.freshState` is on. Every other volume fails the gate, including one that
holds files and no marker, since a copy may have stopped half way. The pod stays
in `Init:Error`, and the container's termination message and log carry one
line that names the service, the `swarmctl migrate` command and the option to
set for a fresh install. Nothing of the service runs on the empty volume. The
gate doesn't decide which copy runs: the host unit stops before the pod
exists. Switching a stateful service to `"k8s"` on a live host therefore needs
`swarmctl migrate`, which copies the state and writes the marker, or the
fresh flag, which is for a swarm with no state to lose.
`swarm-notify-router`, `swarm-review-classifier` and `swarm-claude-login` have
no volume and no gate.
`swarm-notify-router` keeps nothing on the host. Its durable consumer on the
forge events stream and its `notify-router-state` bucket live in the queue, so a
switch in either direction copies nothing, and the router continues from the
@ -114,19 +133,21 @@ consumer's position.
cache sits in the container's `/var/lib/swarm-stt`. In the cluster it sits in
the PersistentVolumeClaim `swarm-stt-state`, mounted at the same path. A switch
copies neither: each side starts with the cache it last had, empty the first
time, and transcribes a memo that only the other side cached. The claim stays
time (the pod's gate wants the marker or `deploy.stt.k8s.freshState` for
that), and transcribes a memo that only the other side cached. The claim stays
after a switch back, as every claim does, and the container's directory stays
too. The whisper model isn't state: the pod's image holds it, from the same
store path the container reads, and the volume doesn't.
`swarm-ci-metrics` keeps a cursor, `cursor.json`, which holds the run numbers
already pushed. On the host it sits in the service's state directory. In the
cluster it sits in the PersistentVolumeClaim `swarm-ci-metrics-state`, mounted
at the same path, and the claim binds with the first Job. A switch copies
neither, so each side keeps the cursor it last had, and the first pass on a side
with none pushes every run again, as the same points. A second Job on the same
side finds the cursor and pushes nothing. The claim stays after a switch back,
and so does the host's directory.
already pushed. On the host it sits in the service's state directory. In
the cluster it sits in the PersistentVolumeClaim `swarm-ci-metrics-state`,
mounted at the same path, and the claim binds with the first Job. A
switch copies neither, so each side keeps the cursor it last had, and
the first pass on a side with none (the pod's gate wants the marker or
`deploy.ci-metrics.k8s.freshState` for that) pushes every run again, as
the same points. A second Job on the same side finds the cursor and pushes
nothing. The claim stays after a switch back, and so does the host's directory.
## The controller
@ -197,7 +218,7 @@ holds the container back until the pod has gone.
- **Containers.** The responder is the pod's main container, `swarm-nats`,
rendered from the unit the container runs, as the other daemons are. Beside
it run `nats`, the server, `tls-renew` and `exporter`, the Prometheus
exporter. Three init containers run in order before them. `store-guard`
exporter. Three init containers run in order before them. `state-gate`
checks the JetStream volume. `tls-issue` issues the server's leaf.
`callout-config` creates the callout's keys if the store holds none, fetches
their public halves and writes the server's configuration. The server's
@ -241,10 +262,10 @@ holds the container back until the pod has gone.
- **State.** The server's store directory, `/var/lib/nats`, is the
PersistentVolumeClaim `swarm-nats-state`. The claim starts empty, and a switch
copies nothing from the container's store: it holds the swarm's declared
desired state, which nothing regenerates. `store-guard` therefore stops the
pod, with a message naming `swarmctl migrate`, when the volume holds no
JetStream data, unless `deploy.nats.k8s.freshStore` is on. Turn it on for a
fresh install only. The claim stays after a switch back, as every claim
desired state, which nothing regenerates. `state-gate` therefore stops the
pod, with a message naming `swarmctl migrate`, until the volume holds the
migration marker, unless `deploy.nats.k8s.freshState` is on. Turn it on for
a fresh install only. The claim stays after a switch back, as every claim
does, and the container's store stays too.
- **Readiness.** The pod is Ready when the responder's `/readyz`, on the pod's
port 8080, passes and the server's exec probe does. The probe runs
@ -345,17 +366,18 @@ minter's real login step does, while `claude` with `HOME` on the root leaves
nothing there.
The VM test `k8s-nats-switch` moves the queue against the real secret store. A
sampler counts servers and responders every 200 ms and sees at most one of each,
and the container and the pod never together. The pod is Ready by its exec probe
and has the init containers, the `hostPort`s and the volumes the module renders,
and its leaf's volume is a tmpfs. A client on the bridge reaches the queue by
name, and a second node outside the node reaches the control port and not the
queue's, as with the container; with `openFirewall` it dials the pod by name and
verifies the name, and the responder in the pod admits it. A stream written
before a pod delete survives it: the replacement pod reads it from the same
volume. The store guard's image refuses an empty volume, passes a fresh one and
a volume with data. The exporter answers the host's own processes through the
published port, and the switch back removes the pod before the container starts.
sampler counts servers and responders every 200 ms and sees at most one of
each, and the container and the pod never together. The pod is Ready by its
exec probe and has the init containers, the `hostPort`s and the volumes the
module renders, and its leaf's volume is a tmpfs. A client on the bridge
reaches the queue by name, and a second node outside the node reaches the
control port and not the queue's, as with the container; with `openFirewall`
it dials the pod by name and verifies the name, and the responder in the pod
admits it. A stream written before a pod delete survives it: the replacement
pod reads it from the same volume. The state gate's image refuses an empty
volume, passes a fresh one and a volume with the marker. The exporter answers
the host's own processes through the published port, and the switch back
removes the pod before the container starts.
The VM test `k8s-controller-switch` moves the controller. It asserts one copy at
each step by the switch's own timestamps and by a sampler, that the pod is Ready