k8s: the queue's pod mounts the host unit's store in place
This commit is contained in:
parent
6ac4e9b87d
commit
8b4ae09b45
1 changed files with 267 additions and 155 deletions
|
|
@ -32,8 +32,8 @@ cluster follow the same pattern.
|
|||
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 worth moving in a volume:
|
||||
`swarm-controller` and `nats`. It says whether the pod may start on an empty
|
||||
the service whose pod keeps state worth moving in a volume:
|
||||
`swarm-controller`. 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
|
||||
|
|
@ -108,13 +108,13 @@ claims stay; `swarmctl migrate finish` deletes them.
|
|||
|
||||
## State
|
||||
|
||||
A pod with a state volume that holds state worth moving (`swarm-controller` and
|
||||
NATS) 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
|
||||
A pod with a state volume that holds state worth moving (`swarm-controller`)
|
||||
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
|
||||
|
|
@ -122,8 +122,9 @@ 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, and `swarm-stt` and
|
||||
`swarm-ci-metrics` have a volume that the gate doesn't check.
|
||||
`swarm-claude-login` have no volume and no gate, `swarm-stt` and
|
||||
`swarm-ci-metrics` have a volume that the gate doesn't check, and the queue's
|
||||
volume is the host unit's own directory.
|
||||
|
||||
`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
|
||||
|
|
@ -215,15 +216,14 @@ Deployment has one replica and the `Recreate` strategy, and the prune unit
|
|||
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. `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
|
||||
settings are the ones the container's `services.nats.settings` render, so a
|
||||
change to them reaches both. Only the path of the server's key differs,
|
||||
because the pod has no credential directory.
|
||||
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.
|
||||
Two init containers run in order before them. `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 settings are the ones the container's `services.nats.settings`
|
||||
render, so a change to them reaches both. Only the path of the server's key
|
||||
differs, because the pod has no credential directory.
|
||||
- **Names.** The pod's `hostAliases` map the queue's name to the pod's own
|
||||
loopback, so the responder dials the server by the name its leaf carries and
|
||||
verifies it, with no traffic leaving the pod. Every other client reaches the
|
||||
|
|
@ -265,14 +265,15 @@ holds the container back until the pod has gone.
|
|||
the leaf for the gateway's `/metrics` vhost, and with no container it has
|
||||
nothing to restart. The gateway's location dials the exporter on the bridge's
|
||||
address where it dialled loopback.
|
||||
- **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. `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.
|
||||
- **State.** The server's store directory, `/var/lib/nats`, is the container's
|
||||
own on the host, `/var/lib/nixos-containers/swarm-nats/var/lib/nats`: the
|
||||
PersistentVolumeClaim `swarm-nats-store` binds a static local volume on it,
|
||||
so a switch moves the process and not the bytes, and the pod has no state
|
||||
gate. The container's unit runs `chown -R nats:nats` on the directory before
|
||||
the server starts, and the pod's `fsGroup` gives its group read and write.
|
||||
[The queue's store](migrate.md#the-queues-store) has the details. The claim
|
||||
and its volume stay after a switch back, as every claim does, with the
|
||||
directory.
|
||||
- **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
|
||||
`wget` against `/healthz?js-enabled-only=true` on the server's monitor, which
|
||||
|
|
@ -379,11 +380,12 @@ 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.
|
||||
admits it. A key written on the host before the switch is the pod's to read, a
|
||||
key the pod writes is the host server's after the switch back, and a stream
|
||||
written before a pod delete survives it: the replacement pod reads it from the
|
||||
same directory. 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue