docs: the controller's runtime, hostPort hop, listener leaf, state and rev rollout
This commit is contained in:
parent
713f866030
commit
e7334ad98e
1 changed files with 114 additions and 16 deletions
|
|
@ -6,9 +6,9 @@ is `"host"` (the default) or `"k8s"`. The service runs once per swarm, so the
|
|||
option moves it and never copies it: the host unit and the pod never run
|
||||
together, because they would share one queue consumer and one set of buckets,
|
||||
or two cursors that push every CI run twice. `swarm-notify-router`,
|
||||
`swarm-stt`, `swarm-ci-metrics`, `swarm-review-classifier` and
|
||||
`swarm-claude-login` have the option today, and the other services that run in
|
||||
the cluster follow the same pattern.
|
||||
`swarm-stt`, `swarm-ci-metrics`, `swarm-review-classifier`,
|
||||
`swarm-claude-login` and `swarm-controller` have the option today, and the
|
||||
other services that run in the cluster follow the same pattern.
|
||||
|
||||
## Options
|
||||
|
||||
|
|
@ -20,6 +20,12 @@ the cluster follow the same pattern.
|
|||
`services.hyperhive.deploy.review-classifier.runtime` and
|
||||
`services.hyperhive.deploy.claude-login.runtime` (default `"host"`), with the
|
||||
same rule.
|
||||
- `services.hyperhive.deploy.swarm-controller.runtime` (default `"host"`), with
|
||||
the same rule. It also needs
|
||||
`services.hyperhive.swarm.controller.tcp.enable`, and
|
||||
`deploy.swarm-controller.tcp.listenAddress` at its default `0.0.0.0`: the
|
||||
evaluation fails without either. [The controller](#the-controller) has its
|
||||
own section.
|
||||
|
||||
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
|
||||
|
|
@ -31,7 +37,10 @@ on `"host"`, the cluster holds no service objects.
|
|||
(`swarm-notify-router`, `swarm-stt`, `swarm-review-classifier`,
|
||||
`swarm-claude-login`), no credential hand-ins for it and no journal forwarder
|
||||
for it. `swarm-ci-metrics` has no container: its service, its timer and the
|
||||
CA bundle unit of its service go.
|
||||
CA bundle unit of its service go. `swarm-controller` has no container
|
||||
either: the host turns `swarm-controller.service` off, so nothing can start
|
||||
it, and defines no `swarm-controller-tls.service` or timer. The evaluated
|
||||
unit stays the source of the Deployment.
|
||||
- **The service's objects go in.** The [rendered manifests](manifests.md) reach
|
||||
the cluster through `services.k3s.manifests`, one file per service plus the
|
||||
namespace. The cluster applies a file when its link appears in the manifests
|
||||
|
|
@ -46,9 +55,13 @@ on `"host"`, the cluster holds no service objects.
|
|||
- `trust-bundle.pem`: the hive's trust bundle, where the gateway is
|
||||
self-signed;
|
||||
- `bao-server-ca.pem`: the secret store's server CA
|
||||
(`deploy.bao.serverCaFile`).
|
||||
(`deploy.bao.serverCaFile`);
|
||||
- `hive-client-ca.pem` and `swarm-services-root.pem`, with the controller in
|
||||
the cluster: the authority the controller writes into each hive's store role
|
||||
(`deploy.swarm-controller.hiveClientCaFile`), and the store's services root
|
||||
that its listener trusts the gateway's client leaf by.
|
||||
|
||||
Both are public certificates. The unit waits for the cluster and for the
|
||||
All are public certificates. The unit waits for the cluster and for the
|
||||
files, and a pod that mounts the ConfigMap waits in `ContainerCreating` until
|
||||
the unit has run. A path unit watches both files and runs the unit again when
|
||||
either changes, with no manual step. A running pod doesn't see a changed
|
||||
|
|
@ -109,6 +122,63 @@ 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.
|
||||
|
||||
## The controller
|
||||
|
||||
`swarm-controller` runs once per swarm, and nothing in the daemon guards that: a
|
||||
second copy would send the operator admin grants and revokes again, split the
|
||||
review requests the queue holds, and write the same keys. The runtime switch is
|
||||
the whole guard on one node: the Deployment has one replica and the `Recreate`
|
||||
strategy, and the prune unit holds the host unit back until the pod has gone. No
|
||||
leader lock exists, so a cluster of more than one node needs one before the
|
||||
controller may move there.
|
||||
|
||||
- **The gateway's hop.** The host can't reach a unix socket inside a pod, so
|
||||
the pod serves the TCP listener, and publishes it with a `hostPort` on
|
||||
`deploy.swarm-controller.tcp.hostAddress`. That address is the hive bridge's
|
||||
by default, the one the pods already reach the host's services on. The
|
||||
listener binds `0.0.0.0` inside the pod (`tcp.listenAddress`, which the
|
||||
evaluation holds there). The gateway's `/api/` and `/webhook/forge/`
|
||||
locations dial the node's address and port, and verify the listener's
|
||||
certificate as `swarm.controller.tcp.domain` (`proxy_ssl_name`,
|
||||
`proxy_ssl_verify`). With the controller on the host the locations dial the
|
||||
name. A `hostPort` reaches one node: a cluster of more than one node needs a
|
||||
Service instead.
|
||||
- **The listener's leaf.** The pod issues its own, from the store's
|
||||
`swarm-controller-tls` role, with the same script as
|
||||
`swarm-controller-tls.service`. An init container logs in with the pod's
|
||||
ServiceAccount token (the `swarm-controller` role of the `jwt-k8s` mount,
|
||||
whose policy holds the one issue path) and writes the leaf and its key into
|
||||
an `emptyDir` before the daemon starts. The `emptyDir` is in memory
|
||||
(`medium: Memory`), so the key never reaches a Secret or the node's disk. A
|
||||
second container, `tls-renew`, runs the script again every day, and again
|
||||
after ten minutes when the store refused. The script leaves a leaf alone
|
||||
while it's in the first half of its lifetime, as the host's daily timer
|
||||
does, and the daemon reads the new files with no restart. A sidecar renews
|
||||
because nothing rolls the pod before the leaf expires. Both containers run
|
||||
an image of their own, `swarm-controller-tls`, which holds the store client
|
||||
and the script's tools.
|
||||
- **`swarmctl`.** The controller's socket lives inside the pod, so the host's
|
||||
`swarmctl` reaches the controller only through the gateway: run
|
||||
`swarmctl login` once, then use `--swarm <url>` or a wrapper that defaults
|
||||
to it. A socket path on the host serves nothing under `runtime = "k8s"`.
|
||||
- **Probes.** The pod binds `SWARM_CONTROLLER_HEALTH_ADDR`, with liveness on
|
||||
`/healthz` and readiness on `/readyz`. Readiness needs the queue connection
|
||||
and a fresh store login, so a store role that refuses the pod's token leaves
|
||||
it NotReady.
|
||||
- **State.** `/var/lib/swarm-controller` is the PersistentVolumeClaim
|
||||
`swarm-controller-state`. It starts empty, and nothing here copies the host's
|
||||
directory into it ([migrate](migrate.md) does). An empty claim holds no
|
||||
`operator-matrix-admins.json`, which reads as an empty set: the controller
|
||||
revokes nobody, and an account removed from the operator group before the
|
||||
copy keeps its homeserver admin. The webhook secret is in the store, so it
|
||||
survives.
|
||||
- **The rev.** The unit's rev file, `/etc/hyperhive/swarm-controller.json`, is a
|
||||
`subPath` mount of the `swarm-controller-etc` ConfigMap, which a running pod
|
||||
never sees change. The Deployment's pod template carries `checksum/etc`, a
|
||||
hash of the ConfigMap's content, so a new rev rolls the pod. The host unit
|
||||
re-reads the file with no restart, so this restart, which drops the job graph,
|
||||
is new.
|
||||
|
||||
## Resources and sandbox
|
||||
|
||||
The pod takes the unit's `MemoryMax` and `CPUQuota` as its container's limits
|
||||
|
|
@ -193,3 +263,14 @@ pod's root takes no writes, so a write outside the `/tmp` volume fails, and
|
|||
that `claude` with `HOME` in the volume writes its config there, as the
|
||||
minter's real login step does, while `claude` with `HOME` on the root leaves
|
||||
nothing there.
|
||||
|
||||
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
|
||||
on `/readyz` with the `hostPort` and the volumes the module renders and no
|
||||
Secret, that its listener's leaf is the one its init container issued, valid as
|
||||
the listener's name against the hive's root, that the volume holding its key is
|
||||
a tmpfs, and that the listener refuses a client with no leaf. It runs the
|
||||
gateway's own controller location, from the module's text for each runtime,
|
||||
against the host unit and the pod: both answer an unsigned webhook 401. A
|
||||
changed rev rolls the Deployment onto a new pod and keeps the state volume, and
|
||||
the switch back deletes the pod and its AddOn before the unit starts.
|
||||
|
|
|
|||
Loading…
Reference in a new issue