Watch
0
0
Fork
You've already forked hyperhive
0

run the log store and its auth responders as pods

swarm-logs-auth and swarm-metrics-auth take --listen for a TCP address beside
--socket. The log store is a Deployment on a static local volume that is its
old container's data directory, behind a ClusterIP Service the gateway dials by
name. Its two auth_request responders are one unpinned pod with a jwt role.
The renderer gains a plain HTTP listener, a probe path, fsGroupChangePolicy,
and one policy for a pod with both a listener and egress.
This commit is contained in:
atlas 2026-11-26 10:17:57 +01:00 • committed by maia
commit 71b2e9310c

View file

@ -2,8 +2,9 @@
The swarm services that have a pod run in the host's cluster and nowhere else:
`swarm-notify-router`, `swarm-stt`, `swarm-ci-metrics`, `swarm-review-classifier`,
`swarm-claude-login`, `swarm-controller` and the queue with its auth callout
(`swarm-nats`). Each runs once per swarm, because two copies would share one
`swarm-claude-login`, `swarm-controller`, the queue with its auth callout
(`swarm-nats`) and the log store with its responders (`swarm-victorialogs`,
`swarm-logs-auth`). Each runs once per swarm, because two copies would share one
queue consumer and one set of buckets, or two cursors that push every CI run
twice. A host that enables one gets [the cluster node](node.md) with it: no
option moves a service between the host and the cluster, and the host has no
@ -14,7 +15,7 @@ gateway, `swarm-builder`, `swarm-matrix-ctl` and every hive stay on the host.
`services.hyperhive.deploy.k8s.enable` defaults on where the host enables any
of `deploy.notify-router`, `stt`, `ci-metrics`, `review-classifier`,
`claude-login`, `nats` or `swarm-controller`. `deploy.singleHostSwarm` and
`claude-login`, `nats`, `swarm-controller` or `victorialogs`. `deploy.singleHostSwarm` and
`deploy.allSwarmServices` enable them, so an all-local host gets the node and
every service in the cluster with no further option. A host that sets
`deploy.k8s.enable = false` while it enables one fails at evaluation, and the
@ -55,6 +56,8 @@ The data stays where it was:
([State](#state)).
- The poller's cursor is `/var/lib/private/swarm-ci-metrics`, mounted the same
way.
- The log store's pod mounts `/var/lib/nixos-containers/swarm-victorialogs/var/lib/victorialogs`,
the directory the container's store used ([The log store](#the-log-store)).
- The other services keep nothing a move has to carry.
The pods log in to the store with their ServiceAccount tokens, so the store's
@ -296,6 +299,77 @@ strategy, and the removed container stops before the pod can start.
descriptors are the container runtime's, not the 800000 the container's unit
sets. The VM test checks the runtime's is at least that.
## The log store
`swarm-victorialogs` is the swarm's log store: one VictoriaLogs, with the two
`auth_request` responders of its gateway vhost in a second pod. The gateway's
vhost `logs.<swarm domain>` stays on the host, and so do the collector that
writes to the store and Grafana that reads it.
- **The store's pod.** The first service rendered without a unit of the module's
own: the module defines the daemon's `ExecStart`, with its flags
(`-storageDataPath`, `-httpListenAddr`, `-retentionPeriod`) as a list, and its
`StateDirectory`, and the renderer reads the pod from those. The image holds
the nixpkgs build of `victoria-logs` and nothing else. The pod serves plain
HTTP on port 9428, probed on `/health`, logs in to nothing and pushes no
telemetry: its output is the pod's log, which the host collector reads like
any pod's ([logs](telemetry.md#logs)), and the collector scrapes the store's
own metrics through the gateway. Its Deployment has one replica and the
`Recreate` strategy, and the removed container stops before the pod can start.
- **State.** The store's data directory is the container's own on the host,
`/var/lib/nixos-containers/swarm-victorialogs/var/lib/victorialogs`: the claim
`swarm-victorialogs-store` binds a static local volume on it, so an upgrade
moves the process and not the bytes. Its `nodeAffinity` and the pod's
`nodeSelector` both name the node label
`hyperhive.darkest.space/state-victorialogs`
([node labels](node.md#node-labels)), so the pod and the directory stay on the
node that carries it. The files the container wrote belong to a user of its
own, which the pod's user isn't. The pod's `fsGroup` is `65532`, and its
`fsGroupChangePolicy` is `OnRootMismatch`: the first start after the upgrade
gives the pod's group the whole tree, and later starts look at the directory
alone, so a restart doesn't walk a store of many files. The files keep their
user. The module makes the directory on a host that never ran the container,
leaving the owner and mode of an existing one alone. The volume's capacity is
nominal: a local volume's size isn't enforced, and retention
(`deploy.victorialogs.retentionPeriod`, 30 days) is what bounds the store.
- **The gateway's hop.** The host can't reach a unix socket inside a pod, so the
store serves TCP and a ClusterIP Service,
`swarm-victorialogs.<namespace>.svc.<cluster domain>`, publishes it. The
vhost's locations dial the Service's name through nginx's `resolver` (the
hive's dnsmasq) and a variable, as [the controller's](#the-controller) do, so
`gateway.dns.enable` has to be on. Each role has a variable of its own, because
the auth subrequests run their own `set`. A `proxy_pass` with a variable and a
URI part sends that URI and not the request's own, so the store's locations
write none, and the request's path and query reach the store as the caller sent
them. The collector's push, Grafana's datasource, the controller's and
hive-c0re's query URLs and the agents' `swarm-logs` all use
`logs.<swarm domain>`, which the host serves: none of them changes.
- **The responders' pod.** `swarm-logs-auth`, which checks an agent's bearer and
its `logs` permission, and `swarm-logs-grafana-auth` (the `swarm-metrics-auth`
binary), which checks Grafana's, run as two containers of one Deployment,
`swarm-logs-auth`. Both log in as the cert role `swarm-logs-auth` does, so the
pod has one ServiceAccount and one jwt role of that name, and both read the
store with the pod's token. They hold no state and nothing in the store pod
calls them, so the pod has no node label and runs on any node, and only the
gateway's subrequests (`auth_request`) reach them: each serves TCP
(`--listen`) on 8081 and 8082, behind a Service each. A unix socket couldn't
stay, because the host's nginx can't open a socket inside a pod, and Pod
Security `restricted` refuses a `hostPath` for it.
- **Who reaches what.** Both pods have a NetworkPolicy that selects them for
ingress and allows none, so only the node's own traffic reaches them: the
host's nginx, which dials the Services, and the kubelet's probes. The policy
refuses a pod of the cluster. The store takes writes and reads with no credential, so a
process on the host can read and write it: see
[Agent security](../../2-handbook/agents/security.md). The responders' policy
also lets the pod reach cluster DNS and the store's pod listener on the
bridge's address (`egress = [ "store" ]`), the one host port the pod needs
until the store moves into the cluster.
- **The host's part.** The host keeps the vhost, `gateway.localNames` and the
options (`retentionPeriod`, `authRate`, `authBurst`, `authVerdictTtl` and the
store identity files). It runs no container, unit or socket directory for
either pod, and no journal forwarder: the host collector reads the pods'
output from the node like any pod's.
## Resources and sandbox
The pod takes the unit's `MemoryMax` and `CPUQuota` as its container's limits
@ -362,8 +436,9 @@ forwards.
## Validation
`module-eval-k8s` checks that the all-local host runs every service as a pod and
none as a container, unit or timer; that the node defaults on through the
all-local mode and through one toggle, and an explicit `false` stays false; that a
none as a container, unit or timer, and that the log store's volume is its
old container's directory and its responders' pod has no node label; that the node
defaults on through the all-local mode and through one toggle, and an explicit `false` stays false; that a
host with the node off and a service on fails with a message naming the option
and the services; that a controller without the TCP listener, the pod's bind
address or the hive's resolver fails the evaluation; that the manifests sit in
@ -409,4 +484,18 @@ listener refuses a client with no leaf. It runs the gateway's own controller
location, from the module's text, against the pod: it answers an unsigned
webhook 401. A changed rev rolls the Deployment onto a new pod.
The same VM test runs the log store. A unit of the test writes a record into the old
container's data directory as another user before the cluster starts, because the
container is no longer in the module to switch from. It asserts that the host has no
container, unit or socket directory for the store or its responders; that the
volume is that directory and the pod's group owns the tree; that a gateway, run
from the module's own locations in a nginx of its own, returns the record to an
agent's bearer, refuses an agent without the grant and a wrong secret, and
checks Grafana's bearer with the second responder; that the store keeps a record
posted to the ingest route and both records across a pod delete; and that the
policy refuses a peer pod the Services while it admits the node and the
kubelet. The `swarm-logs`
CLI itself isn't run: it needs an agent's store certificate, so the test
presents the `Authorization` header it sends.
`k8s-bao-login` and `k8s-node` check the store's login and the node.