run the metrics store and its auth responders as pods
This commit is contained in:
parent
3f71739852
commit
07a004fad1
1 changed files with 1308 additions and 1031 deletions
|
|
@ -8,8 +8,10 @@ how to open each service, is on
|
|||
## Metrics (VictoriaMetrics + Grafana)
|
||||
|
||||
The swarm's telemetry lands in one VictoriaMetrics, and one Grafana
|
||||
reads it, in two containers at `metrics.<swarm-domain>` and
|
||||
`grafana.<swarm-domain>`. Two containers rather than one so you can
|
||||
reads it, at `metrics.<swarm-domain>` and `grafana.<swarm-domain>`. They run
|
||||
apart so you can restart or break Grafana without taking the time-series
|
||||
database with it: VictoriaMetrics as a pod in the host's cluster
|
||||
([the metrics store](../k8s/runtime.md#the-metrics-store)), Grafana in a container.
|
||||
restart or break Grafana without taking the time-series database with it.
|
||||
|
||||
The Grafana container sits on the hive bridge in a network namespace of its
|
||||
|
|
@ -31,16 +33,16 @@ services.hyperhive.deploy = {
|
|||
⚠️ **This starts a database that grows for as long as the swarm runs.**
|
||||
See `retentionPeriod` below before leaving it at its default.
|
||||
|
||||
| Option | When you'd touch it |
|
||||
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `deploy.victoriametrics.retentionPeriod` | Default `5y`. Lower it once you have measured how fast this swarm actually fills a disk — the default is deliberately generous because too-short silently discards history you can't get back. |
|
||||
| `swarm.grafana.oidc.role` | Default `Admin` for everyone who logs in. Lower to `Viewer`/`Editor` if the swarm grows operators who shouldn't be able to reconfigure Grafana. |
|
||||
| `deploy.grafana.datasourceUrl` | Only if you front VictoriaMetrics with something else. It defaults to the store's swarm name (`https://<swarm.victoriametrics.domain>`), so Grafana and the store can run on different hosts. |
|
||||
| `deploy.grafana.logsDatasourceUrl` | Only if you front VictoriaLogs with something else. It defaults to the log store's swarm name (`https://<swarm.victorialogs.domain>`), so Grafana and the store can run on different hosts. |
|
||||
| `deploy.victoriametrics.agentAuthRate` | Default `50r/s` per client address, for agent reads checked by `swarm-metrics-agent-auth`; over it and `agentAuthBurst`, the gateway answers 403. |
|
||||
| `deploy.victoriametrics.agentAuthBurst` | Default `500` requests above `agentAuthRate` before the 403s start. |
|
||||
| `deploy.victoriametrics.agentAuthVerdictTtl` | Default `60` seconds that `swarm-metrics-agent-auth` keeps granting an agent secret it verified. A replaced or deleted secret keeps working at the metrics store for up to that long. A revoked `metrics` permission does too. |
|
||||
| `deploy.victoriametrics.agentAuthPackage` | The `swarm-logs-auth` build that runs as `swarm-metrics-agent-auth`. Set on its own: `deploy.victorialogs.authPackage` doesn't reach it. |
|
||||
| Option | When you'd touch it |
|
||||
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `deploy.victoriametrics.retentionPeriod` | Default `5y`. Lower it once you have measured how fast this swarm actually fills a disk — the default is deliberately generous because too-short silently discards history you can't get back. |
|
||||
| `swarm.grafana.oidc.role` | Default `Admin` for everyone who logs in. Lower to `Viewer`/`Editor` if the swarm grows operators who shouldn't be able to reconfigure Grafana. |
|
||||
| `deploy.grafana.datasourceUrl` | Only if you front VictoriaMetrics with something else. It defaults to the store's swarm name (`https://<swarm.victoriametrics.domain>`), so Grafana and the store can run on different hosts. |
|
||||
| `deploy.grafana.logsDatasourceUrl` | Only if you front VictoriaLogs with something else. It defaults to the log store's swarm name (`https://<swarm.victorialogs.domain>`), so Grafana and the store can run on different hosts. |
|
||||
| `deploy.victoriametrics.agentAuthRate` | Default `50r/s` per client address, for agent reads checked by the agents' responder; over it and `agentAuthBurst`, the gateway answers 403. |
|
||||
| `deploy.victoriametrics.agentAuthBurst` | Default `500` requests above `agentAuthRate` before the 403s start. |
|
||||
| `deploy.victoriametrics.agentAuthVerdictTtl` | Default `60` seconds that the agents' responder keeps granting an agent secret it verified. A replaced or deleted secret keeps working at the metrics store for up to that long. A revoked `metrics` permission does too. |
|
||||
| `deploy.victoriametrics.agentAuthPackage` | The `swarm-logs-auth` build that runs as the first container of the responders' pod. Set on its own: `deploy.victorialogs.authPackage` doesn't reach it. |
|
||||
|
||||
<!-- vale write-good.Passive = NO -->
|
||||
|
||||
|
|
@ -101,19 +103,19 @@ The `controller` panels come from the controller itself. It exports OTLP
|
|||
through the gateway to the swarm's collector from whatever host it runs on,
|
||||
whether or not that host runs the collector.
|
||||
|
||||
Neither container is reachable except through the gateway: each listens
|
||||
on a unix socket only the gateway's nginx can open, and VictoriaMetrics
|
||||
runs in a network namespace of its own with no interface but loopback.
|
||||
VictoriaMetrics authenticates nothing itself; the `metrics.<swarm-domain>`
|
||||
vhost does it:
|
||||
Neither is reachable except through the gateway: Grafana listens on a unix
|
||||
socket only the gateway's nginx can open, and VictoriaMetrics behind a Service
|
||||
that admits only the host's own traffic. VictoriaMetrics authenticates nothing
|
||||
itself; the `metrics.<swarm-domain>` vhost does it:
|
||||
|
||||
- **The read API** (the Prometheus query, series, label and metadata
|
||||
routes): Grafana's datasource, an agent, or an operator. Grafana sends a
|
||||
bearer that `swarm-bao-grafana-metrics-bearer` creates in the swarm secret
|
||||
store, and `swarm-metrics-auth` on the store's host checks it against the
|
||||
store, and Grafana's responder (the second container of the responders' pod)
|
||||
checks it against the
|
||||
same store path. An agent's `swarm-metrics` sends its
|
||||
`swarm-agent.<agent>.<secret>` bearer, which `swarm-metrics-agent-auth` on
|
||||
the store's host checks against `swarm/agents/<agent>/queue`. It also needs the `metrics`
|
||||
`swarm-agent.<agent>.<secret>` bearer, which the agents' responder (the first
|
||||
container) checks against `swarm/agents/<agent>/queue`. It also needs the `metrics`
|
||||
permission, or the answer is a 403. A request
|
||||
without a bearer needs an operator's authelia session (group `admins`);
|
||||
without one it gets a 401, not a login redirect.
|
||||
|
|
@ -126,35 +128,29 @@ vhost does it:
|
|||
|
||||
The gateway remembers authelia's answer for the collector's push route. It keys the answer on the request's `Authorization` header and the route, keeps only a 200, and keeps it for 60 seconds. A burst of pushes from one token costs authelia one subrequest, and a push that finds its verdict in the cache doesn't wait on authelia, however slow it is. A 401 or 403 always goes to authelia again. A request without an `Authorization` header skips the cache, and the subrequest drops the `Cookie` header. A revoked or expired token keeps pushing for up to 60 seconds. The `/metrics` scrape and the other routes ask authelia every time.
|
||||
|
||||
`swarm-metrics-auth` and `swarm-metrics-agent-auth` read the store with one
|
||||
leaf, `deploy.victoriametrics.authBaoClientCertFile` / `authBaoClientKeyFile`.
|
||||
Where the secret store runs on the same host, these default to the leaf it
|
||||
mints. On any other host you place a leaf whose CN is
|
||||
`deploy.bao.metricsAuthCommonName`, and evaluation refuses the config until
|
||||
you set both. `swarm-metrics-auth` reads the stored bearer at most once a
|
||||
minute, so a replaced bearer starts working up to a minute later. When the
|
||||
store doesn't answer within five seconds, it checks requests against the
|
||||
The two responders are the containers of one pod, `swarm-metrics-auth`, which
|
||||
logs in to the secret store with its ServiceAccount token under one role.
|
||||
`deploy.victoriametrics.authBaoClientCertFile` / `authBaoClientKeyFile` still
|
||||
name a leaf: where the secret store runs on the same host, they default to the
|
||||
leaf it mints, and on any other host you place a leaf whose CN is
|
||||
`deploy.bao.metricsAuthCommonName`. Evaluation refuses the config until you set
|
||||
both. Grafana's responder
|
||||
(`swarm-metrics-auth`, the second container) reads the stored bearer at most
|
||||
once a minute, so a replaced bearer starts working up to a minute later. When
|
||||
the store doesn't answer within five seconds, it checks requests against the
|
||||
last value it read instead of denying, and still refuses a wrong bearer;
|
||||
it tries the store again after three seconds. A revoked or rotated bearer
|
||||
stays accepted while the store is down, for an hour after the last read at
|
||||
most; after that the responder denies again. The store's next answer
|
||||
replaces the value, and a process that holds none (it started while the
|
||||
store was down) denies. `swarm-logs-grafana-auth`
|
||||
is the same binary and does the same.
|
||||
store was down) denies.
|
||||
|
||||
`swarm-metrics-agent-auth` is the log store's `swarm-logs-auth` binary, with
|
||||
the same grant TTL and rate limit, under `deploy.victoriametrics.agentAuth*`
|
||||
(table above).
|
||||
The agents' responder is the log store's `swarm-logs-auth` binary on the
|
||||
metrics surface, with the same grant TTL and rate limit, under
|
||||
`deploy.victoriametrics.agentAuth*` (table above).
|
||||
|
||||
The store's container has no network, so its journal forwarder leaves through
|
||||
a relay. Inside the container, `swarm-victoriametrics-egress-relay` listens on
|
||||
loopback and passes each connection to a socket the host's nginx listens on,
|
||||
`/run/swarm-victoriametrics-egress/egress.sock`. nginx sends the forwarder's
|
||||
route to the swarm collector and its token request to authelia, both by name
|
||||
and verified, and refuses every other path. On the host,
|
||||
`swarm-victoriametrics-forwarder-oidc.service` fetches the forwarder's OIDC
|
||||
secret under the same leaf as `swarm-metrics-auth`, and the container sees it
|
||||
read-only through a bind mount.
|
||||
The store's pod writes its output to the pod log, which the host collector reads
|
||||
from the node like any pod's ([logs](../k8s/telemetry.md#logs)).
|
||||
|
||||
The collector scrapes Grafana's own metrics at
|
||||
`https://<swarm.grafana.domain>/metrics`, so a collector on a host without
|
||||
|
|
@ -291,16 +287,16 @@ gateway either way.
|
|||
|
||||
The `swarm-bao`, `swarm-nats`, `swarm-builder`, `swarm-claude-login`,
|
||||
`swarm-notify-router`, `swarm-review-classifier`, `swarm-ci-runner`, `swarm-grafana`,
|
||||
`swarm-victoriametrics`, `swarm-authelia`, `swarm-attic`, `hive-forge`
|
||||
`swarm-authelia`, `swarm-attic`, `hive-forge`
|
||||
and `hive-matrix` containers each run a collector of their own that forwards the container's
|
||||
journal here, on a route and receiver per service
|
||||
(`https://<swarm.otel.domain>/<container>/`), authenticated as an OIDC client
|
||||
of that service's. The queue, builder, login minter, notification router and
|
||||
classifier reuse the service's own client; the store, CI runner, Grafana, metrics store,
|
||||
classifier reuse the service's own client; the store, CI runner, Grafana,
|
||||
authelia, cache, forge and homeserver have a forwarder client of their own
|
||||
(`swarm.<service>.otel.clientId`). Their records carry `service.name` (`bao`,
|
||||
`nats`, `builder`, `claude-login`, `notify-router`, `review-classifier`, `ci-runner`,
|
||||
`grafana`, `victoriametrics`, `authelia`, `attic`, `forgejo`,
|
||||
`grafana`, `authelia`, `attic`, `forgejo`,
|
||||
`tuwunel`) and the `sender` of its own client id. The forwarder of all but the store's is
|
||||
`nix/container-modules/swarm-journal-forwarder.nix`.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue