Watch
0
0
Fork
You've already forked hyperhive
0

run grafana as a pod in the cluster

The Deployment swarm-grafana replaces the swarm-grafana container: one
replica on a static local volume that is the container's data directory,
an init container that fetches the OIDC client secret and creates the
administrator password, the datasources' bearer and the encryption key in
the secret store, and a sidecar that keeps the controller's Viewer token.
The datasources reach the stores through the gateway with that bearer, and
Grafana's /metrics asks for the stores' kind of credential, which the vhost
sends. The five host units, the journal forwarder, its client glue and the
unix-socket directory go with the container.
This commit is contained in:
atlas 2026-11-27 22:51:25 +01:00
commit 9f62e71dae

View file

@ -10,15 +10,13 @@ how to open each service, is on
The swarm's telemetry lands in one VictoriaMetrics, and one Grafana
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.
database with it: both run as pods in the host's cluster
([the metrics store](../k8s/runtime.md#the-metrics-store),
[the Grafana pod](../k8s/runtime.md#the-grafana-pod)).
The Grafana container sits on the hive bridge in a network namespace of its
own and dials authelia, the secret store, the collector and both datasources
by name through it. It binds no TCP port: it listens on the unix socket
`/run/swarm-grafana/grafana.sock`, a directory only the gateway's nginx and
the container can open.
Grafana's pod dials authelia, the secret store and both datasources by name
through the gateway, and listens on port 3000 for the host's own traffic only:
the vhost on the host's nginx is the one way in.
They derive together: a store with no UI is unreadable and a UI with no
store is empty. To run one without the other, set it directly:
@ -103,16 +101,15 @@ 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 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 asks every request for
Neither is reachable except through the gateway: both sit behind Services
that admit only the host's own traffic. VictoriaMetrics asks every request for
a credential of its own, which the gateway's nginx supplies once the
`metrics.<swarm-domain>` vhost has checked the caller:
- **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 Grafana's responder (the second container of the responders' pod)
bearer that the init container of Grafana's pod creates in the swarm
secret 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 the agents' responder (the first
@ -155,8 +152,11 @@ 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
Grafana still gets them. The gateway admits only the collector's client to
that path; any other session gets `deny`.
Grafana still gets them. Grafana asks that route for a credential of its own
(`[metrics] basic_auth_username` and `basic_auth_password`), which the
gateway's nginx supplies once authelia has checked the caller; the gateway
admits only the collector's client to that path, and any other session gets
`deny`. A request that reaches the pod without the credential gets 401.
The collector scrapes the store's own metrics the same way, at
`https://<swarm.victoriametrics.domain>/metrics`, so a collector on a host
@ -198,7 +198,7 @@ collector is the only intended writer.
agent presents its `swarm-agent.<agent>.<secret>` bearer, checked by
`swarm-logs-auth`. The agent must also hold the `logs` permission,
which is off by default; without it the answer is a 403 (`docs/5-project/process/conventions.md`, Permissions). Grafana's datasource presents the same bearer as its
metrics datasource, which `swarm-bao-grafana-metrics-bearer` creates, and a
metrics datasource, which the init container of Grafana's pod creates, and a
second `swarm-metrics-auth` instance (`swarm-logs-grafana-auth`, in the same pod as
`swarm-logs-auth`) checks it against the same store path; the gateway tells it from
the others by its shape, 64 hex digits. Anything else needs an operator's
@ -288,17 +288,17 @@ gateway either way.
| `swarm.otel.domain` | Only to rename it — the default already resolves correctly for every hive in the swarm. |
The `swarm-bao`, `swarm-nats`, `swarm-builder`, `swarm-claude-login`,
`swarm-notify-router`, `swarm-review-classifier`, `swarm-ci-runner`, `swarm-grafana`,
`swarm-notify-router`, `swarm-review-classifier`, `swarm-ci-runner`,
`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,
classifier reuse the service's own client; the store, CI runner,
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`, `authelia`, `attic`, `forgejo`,
`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`.