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:
parent
26ef09b0d7
commit
9f62e71dae
34 changed files with 1938 additions and 1953 deletions
|
|
@ -135,7 +135,11 @@ container, its sockets, secrets and metrics:
|
|||
|
||||
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 losing the time-series database.
|
||||
can restart or break Grafana without losing the time-series database. Both
|
||||
run as pods in the host's cluster, and Grafana keeps its database on the host's
|
||||
disk. Grafana reads its secrets when its pod starts: after you replace its OIDC
|
||||
client secret, restart it with
|
||||
`kubectl -n hyperhive rollout restart deployment/swarm-grafana`.
|
||||
`deploy.victoriametrics.enable` turns [the cluster node](../../4-implementation/k8s/node.md)
|
||||
on with it. Enabling either enables both; to run one alone, set it directly with
|
||||
`deploy.victoriametrics.enable` or `deploy.grafana.enable`.
|
||||
|
|
|
|||
|
|
@ -164,14 +164,16 @@ gateway refuses its token too. See [`swarmctl/README.md`](../../../swarmctl/READ
|
|||
one minted into the swarm secret store, not the upstream `admin`. A
|
||||
dead provider locks out the SSO accounts but not that one: an operator
|
||||
reads the password from `swarm/services/<grafana client id>/admin/password`
|
||||
in the store (or, as root on the Grafana host, from
|
||||
`/run/swarm-grafana-secrets/admin-password`)
|
||||
and calls the API with it. See [`services.md`](services.md#metrics-victoriametrics--grafana)
|
||||
in the store and calls the API with it. See [`services.md`](services.md#metrics-victoriametrics--grafana)
|
||||
and [`credentials.md`](credentials.md). SSO logins are the everyday way in, which
|
||||
is why `swarm.grafana.oidc.role` defaults to `Admin`.
|
||||
The three secrets Grafana reads live on the host's tmpfs, so after a reboot
|
||||
Grafana stays down (no login, no dashboards) until the secret store
|
||||
answers; the delivery units retry and start it with no manual step.
|
||||
Grafana runs as a pod in the host's cluster and reads its secrets from the
|
||||
secret store when the pod starts, so after a reboot Grafana stays down (no
|
||||
login, no dashboards) until the secret store answers; the pod retries and
|
||||
starts with no manual step. It reads them once: after you replace its OIDC
|
||||
client secret, the administrator password or the datasources' bearer in the
|
||||
store, restart it with
|
||||
`kubectl -n hyperhive rollout restart deployment/swarm-grafana`.
|
||||
- **It doesn't provision users.** `swarmctl` creates and destroys agents
|
||||
continuously today, so the subject set belongs to a program rather
|
||||
than to a config file.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ A service gets manifests on the host whose configuration deploys it:
|
|||
| `swarm-logs-auth` | Deployment | ServiceAccount, two Services, NetworkPolicy |
|
||||
| `swarm-victoriametrics` | Deployment | Service, NetworkPolicy, PersistentVolume and Claim |
|
||||
| `swarm-metrics-auth` | Deployment | ServiceAccount, two Services, NetworkPolicy |
|
||||
| `swarm-grafana` | Deployment | ServiceAccount, Service, NetworkPolicy, PersistentVolume and Claim |
|
||||
|
||||
`namespace.yaml` holds the Namespace ([Pod Security](#pod-security)), and
|
||||
`default-deny-ingress/networkpolicy.yaml` its default-deny ingress policy
|
||||
|
|
@ -150,15 +151,17 @@ credential directory.
|
|||
in the container, with a 5-second timeout, and a 503 fails it. The pod
|
||||
declares no port for the listener. `swarm-controller` is one of
|
||||
them, with `SWARM_CONTROLLER_HEALTH_ADDR`. A third-party daemon with no health variable,
|
||||
`victoria-logs` and `victoria-metrics`, names a `probe` path instead (`/health`), which both probes
|
||||
request on its listener. A `startupFailureThreshold` in it (`victoria-metrics`, 60) adds a
|
||||
`victoria-logs`, `victoria-metrics` and `grafana`, names a `probe` path instead (`/health`; `/api/health` for `grafana`), which both probes
|
||||
request on its listener. A `startupFailureThreshold` in it (`victoria-metrics`, 60, and `grafana`, 30) adds a
|
||||
startup probe on the same path, tried every ten seconds, before the other two begin.
|
||||
The health listener of our own daemons is unreachable from outside the pod: the
|
||||
node, other pods and the bridge get a refusal, so it needs no credential.
|
||||
The one health route outside the pod is the `/health` of `victoria-logs` and
|
||||
`victoria-metrics` on their main port. Upstream answers `/health`, `/ping`,
|
||||
`/-/healthy` and `/-/ready` before it checks `-httpAuth`, and the gateway needs
|
||||
the main port on the pod's IP, so no bind or probe can close it. It's
|
||||
The health routes outside the pod are the `/health` of `victoria-logs` and
|
||||
`victoria-metrics` on their main port, and the `/api/health` and `/healthz` of
|
||||
Grafana on its own. Upstream answers `/health`, `/ping`, `/-/healthy` and
|
||||
`/-/ready` before it checks `-httpAuth`, Grafana answers its two before its
|
||||
login, and the gateway needs the main port on the pod's IP, so no bind or
|
||||
probe can close them. It's
|
||||
reachable from the node only, through the default-deny ingress policy, and it
|
||||
returns a status and no data.
|
||||
- **Listener and init container:** a service with a TCP `listener`
|
||||
|
|
@ -167,7 +170,7 @@ credential directory.
|
|||
gets an init container and a renewal container that issue its leaf into an
|
||||
`emptyDir` ([runtime](runtime.md#the-controller)). The image of those
|
||||
containers is part of `system.build.k8sImages`. A listener with no `tlsDir`
|
||||
(`swarm-victorialogs`, `swarm-logs-auth`, `swarm-victoriametrics`, `swarm-metrics-auth`) serves plain HTTP: it gets the
|
||||
(`swarm-victorialogs`, `swarm-logs-auth`, `swarm-victoriametrics`, `swarm-metrics-auth`, `swarm-grafana`) serves plain HTTP: it gets the
|
||||
Service and the policy and no leaf, init container or renewal container.
|
||||
- **More than the daemon:** a service whose pod holds more than its daemon
|
||||
(the queue, whose server and exporter run beside the responder) names a
|
||||
|
|
@ -179,9 +182,11 @@ credential directory.
|
|||
holds two store roles has both bound to it
|
||||
([runtime](runtime.md#the-queue)). The responders' pods of the log and metrics
|
||||
stores hold a second container the same way
|
||||
([runtime](runtime.md#the-log-store), [runtime](runtime.md#the-metrics-store)).
|
||||
([runtime](runtime.md#the-log-store), [runtime](runtime.md#the-metrics-store)),
|
||||
and Grafana's pod holds an init container and a sidecar
|
||||
([runtime](runtime.md#the-grafana-pod)).
|
||||
- **A unit of the module's own making:** a service that never ran under systemd on the
|
||||
host (`swarm-victorialogs`, `swarm-logs-auth`, `swarm-victoriametrics`, `swarm-metrics-auth`) gives the renderer the
|
||||
host (`swarm-victorialogs`, `swarm-logs-auth`, `swarm-victoriametrics`, `swarm-metrics-auth`, `swarm-grafana`) gives the renderer the
|
||||
`serviceConfig`, `environment` and `path` of one as a plain attribute set, with
|
||||
the daemon's flags as a list in `ExecStart`. The renderer reads nothing else of
|
||||
a unit. `fsGroupChangePolicy` in the entry sets the pod's field of that name.
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ says so with a label. The module sets the labels
|
|||
(`services.hyperhive.deploy.k8s.nodeLabels`, passed to `services.k3s.nodeLabel`):
|
||||
|
||||
- `hyperhive.darkest.space/state-<service>=true`, one per service whose data
|
||||
the cluster keeps. Today that's `nats`, `ci-metrics`, `victorialogs` and `victoriametrics`, each when its
|
||||
the cluster keeps. Today that's `nats`, `ci-metrics`, `victorialogs`, `victoriametrics` and `grafana`, each when its
|
||||
`deploy.<service>.enable` is on. The
|
||||
service's static local volume has a `nodeAffinity` on the label, and its pod a
|
||||
`nodeSelector` on it, so a node without the label can't run the pod and shows
|
||||
|
|
|
|||
|
|
@ -124,6 +124,10 @@ starts on an empty cache on every start of the pod; an upgrade from the
|
|||
container doesn't carry the old cache over. The whisper model isn't state: the
|
||||
pod's image holds it.
|
||||
|
||||
`swarm-grafana` keeps its database in the claim
|
||||
`swarm-grafana-store`, a static local volume on the directory its container kept
|
||||
([the Grafana pod](#the-grafana-pod)).
|
||||
|
||||
`swarm-ci-metrics` keeps a cursor, `cursor.json`, which holds the run numbers
|
||||
already pushed. It sits in the PersistentVolumeClaim `swarm-ci-metrics-store`, mounted at
|
||||
`/var/lib/private/swarm-ci-metrics`, which binds a static local volume on that
|
||||
|
|
@ -525,6 +529,72 @@ pushes to the store and Grafana that reads it.
|
|||
`agentAuthVerdictTtl` and the store identity files). The host collector reads
|
||||
the pods' output from the node like any pod's.
|
||||
|
||||
## The Grafana pod
|
||||
|
||||
`swarm-grafana` is the swarm's Grafana: one Deployment with one replica and the
|
||||
`Recreate` strategy. The vhost `grafana.<swarm domain>` stays on the host and
|
||||
dials the pod's ClusterIP Service by name, as the stores' vhosts do, so
|
||||
`gateway.dns.enable` has to be on.
|
||||
|
||||
- **The pod.** The module defines Grafana's `ExecStart`, and the image holds the
|
||||
nixpkgs Grafana with the plugins `deploy.grafana.plugins` names, its
|
||||
configuration file and its provisioning directory (datasources, dashboards and
|
||||
alert rules), all read-only. A start script applies the stored administrator
|
||||
password to the database with `grafana cli admin reset-admin-password`, because
|
||||
the `admin_password` setting gives its password to a new database only,
|
||||
and then runs `grafana server`. Grafana serves plain HTTP on port 3000,
|
||||
pushes no telemetry and logs in to nothing itself: its output is the pod's log,
|
||||
which the host collector reads like any pod's ([logs](telemetry.md#logs)). The
|
||||
startup probe requests `/api/health` every ten seconds for up to five minutes,
|
||||
which covers a database migration after an upgrade.
|
||||
- **The init container.** `fetch-secrets` logs in to the secret store with the
|
||||
pod's ServiceAccount token under the jwt role `swarm-grafana-oidc`, and writes
|
||||
four files, mode 0400, to the pod's in-memory `runtime` volume: the OIDC client
|
||||
secret, the administrator password, the bearer of the datasources and the
|
||||
datasource encryption key. It reads the client secret from
|
||||
`swarm/services/<client id>/oidc/client`, which authelia's mint stores, and
|
||||
exits non-zero when the store holds none, so the pod waits in `Init` and retries
|
||||
until the mint has written it. The other three it creates when the store holds
|
||||
none (a lost race reads the winner's value) and never replaces.
|
||||
- **Rotation.** Grafana reads the four files once, when it starts. A replaced
|
||||
OIDC client secret, administrator password or bearer takes effect when the pod
|
||||
restarts: `kubectl -n hyperhive rollout restart deployment/swarm-grafana`. No
|
||||
`swarmctl` verb restarts it. The bearer is also read by the responders of both
|
||||
stores, which pick up a replaced value within a minute.
|
||||
- **The sidecar.** `controller-token` keeps `swarm-controller`'s Viewer service
|
||||
account in Grafana and its token at
|
||||
`swarm/controller/swarm-controller/grafana/token`. Every five minutes it calls
|
||||
Grafana's API with the token it stored, and creates the account and a new
|
||||
token when Grafana refuses it, as Grafana does after its database is
|
||||
recreated. It reaches Grafana on the pod's loopback with the administrator
|
||||
password.
|
||||
- **The datasources.** Grafana dials `metrics.<swarm domain>` and
|
||||
`logs.<swarm domain>` by name through the gateway and sends its bearer, which
|
||||
the responders of those stores check. The pod holds no store's listener
|
||||
credential: the only credential Secret it mounts is its own,
|
||||
`swarm-grafana-credentials`. The cluster's DNS answers those names with the
|
||||
bridge address, and the pod's policy allows port 443 of the host.
|
||||
- **Who may use it.** The UI and the API need an OIDC session or the
|
||||
administrator's basic auth, and the login form is off. `/api/health` is open
|
||||
by Grafana's design. `/metrics` takes a credential of its own, set with
|
||||
`[metrics] basic_auth_username` and `basic_auth_password` (the user
|
||||
`swarm-store`, the password from the Secret `swarm-grafana-credentials`, which the unit of
|
||||
[the stores' listener credential](#the-stores-listener-credential) creates at
|
||||
`swarm/services/grafana/store-auth`). The vhost sends it after
|
||||
authelia has checked the caller, so a request that reaches the pod without it
|
||||
gets 401.
|
||||
- **State.** Grafana's data directory on the host is
|
||||
`/var/lib/nixos-containers/swarm-grafana/var/lib/grafana`: the claim
|
||||
`swarm-grafana-store` binds a static local volume on it, so the database the
|
||||
container kept is the pod's, with its dashboards, annotations and users. The
|
||||
node label is `hyperhive.darkest.space/state-grafana`
|
||||
([node labels](node.md#node-labels)), and the pod's `fsGroup` is `65532` with
|
||||
the `OnRootMismatch` policy, as for the stores.
|
||||
- **Who reaches what.** The namespace's `default-deny-ingress` and the pod's own
|
||||
policy admit the node alone, which is the host's nginx and the kubelet's
|
||||
probes. The pod reaches cluster DNS, the secret store's pod listener and port
|
||||
443 of the host.
|
||||
|
||||
## The stores' listener credential
|
||||
|
||||
Each store listens on its pod's address behind a ClusterIP Service, and the
|
||||
|
|
@ -544,6 +614,10 @@ every route but `/health` and the few built-in ones that answer a fixed text,
|
|||
the import, delete and admin routes of the metrics store included. Root can
|
||||
read the credentials, so treat the host as trusted for what root can do.
|
||||
|
||||
Grafana's `/metrics` route has a credential of the same kind, created by the same unit at
|
||||
`swarm/services/grafana/store-auth` and sent by the vhost from
|
||||
`/var/lib/swarm-store-auth/grafana.conf`: [the Grafana pod](#the-grafana-pod).
|
||||
|
||||
## Resources and sandbox
|
||||
|
||||
The pod takes the unit's `MemoryMax` and `CPUQuota` as its container's limits
|
||||
|
|
|
|||
|
|
@ -124,15 +124,14 @@ symptom many layers from its cause.
|
|||
|
||||
The store's **first reader** is Grafana's OIDC client secret, a _swarm
|
||||
service's_ own credential rather than a hive's. It has exactly
|
||||
one delivery route: `swarm-bao-grafana-oidc.service` reads
|
||||
`swarm/services/<client-id>/oidc/client` out of the store, on **every** host
|
||||
that runs Grafana. Where authelia is doesn't enter into it — the mint in
|
||||
one delivery route: the init container `fetch-secrets` of Grafana's pod reads
|
||||
`swarm/services/<client-id>/oidc/client` out of the store with the pod's
|
||||
ServiceAccount token, on the host that runs the pod. Where authelia is doesn't enter into it — the mint in
|
||||
authelia's container writes that path whether the reader is a network away or
|
||||
in the container next door. On a fresh swarm the mint writes it a moment after
|
||||
the reader's first attempt, so a read that finds no value yet fails and the
|
||||
unit asks again every 30 seconds until the value is there, as the forge's and
|
||||
the homeserver's do. A unit that finished there would wait for its refresh
|
||||
timer, about ten minutes on.
|
||||
the reader's first attempt, so a read that finds no value yet fails the
|
||||
container and the kubelet starts it again, with a growing delay, until the
|
||||
value is there. The forge's and the homeserver's units retry the same way.
|
||||
|
||||
That's a deliberate refusal of the shortcut. Copying the plaintext
|
||||
straight out of authelia's tree when the two happen to share a host is one
|
||||
|
|
@ -163,12 +162,13 @@ the option pair, when that leaf is unset — neither the responder nor the
|
|||
homeserver starts without its secret, and the forge registers no login source
|
||||
without its.
|
||||
|
||||
Grafana's admin password rides the same leaf and the same store. Where Grafana
|
||||
and the store run on different hosts, deploy the store's host first:
|
||||
`swarm-bao-grafana-oidc-policy` there writes the grant that lets Grafana create
|
||||
the password, and until it has, the store refuses `swarm-bao-grafana-admin` on
|
||||
the Grafana host, which retries, while Grafana stays down because its config
|
||||
reads that file.
|
||||
Grafana's admin password, datasource bearer and encryption key ride the same role
|
||||
and the same store. Where Grafana and the store run on different hosts, deploy the store's
|
||||
host first: `swarm-bao-grafana-oidc-policy` there writes the grant that lets Grafana create
|
||||
them, and until it has, the store refuses `fetch-secrets`, which fails and retries while
|
||||
Grafana stays down because its config reads those files. The pod reads them once, when it
|
||||
starts: a replaced value takes effect after
|
||||
`kubectl -n hyperhive rollout restart deployment/swarm-grafana`.
|
||||
|
||||
The **second reader** is the swarm collector's own OIDC client secret, the
|
||||
same shape one level down: `swarm-bao-otel-oidc.service` reads
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ the rest of the cell says how.
|
|||
| `swarm/controller/swarm-controller/matrix/appservice-registration` | `swarm-matrix-ctl appservice render` in `hive-matrix`, when the store answers and holds none; before that, the tokens an earlier version kept in the container, stored unchanged | `swarm-matrix-ctl` in `hive-matrix`; the controller has no grant to it | ❌ minted once; an operator who replaces it makes `sync` render the new pair and restart the homeserver | ✅ `sync` re-reads it every 10 minutes |
|
||||
| `swarm/controller/swarm-controller/oidc/client` | authelia, first boot | `swarm-controller` | ❌ minted once, straight into the store; minted again only when the store holds none | ✅ re-read when authelia refuses it |
|
||||
| `swarm/controller/swarm-controller/forge/token` | the forge, once | `swarm-controller` | ❌ minted once; delete `/var/lib/forgejo/swarm-controller-token-name` in the forge container to mint a new one | ✅ re-read on a 401 |
|
||||
| `swarm/controller/swarm-controller/grafana/token` | `swarm-bao-grafana-controller-token` on Grafana's host | `swarm-controller` | ✅ every 10 minutes, when Grafana refuses it or none is stored | ✅ re-read on a 401 |
|
||||
| `swarm/controller/swarm-controller/grafana/token` | the `controller-token` sidecar of Grafana's pod, under the pod's login | `swarm-controller` | ✅ every 5 minutes, when Grafana refuses it or none is stored | ✅ re-read on a 401 |
|
||||
| `swarm/controller/swarm-controller/forge/webhook-secret` | `swarm-controller`, at start, from its old `webhook-secret` file; a new one only when there is no file | `swarm-controller` | ❌ minted once; a rotated secret fails every delivery until the forge hooks are re-registered | ❌ read once; a store down at start is re-read in the background until it answers |
|
||||
| `swarm/agents/<agent>/bao-mtls` | the store's agent PKI mount (`deploy.bao.agentPkiMountPath`), at agent creation, and by the renewal pass when none is stored or its cert-auth role is missing | `hive-c0re`, then the agent | ✅ re-issued every 5 minutes once past half its 7-day validity; minted when none is stored or its cert-auth role is missing, for agents not `Destroyed` | ✅ the agent re-reads every 10 minutes; it renews only while its current leaf is valid |
|
||||
| `swarm/agents/<agent>/queue` | `swarm-controller`, at agent creation | the agent; the queue, log and metrics auth services | ✅ re-minted at 45 days; skipped for `Destroyed` agents, whose path is deleted | ✅ read on every reconnect; an open connection keeps the old secret for up to an hour; the log and metrics stores honour a replaced secret for up to `deploy.victorialogs.authVerdictTtl` and `deploy.victoriametrics.agentAuthVerdictTtl` (60 s by default) |
|
||||
|
|
@ -44,12 +44,13 @@ the rest of the cell says how.
|
|||
| `swarm/services/k8s/agent-token` | `k3s-join-token-publish`, on the cluster's main node, as that node's hive: k3s's `agent-token`, written again whenever the file differs | a node that joins: `k3s-join-token`, as that node's hive, before k3s starts | ✅ at each start of the main node's k3s | ✅ at each start of the joining node's k3s |
|
||||
| `swarm/services/victorialogs/store-auth` | `swarm-bao-store-auth`, on the log store's host, as the `swarm-store-auth` principal: 32 random bytes as 64 hex digits, written only while the path holds nothing | the same unit, which hands it to the host's nginx and to the cluster; the log store's pod loads it as its `-httpAuth.password` | ❌ never replaced: to rotate, delete the leaf's metadata with a token that may and restart `swarm-bao-store-auth` | ✅ the unit reads it at each start and writes the nginx file and the Secret again when they differ; the store re-reads its file every two seconds |
|
||||
| `swarm/services/victoriametrics/store-auth` | `swarm-bao-store-auth`, on the metrics store's host, as the `swarm-store-auth` principal: 32 random bytes as 64 hex digits, written only while the path holds nothing | the same unit, which hands it to the host's nginx and to the cluster; the metrics store's pod loads it as its `-httpAuth.password` | ❌ never replaced: to rotate, delete the leaf's metadata with a token that may and restart `swarm-bao-store-auth` | ✅ the unit reads it at each start and writes the nginx file and the Secret again when they differ; the store re-reads its file every two seconds |
|
||||
| `swarm/services/grafana/store-auth` | `swarm-bao-store-auth`, on Grafana's host, as the `swarm-store-auth` principal: 32 random bytes as 64 hex digits, written only while the path holds nothing | the same unit, which hands it to the host's nginx and to the cluster; Grafana's pod loads it as its `[metrics] basic_auth_password` | ❌ never replaced: to rotate, delete the leaf's metadata with a token that may, restart `swarm-bao-store-auth`, then restart Grafana's pod | ✅ the unit reads it at each start and writes the nginx file and the Secret again when they differ; ❌ Grafana reads it at start |
|
||||
| `swarm/services/nats/exporter-auth` | `swarm-bao-store-auth`, on the queue's host, as the `swarm-store-auth` principal: 32 random bytes as 64 hex digits, written only while the path holds nothing | the same unit, which hands the password to the host's nginx and its bcrypt hash to the cluster; the queue's exporter takes the hash as its `-http_pass` | ❌ never replaced: to rotate, delete the leaf's metadata with a token that may, restart `swarm-bao-store-auth`, then restart the queue's pod, which reads the hash only as it starts | ✅ the unit reads it at each start and writes the nginx file, the hash and the Secret again when they differ; a hash is made again only when the password changed |
|
||||
| `swarm/hives/<hive>/oidc/client` | authelia, first boot, straight into the store | the hive | ❌ minted once, straight into the store; minted again only when the store holds none | ✅ re-read when authelia refuses it |
|
||||
| `swarm/services/<clientId>/oidc/client` | authelia | that service | must be stated | must be stated |
|
||||
| `swarm/services/ci-runner/registration-token` | `swarm-controller`, from the forge, at start and every 5 minutes | `swarm-bao-ci-runner` on the runner's host | ❌ the forge keeps one token until an admin resets it; the controller then writes the new one within 5 minutes | ✅ every 10 minutes; restarts the runner on a change |
|
||||
| `swarm/services/<grafana client id>/metrics/bearer` | `swarm-bao-grafana-metrics-bearer` on Grafana's host, when none is stored | `swarm-metrics-auth` and `swarm-logs-grafana-auth` | ❌ delete it and restart `swarm-bao-grafana-metrics-bearer` | ✅ the auth services re-read within a minute, and while they can't reach the store they keep accepting the value they last read, for an hour at most; ❌ Grafana restarts when its copy changes |
|
||||
| `swarm/services/<grafana client id>/secret-key` | `swarm-bao-grafana-secret-key` on Grafana's host, from the key an earlier release generated; a new one only when there is none | Grafana | ❌ minted once; a different key leaves Grafana unable to read its stored datasource secrets | ❌ Grafana reads it at start; the unit restarts Grafana when the file changes |
|
||||
| `swarm/services/<grafana client id>/metrics/bearer` | the init container of Grafana's pod, when none is stored | `swarm-metrics-auth` and `swarm-logs-grafana-auth` | ❌ delete it and restart Grafana's pod | ✅ the auth services re-read within a minute, and while they can't reach the store they keep accepting the value they last read, for an hour at most; ❌ Grafana reads it at start, so restart its pod when it changes |
|
||||
| `swarm/services/<grafana client id>/secret-key` | the init container of Grafana's pod, when none is stored: the key file the earlier container generated, else a new key, and a new key never over a database that holds data keys | Grafana | ❌ stored once; a different key leaves Grafana unable to read what the first one encrypted | ❌ Grafana reads it at start |
|
||||
| `swarm/services/swarm-authelia/keys/<name>`, for `jwt`, `session`, `storage-encryption`, `oidc-hmac` and `oidc-issuer` | authelia's `authelia-swarm-secrets` unit in its container, under the secret publisher's identity, from the key file an earlier release generated; a new one only when there is none | authelia | ❌ minted once; a different storage-encryption key leaves authelia's database unreadable and a different issuer key invalidates every issued token | ❌ read when the unit runs; the unit restarts authelia when the file changes |
|
||||
| `swarm/services/review-classifier/anthropic-api-key` | you, in the store's UI, field `api_key` | `swarm-review-classifier` | ❌ write a new key | ✅ read on every run |
|
||||
| `swarm/services/review-classifier/acp-provider` | you, in the store's UI, field `api_key` | `swarm-review-classifier` | ❌ write a new key | ✅ read on every run |
|
||||
|
|
@ -132,11 +133,12 @@ pieces fit, and the reasoning behind them, is in [`credentials.md`](../../2-hand
|
|||
| the swarm collector's copy of its OIDC secret | `swarm-bao-otel-oidc.service` reads it out of the swarm secret store, **on every host that runs the collector and holds a store identity** | `/run/swarm-otel-oidc/<id>.secret` on the host's tmpfs, bind-mounted read-only into the `swarm-otel` container — never on persistent disk, so a reboot fetches it again | same unit, same path — one route, co-located or not. A collector with no store identity has `clientSecretFile == null`, its already-supported unauthenticated-push degrade — see [swarm-level secrets](../../2-handbook/swarm/credentials.md#swarm-level-secrets) |
|
||||
| the log store's listener credential | `swarm-bao-store-auth.service` creates it in the swarm secret store at `swarm/services/victorialogs/store-auth` when the store holds none, then copies it out, **on the host that runs the log store**. The grant is create and read, without update | `/var/lib/swarm-store-auth/victorialogs.conf` (root and the nginx group, `0640`, in a directory of `0750`): the `Authorization` header the vhost's store locations send, and `/var/lib/swarm-store-auth/victorialogs.password` (root only, `0600`), from which the unit publishes the Secret `swarm-victorialogs-credentials`, key `store-auth`, which the store's pod mounts | nothing to copy: the vhost and the store are on one host. If the nginx file and the Secret hold different values, every request through the gateway answers 401 until the unit runs again; it writes the nginx file first and the Secret after |
|
||||
| the metrics store's listener credential | `swarm-bao-store-auth.service` creates it in the swarm secret store at `swarm/services/victoriametrics/store-auth` when the store holds none, then copies it out, **on the host that runs the metrics store**. The grant is create and read, without update | `/var/lib/swarm-store-auth/victoriametrics.conf` (root and the nginx group, `0640`, in a directory of `0750`): the `Authorization` header the vhost's store locations send, and `/var/lib/swarm-store-auth/victoriametrics.password` (root only, `0600`), from which the unit publishes the Secret `swarm-victoriametrics-credentials`, key `store-auth`, which the store's pod mounts | nothing to copy: the vhost and the store are on one host. If the nginx file and the Secret hold different values, every request through the gateway answers 401 until the unit runs again; it writes the nginx file first and the Secret after |
|
||||
| Grafana's listener credential | `swarm-bao-store-auth.service` creates it in the swarm secret store at `swarm/services/grafana/store-auth` when the store holds none, then copies it out, **on the host that runs Grafana**. The grant is create and read, without update | `/var/lib/swarm-store-auth/grafana.conf` (root and the nginx group, `0640`, in a directory of `0750`): the `Authorization` header the vhost's `/metrics` location sends, and `/var/lib/swarm-store-auth/grafana.password` (root only, `0600`), from which the unit publishes the Secret `swarm-grafana-credentials`, key `store-auth`, which Grafana's pod mounts | nothing to copy: the vhost and Grafana are on one host. If the nginx file and the Secret hold different values, `/metrics` through the gateway answers 401 until the unit runs again; it writes the nginx file first and the Secret after |
|
||||
| the queue exporter's listener credential | `swarm-bao-store-auth.service` creates it in the swarm secret store at `swarm/services/nats/exporter-auth` when the store holds none, then copies it out, **on the host that runs the queue**. The grant is create and read, without update | `/var/lib/swarm-store-auth/nats.conf` (root and the nginx group, `0640`, in a directory of `0750`): the `Authorization` header the gateway's `/metrics` location for the queue sends; `/var/lib/swarm-store-auth/nats.password` (the password, root only) and `/var/lib/swarm-store-auth/nats.hash` (its bcrypt hash, from which the unit publishes the Secret `swarm-nats-exporter-auth`, key `hash`, which the exporter container reads as `EXPORTER_HASH`). The password reaches nothing but the host: the Secret and the pod's command line hold the hash | nothing to copy: the vhost and the pod are on one host. An nginx file that doesn't match the hash makes the gateway's scrape answer 401 until the unit runs again; the exporter reads the hash as it starts, so a rotated password also needs a restart of the queue's pod |
|
||||
| Grafana's copy of its OIDC secret | `swarm-bao-grafana-oidc.service` reads it out of the swarm secret store, **on every host that runs Grafana** | `/run/swarm-grafana-secrets/<id>.secret` on the host's tmpfs, bind-mounted read-only into the `swarm-grafana` container — never on persistent disk, so a reboot fetches it again | same unit, same path — one route, co-located or not. Nothing for an operator to place beyond this host's store leaf, see [hive-level secrets](../../2-handbook/swarm/credentials.md#hive-level-secrets) |
|
||||
| Grafana's admin password | `swarm-bao-grafana-admin.service` creates it in the swarm secret store at `swarm/services/<grafana client id>/admin/password` when the store holds none, then copies it out, **on every host that runs Grafana**. Grafana's leaf may create that leaf but not update it, so the store keeps the first value, and the secret publisher can't write it. To rotate, run `bao kv metadata delete secret/swarm/services/<grafana client id>/admin/password` with a token that may, such as the root token (Grafana's, the publisher's and the controller's can't), then `systemctl restart swarm-bao-grafana-admin`; a plain `bao kv delete` isn't enough, see [the callout xkey's section](credentials.md#the-queues-callout-xkey) | `/run/swarm-grafana-secrets/admin-password` on the host's tmpfs, bind-mounted read-only into the `swarm-grafana` container, never on persistent disk: `security.admin_password` for a new database, and `grafana cli admin reset-admin-password` in `grafana.service`'s `preStart` for an existing one, on every start | same unit, same path. After a reboot the unit fetches the file again, and Grafana doesn't start until it exists, so it stays down rather than falling back to the upstream default `admin` |
|
||||
| Grafana's metrics bearer | `swarm-bao-grafana-metrics-bearer.service` creates it in the swarm secret store at `swarm/services/<grafana client id>/metrics/bearer` when the store holds none, then copies it out, **on every host that runs Grafana**. Same grant as the admin password, create without update. To rotate, run `bao kv metadata delete secret/swarm/services/<grafana client id>/metrics/bearer` with a token that may, then `systemctl restart swarm-bao-grafana-metrics-bearer` | `/run/swarm-grafana-secrets/metrics-bearer` on the host's tmpfs, bind-mounted read-only into the `swarm-grafana` container, holding `Bearer <value>`: the metrics datasource's `Authorization` header. The logs datasource sends the same header. `swarm-metrics-auth` on the metrics store's host, and a second instance on the log store's host (`swarm-logs-grafana-auth`), read the stored value themselves, each under its own leaf | same unit, same path. The unit restarts Grafana when the file changes |
|
||||
| Grafana's datasource encryption key | `swarm-bao-grafana-secret-key.service` stores it in the swarm secret store at `swarm/services/<grafana client id>/secret-key` when the store holds none, then copies it out, **on every host that runs Grafana**. It stores the key an earlier release generated at `/var/lib/grafana-secret/secret_key` in the container, so the key doesn't change, and mints a new one only on a host with no such file. Same grant as the admin password, create without update. The earlier file stays on disk, unused once the store holds the key. A store that's down or doesn't grant the leaf fails the unit, and Grafana doesn't start | `/run/swarm-grafana-secrets/secret-key` on the host's tmpfs, bind-mounted read-only into the `swarm-grafana` container: `security.secret_key` | same unit, same path. Grafana doesn't start until the file exists. Changing the key leaves Grafana unable to read the datasource secrets it stored, so never delete the store path to rotate it |
|
||||
| Grafana's copy of its OIDC secret | the init container `fetch-secrets` of Grafana's pod reads it out of the swarm secret store with the pod's ServiceAccount token | `/run/grafana-secrets/<id>.secret` in the pod's in-memory `runtime` volume, mode 0400, never on a disk; Grafana reads it with `$__file{}` | the same container, the same path, on every start. Nothing for an operator to place. A replaced secret takes effect when the pod restarts: `kubectl -n hyperhive rollout restart deployment/swarm-grafana` |
|
||||
| Grafana's admin password | the init container creates it in the swarm secret store at `swarm/services/<grafana client id>/admin/password` when the store holds none, then writes it out. The pod's role may create that leaf but not update it, so the store keeps the first value, and the secret publisher can't write it. To rotate, run `bao kv metadata delete secret/swarm/services/<grafana client id>/admin/password` with a token that may, such as the root token (the pod's, the publisher's and the controller's can't), then restart the pod; a plain `bao kv delete` isn't enough, see [the callout xkey's section](credentials.md#the-queues-callout-xkey) | `/run/grafana-secrets/admin-password` in the pod's in-memory `runtime` volume: `security.admin_password` for a new database, and `grafana cli admin reset-admin-password` before `grafana server` for an existing one, on every start | the same container, the same path. Grafana doesn't start until the file exists, so it stays down rather than falling back to the upstream default `admin` |
|
||||
| Grafana's metrics bearer | the init container creates it in the swarm secret store at `swarm/services/<grafana client id>/metrics/bearer` when the store holds none, then writes it out. Same grant as the admin password, create without update. To rotate, run `bao kv metadata delete secret/swarm/services/<grafana client id>/metrics/bearer` with a token that may, then restart the pod | `/run/grafana-secrets/metrics-bearer` in the pod's in-memory `runtime` volume, holding `Bearer <value>`: the metrics datasource's `Authorization` header. The logs datasource sends the same header. `swarm-metrics-auth` and `swarm-logs-grafana-auth`, in the stores' responders' pods, read the stored value themselves, each under its own ServiceAccount | the same container, the same path, on every start |
|
||||
| Grafana's datasource encryption key | the init container stores it in the swarm secret store at `swarm/services/<grafana client id>/secret-key` when the store holds none, then writes it out. The value it stores is the file the earlier container generated at `/var/lib/nixos-containers/swarm-grafana/var/lib/grafana-secret/secret_key` (read-only, through a claim on a static local volume) when there is one, else a new key; with no file, an empty leaf and a `grafana.db` that holds rows in `data_keys` it exits non-zero, names the leaf and stores nothing. Same grant as the admin password, create without update. A store that's down or doesn't grant the leaf fails the container, and Grafana doesn't start | `/run/grafana-secrets/secret-key` in the pod's in-memory `runtime` volume: `security.secret_key` | the same container, the same path. Changing the key leaves Grafana unable to read the data keys it wrapped, so never delete the store path to rotate it |
|
||||
| the swarm controller's webhook secret | `swarm-controller` stores it in the swarm secret store at `swarm/controller/swarm-controller/forge/webhook-secret` when the store holds none: the value of `webhook-secret` in its state directory, or a new one when there is no such file. The state directory file stays on disk and is the fallback while the store is unreachable or its policy doesn't grant the path yet | the swarm secret store; the controller holds it in memory and registers the same value with the forge's hooks | nothing to place: the controller's store leaf already exists. A store that stays unreachable on a start with no state directory file leaves the webhook endpoint answering 503 until the store answers: the controller re-reads it in the background, at most five minutes apart, and registers the forge hooks once it has the secret |
|
||||
| the secret store's unseal or recovery keys and root token, as `bao operator init -format=json` printed them | `bao operator init`, run once by `swarmctl bao init` (or `swarmctl setup`) on the host where the operator runs it | `bao-init.json` in swarmctl's state directory (`$XDG_STATE_HOME/swarmctl`, else `~/.local/state/swarmctl`, so `/root/.local/state/swarmctl` for root): file mode 0600 in a 0700 directory, written before swarmctl parses the output, so a parse failure leaves the keys on disk. Nothing reads it. The operator records the keys off the host, then runs `shred -u` on it; while it exists `swarmctl bao init` refuses to run | nothing: the file is on the host that ran `swarmctl bao init`, and no other host needs it |
|
||||
| the metrics store responder's own store leaf (cert + key) | `signLeaf` in `glue-bao-tls.nix` (`swarm-bao-pki.service`), on the host that runs the secret store, once, subject `deploy.bao.metricsAuthCommonName`. `swarm-bao-metrics-auth-policy.service` writes the `swarm-metrics-auth` role and its read grants on every agent's queue and observability leaves and on the bearer leaf, nothing else | `/var/lib/swarm-bao-pki/metrics-auth.pem` and `metrics-auth-key.pem` on the store's host, handed to `swarm-metrics-auth` through `LoadCredential` (paths in argv, never values) and read by path by `swarm-victoriametrics-forwarder-oidc` | **the operator** places a leaf with that subject on the metrics store's host and names it in `deploy.victoriametrics.authBaoClientCertFile` / `authBaoClientKeyFile`; evaluation fails naming both until then. If the store is on another host, deploy that host first: the role must exist before the responder's login succeeds, and until it does the gateway refuses every Grafana query (fail closed) |
|
||||
|
|
@ -146,13 +148,13 @@ pieces fit, and the reasoning behind them, is in [`credentials.md`](../../2-hand
|
|||
| a hive's copy of its own OIDC secret | hive-c0re reads it out of the swarm secret store when it first connects to the queue, under the hive's own leaf | the daemon's memory only; never on disk | same read, co-located or not. Nothing for an operator to place beyond the hive's store leaf (`deploy.bao.clientCertFile`) |
|
||||
| the hive collector's copy of its hive's OIDC secret | `swarm-bao-hive-otel-oidc.service` reads it out of the swarm secret store under the hive's own leaf, **on every hive that runs the collector and holds that leaf**; the leaf is the source | `/run/hive-otel-oidc/hive-<name>.secret` on the hive's host tmpfs, 0400 root, loaded by `LoadCredential` — never on persistent disk, so a reboot fetches it again | same unit, same path, co-located or not. Nothing for an operator to place beyond the hive's store leaf (`deploy.bao.clientCertFile`). Naming a secret file with `otel.clientSecretFile` instead is legacy for a host without a leaf: the build warns, and the fix is to place the leaf from `/var/lib/swarm-bao-pki/hives/<hive>/` and drop the setting |
|
||||
| the swarm controller's forge token | the forge's `forgejo-swarm-controller-account`, in-container, once. An attempt that fails or runs past 30 seconds retries after 5 seconds, then at growing intervals up to 5 minutes | the swarm secret store at `swarm/controller/swarm-controller/forge/token`, written by the mint under the forge publisher's leaf, which the forge container loads as a credential; the controller holds it in memory only. `/var/lib/forgejo/swarm-controller-token-name` in the forge container holds its name, the minter's record that it has minted | nothing to place beyond the controller's store leaf. A forge host without the store needs the publisher's leaf placed (`deploy.bao.forgePublisherClientCertFile`) |
|
||||
| the swarm controller's Grafana token | `swarm-bao-grafana-controller-token.service`, **on the host that runs Grafana**, as Grafana's built-in admin over its socket: it creates the `swarm-controller` service account as a Viewer (and sets it back to Viewer on every run), mints a token for it and writes it to the swarm secret store at `swarm/controller/swarm-controller/grafana/token` under Grafana's leaf. It waits up to 60 seconds for Grafana's socket to answer before its first call. Re-run every ten minutes: it keeps a stored token Grafana accepts, and replaces one Grafana refuses with 401 (or a missing one), deleting every other token of that account first | the swarm secret store only; the controller reads it for `GET /api/alerts` and holds it in memory, re-reading the store once when Grafana answers 401 | nothing to place: Grafana's leaf is already required to run Grafana. Until the unit has run, `/api/alerts` answers 503 naming the empty path |
|
||||
| the swarm controller's Grafana token | the `controller-token` sidecar of Grafana's pod, as Grafana's built-in admin on the pod's loopback: it creates the `swarm-controller` service account as a Viewer (and sets it back to Viewer on every pass), mints a token for it and writes it to the swarm secret store at `swarm/controller/swarm-controller/grafana/token` under the pod's login. It waits for Grafana's health route before its first call. It runs every five minutes: it keeps a stored token Grafana accepts, and replaces one Grafana refuses with 401 (or a missing one), deleting every other token of that account first | the swarm secret store only; the controller reads it for `GET /api/alerts` and holds it in memory, re-reading the store once when Grafana answers 401 | nothing to place. Until the sidecar has run, `/api/alerts` answers 503 naming the empty path |
|
||||
| an agent's API-key environment (`ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`, an ACP provider key) | `hive-agent-backend-env.service`, in the agent's container, on every agent with a store, whatever its runtime or its login kind. When the store holds nothing at `swarm/agents/<agent>/backend-env` and `backendEnvironmentFile` is a non-empty file, it creates the leaf with the file's exact bytes and `-cas=0`, under the agent's own leaf, which may create that path and not update it. It never rotates a value and never rewrites or deletes the file. To set or replace a key, use **set the API-key environment** in the swarm UI (`PUT /api/hives/{hive}/agents/{agent}/backend-env`): `swarm-controller` overwrites the leaf with its own grant, and the store's value then wins over the file. Its **remove** (`DELETE` on the same path) deletes the leaf, and an agent whose file has content then creates it from that file again | the swarm secret store at that path; the unit writes it to `/run/hive-agent-backend-env/env` (tmpfs, `0600`, root), and `hive-agent` and `hive-subagent-daemon` load that after `backendEnvironmentFile` as `EnvironmentFile=` | the same unit, same path. A variable in the store wins over the same one in the file. With the store down at a start, the file alone carries the agent, as it did before the store held a copy; with an older hive build the agent ignores the leaf and keeps reading the file |
|
||||
| an agent's proxy settings (`HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY`, the credential in the proxy URL) | `hive-agent-proxy-credential.service`, in the agent's container, as the agent user, at start and every 10 minutes: it reads `swarm/agents/<agent>/proxy-credential` under the agent's own leaf and builds the file from it. It writes nothing while the path holds nothing or the hive's facts name no squid | `/run/hive-agent-proxy-credential/proxy.env` (tmpfs, `0600`, the agent user); the harness, its bash tool, the subagents, the MCP servers and the pollers load it as `EnvironmentFile=-` and read it when they start | With no credential, or on a hive that writes no `HIVE_SQUID_PROXY` and `HIVE_EGRESS_NO_PROXY` fact, nothing writes the file and a unit has no proxy variable and reaches the internet without the proxy; the host still redirects the web traffic of a `restricted` or `log` agent into squid (see [the network reference](../networking/network.md#intercepted-web-traffic)). A failed read keeps the file already in place. A unit started before the file appeared goes direct until its next start. The credential is also in the environment of every process those units start, so `env` in the agent's shell prints it |
|
||||
| an agent's claude login (`.credentials.json`) | `swarm-claude-login.service`, in its container, when an operator completes `claude auth login` from the agent's card in the swarm UI; it stores the file as a new version at `swarm/agents/<agent>/claude-credentials` under its own leaf, which may create and update that path and read nothing under an agent | the swarm secret store at that path; the agent's `hive-agent` reads it under the agent's own leaf every 30 seconds while it waits for a login and writes it to `~/.claude/.credentials.json` | the same read, co-located or not; nothing for an operator to place beyond the agent's store leaf. When the store's copy and the agent's differ the KV version decides: the agent installs only a version newer than the last it installed (`claude-credentials-version` under the harness dir), because claude rotates the refresh token in its own copy and the stored one goes stale. The agent ignores a stale or equal version, and a relogin writes a newer one — [claude-login.md](../../2-handbook/swarm/claude-login.md) |
|
||||
| the queue responder's copy of its OIDC secret | the responder reads it out of the swarm secret store itself as it starts, under its own leaf, and again when authelia refuses it | the daemon's memory only; never on disk | same read, wherever authelia runs. Nothing for an operator to place beyond the responder's store leaf (`deploy.nats.authBaoClientCertFile`) |
|
||||
| the queue container's journal forwarder's copy of the queue's OIDC secret | `swarm-journal-forwarder-oidc.service` inside the `swarm-nats` container reads it out of the swarm secret store under the responder's store leaf, and again every 10 minutes | `/run/swarm-journal-forwarder-oidc/client-secret` on the container's tmpfs, root `0400`, never on persistent disk; `LoadCredential` hands it to the collector | same unit, same path. After a reboot the fetch fails fast while the store is down and retries with a delay that grows to 5 minutes; the attempt that succeeds starts the collector, which isn't part of the container's boot, and it resumes from its saved journal cursor. Nothing for an operator to place beyond the responder's store leaf (`deploy.nats.authBaoClientCertFile`) |
|
||||
| the CI runner, Grafana, cache, forge and homeserver containers' journal forwarders' OIDC secrets | `swarm-journal-forwarder-oidc.service` inside each container reads its forwarder client's secret (`swarm.<service>.otel.clientId`) out of the swarm secret store under the store leaf the host already holds for that service, handed in as a system credential (bound in read-only, for the homeserver's), and again every 10 minutes | `/run/swarm-journal-forwarder-oidc/client-secret` on the container's tmpfs, root `0400`, never on persistent disk; `LoadCredential` hands it to the collector | same unit, same path. Nothing for an operator to place beyond those leaves (`deploy.bao.ciRunnerClientCertFile`, `deploy.bao.grafanaOidcClientCertFile`, `deploy.bao.forgePublisherClientCertFile`, `deploy.bao.atticClientCertFile`, `deploy.matrix.ctlBaoClientCertFile`) |
|
||||
| the CI runner, cache, forge and homeserver containers' journal forwarders' OIDC secrets | `swarm-journal-forwarder-oidc.service` inside each container reads its forwarder client's secret (`swarm.<service>.otel.clientId`) out of the swarm secret store under the store leaf the host already holds for that service, handed in as a system credential (bound in read-only, for the homeserver's), and again every 10 minutes | `/run/swarm-journal-forwarder-oidc/client-secret` on the container's tmpfs, root `0400`, never on persistent disk; `LoadCredential` hands it to the collector | same unit, same path. Nothing for an operator to place beyond those leaves (`deploy.bao.ciRunnerClientCertFile`, `deploy.bao.forgePublisherClientCertFile`, `deploy.bao.atticClientCertFile`, `deploy.matrix.ctlBaoClientCertFile`) |
|
||||
| the CI run poller's forge token | `swarm-controller`, with the forge's admin API, for its `ci-metrics` account, at start and in a five-minute pass | the swarm secret store at `swarm/services/ci-metrics/forge/token`; `swarm-ci-metrics` reads it once per pass under its own leaf and holds it in memory for that pass. When the store's token no longer matches the forge's, the controller's next pass mints a new one; until then the poller's forge calls answer 401, the unit fails and no cursor moves | nothing to place beyond the poller's leaf (`deploy.bao.ciMetricsClientCertFile`), on a host without the store |
|
||||
| the CI run poller's copy of its OIDC secret | authelia's mint, which creates it in the swarm secret store | `swarm-ci-metrics` reads `swarm/services/<swarm.ci-metrics.clientId>/oidc/client` once per pass under its own leaf, and again when authelia refuses it; memory only. While it differs from authelia's, the token request fails, nothing gets pushed and no cursor moves | same leaf, nothing else |
|
||||
| authelia's container's journal forwarder's OIDC secret | authelia's mint, in its container, like every client's secret (`swarm.authelia.otel.clientId`). It creates it at `swarm/services/<id>/oidc/client`, and `swarm-journal-forwarder-oidc.service` in the same container reads it back under the secret publisher's leaf, at start and every 10 minutes | `/run/swarm-journal-forwarder-oidc/client-secret` on the container's tmpfs, root `0400`; `LoadCredential` hands it to the collector. | none: the forwarder runs only in authelia's container, and is off there without the publisher's leaf |
|
||||
|
|
@ -190,8 +192,8 @@ classifier's, the CI runner's, the builder's, the cache's, the CI run poller's,
|
|||
login minter's, the forge host's and Grafana's, which reach more than one:
|
||||
|
||||
| unit | option pair under `deploy.bao.` | reads, or writes |
|
||||
| Grafana's pod: the init container and the sidecar, through the jwt role `swarm-grafana-oidc` | `grafanaOidcClientCertFile` / `grafanaOidcClientKeyFile` | reads `swarm/services/<grafana client id>/oidc/client`; creates and reads `swarm/services/<grafana client id>/admin/password`, `swarm/services/<grafana client id>/metrics/bearer` and `swarm/services/<grafana client id>/secret-key`; reads and writes `swarm/controller/swarm-controller/grafana/token` |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `swarm-bao-grafana-oidc`, `swarm-bao-grafana-admin`, `swarm-bao-grafana-secret-key`, and Grafana's journal forwarder in its container | `grafanaOidcClientCertFile` / `grafanaOidcClientKeyFile` | reads `swarm/services/<grafana client id>/oidc/client` and `swarm/services/<grafana forwarder client id>/oidc/client`; creates and reads `swarm/services/<grafana client id>/admin/password` and `swarm/services/<grafana client id>/secret-key` |
|
||||
| `swarm-bao-otel-oidc` | `otelOidcClientCertFile` / `otelOidcClientKeyFile` | `swarm/services/<collector client id>/oidc/client` |
|
||||
| `swarm-bao-forwarder-oidc` | `forwarderOidcClientCertFile` / `forwarderOidcClientKeyFile` | `swarm/services/<store forwarder client id>/oidc/client` |
|
||||
| `swarm-bao-ci-runner`, and the runner's journal forwarder in its container | `ciRunnerClientCertFile` / `ciRunnerClientKeyFile` | `swarm/services/ci-runner/registration-token` and `swarm/services/<runner forwarder client id>/oidc/client` |
|
||||
|
|
@ -204,7 +206,7 @@ login minter's, the forge host's and Grafana's, which reach more than one:
|
|||
| `swarm-archive-users`, `swarm-archive-prune`, `swarm-archive-check` and, with an S3 bucket, `swarm-archive` | `archiveClientCertFile` / `archiveClientKeyFile` | reads `swarm/services/archive/users/*`, `swarm/services/archive/restic/*` and `swarm/services/archive/s3/*`, lists `swarm/services/archive/users/` |
|
||||
| `swarm-ci-metrics` | `ciMetricsClientCertFile` / `ciMetricsClientKeyFile` | `swarm/services/ci-metrics/forge/token` and `swarm/services/<poller client id>/oidc/client` |
|
||||
| `swarm-bao-forge-oidc` and the forge's controller-token mint and its journal forwarder in its container | `forgePublisherClientCertFile` / `forgePublisherClientKeyFile` | writes `swarm/controller/swarm-controller/forge/token`; reads `swarm/services/<forge client id>/oidc/client` and `swarm/services/<forge forwarder client id>/oidc/client` |
|
||||
| `swarm-bao-store-auth` | `storeAuthClientCertFile` / `storeAuthClientKeyFile` | creates and reads `swarm/services/victorialogs/store-auth`, `swarm/services/victoriametrics/store-auth` and `swarm/services/nats/exporter-auth` |
|
||||
| `swarm-bao-store-auth` | `storeAuthClientCertFile` / `storeAuthClientKeyFile` | creates and reads `swarm/services/victorialogs/store-auth`, `swarm/services/victoriametrics/store-auth`, `swarm/services/grafana/store-auth` and `swarm/services/nats/exporter-auth` |
|
||||
|
||||
The option names are `deploy.bao.<pair>`; the common names, what a missing leaf
|
||||
costs and how to place a leaf by hand are in
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@
|
|||
./glue-stt-oidc-client.nix
|
||||
./glue-attic-otel-oidc-client.nix
|
||||
./glue-forge-otel-oidc-client.nix
|
||||
./glue-grafana-otel-oidc-client.nix
|
||||
./glue-matrix-otel-oidc-client.nix
|
||||
./glue-review-classifier-oidc-client.nix
|
||||
./glue-secret-publisher-authelia.nix
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
# Gated on authelia being HERE, not on this host running the cache: a client is
|
||||
# a row in THIS host's provider config, the split
|
||||
# ./glue-grafana-otel-oidc-client.nix makes for the same reason.
|
||||
# ./glue-forge-otel-oidc-client.nix makes for the same reason.
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ let
|
|||
|
||||
# Reader unit → the gate its own module defines it under.
|
||||
readersHere = {
|
||||
# ./swarm-grafana.nix
|
||||
swarm-bao-grafana-oidc = deployCfg.grafana.enable;
|
||||
# ./swarm-otel.nix
|
||||
swarm-bao-otel-oidc =
|
||||
deployCfg.swarm-otel.enable
|
||||
|
|
@ -46,7 +44,12 @@ let
|
|||
swarm-bao-ci-runner = deployCfg.ci-runner.enable;
|
||||
# ./k8s/store-credentials.nix
|
||||
swarm-bao-store-auth =
|
||||
(deployCfg.victorialogs.enable || deployCfg.victoriametrics.enable || deployCfg.nats.enable)
|
||||
(
|
||||
deployCfg.victorialogs.enable
|
||||
|| deployCfg.victoriametrics.enable
|
||||
|| deployCfg.nats.enable
|
||||
|| deployCfg.grafana.enable
|
||||
)
|
||||
&& deployCfg.k8s.enable
|
||||
&& hyperhiveCfg.k8s.enable
|
||||
&& havePair baoDeploy.storeAuthClientCertFile baoDeploy.storeAuthClientKeyFile;
|
||||
|
|
@ -55,25 +58,6 @@ let
|
|||
# Readers that log in under another unit's principal: reader unit → the
|
||||
# gate its own module defines it under, and the policy units it waits for.
|
||||
readersOfOtherPolicy = {
|
||||
# ./swarm-grafana.nix, under Grafana's leaf, which may create the admin
|
||||
# password, the metrics bearer, the datasource key and the controller's
|
||||
# Grafana token only once that policy is written.
|
||||
swarm-bao-grafana-admin = {
|
||||
here = deployCfg.grafana.enable;
|
||||
policies = [ "swarm-bao-grafana-oidc-policy" ];
|
||||
};
|
||||
swarm-bao-grafana-metrics-bearer = {
|
||||
here = deployCfg.grafana.enable;
|
||||
policies = [ "swarm-bao-grafana-oidc-policy" ];
|
||||
};
|
||||
swarm-bao-grafana-secret-key = {
|
||||
here = deployCfg.grafana.enable;
|
||||
policies = [ "swarm-bao-grafana-oidc-policy" ];
|
||||
};
|
||||
swarm-bao-grafana-controller-token = {
|
||||
here = deployCfg.grafana.enable;
|
||||
policies = [ "swarm-bao-grafana-oidc-policy" ];
|
||||
};
|
||||
# ./swarm-attic.nix, under the cache's leaf, which may create the signing
|
||||
# key, the two tokens and the cache's public facts only once that policy is
|
||||
# written.
|
||||
|
|
|
|||
|
|
@ -56,12 +56,6 @@ let
|
|||
&& hyperhiveCfg.deploy.hive-controller.hiveName != null
|
||||
&& havePair baoDeploy.clientCertFile baoDeploy.clientKeyFile
|
||||
&& otel.clientSecretFile == hiveOtelSecret.path;
|
||||
# ./swarm-grafana.nix
|
||||
swarm-bao-grafana-oidc = deployCfg.grafana.enable;
|
||||
swarm-bao-grafana-admin = deployCfg.grafana.enable;
|
||||
swarm-bao-grafana-metrics-bearer = deployCfg.grafana.enable;
|
||||
swarm-bao-grafana-secret-key = deployCfg.grafana.enable;
|
||||
swarm-bao-grafana-controller-token = deployCfg.grafana.enable;
|
||||
# ./swarm-ci-runner.nix
|
||||
swarm-bao-ci-runner = deployCfg.ci-runner.enable;
|
||||
# ./swarm-attic.nix
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
# Glue: register the Grafana container's journal forwarder as an OIDC
|
||||
# client wherever authelia runs.
|
||||
#
|
||||
# ONE PAIRING PER FILE: that forwarder ← authelia, and nothing else.
|
||||
# Without it authelia mints no secret, the publisher has nothing to copy into
|
||||
# the store, and the forwarder's export is a 401.
|
||||
#
|
||||
# Gated on authelia being HERE, not on this host running Grafana: a
|
||||
# client is a row in THIS host's provider config, the split
|
||||
# ./glue-swarm-bao-otel-oidc-client.nix makes for the same reason.
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hyperhiveCfg = config.services.hyperhive;
|
||||
clientId = hyperhiveCfg.swarm.grafana.otel.clientId;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf hyperhiveCfg.deploy.authelia.enable {
|
||||
services.hyperhive.swarm.authelia.oidc.clients = [
|
||||
{
|
||||
id = clientId;
|
||||
description = "HyperHive Grafana journal forwarder";
|
||||
kind = "machine";
|
||||
redirectUris = [ ];
|
||||
# Its own id as its own permitted audience, the one the swarm
|
||||
# collector's receiver for this container checks.
|
||||
audience = [ clientId ];
|
||||
# The receiver verifies the token offline against `/jwks.json`;
|
||||
# authelia's default opaque handle fails there.
|
||||
accessTokenSignedResponseAlg = "RS256";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -168,6 +168,7 @@ let
|
|||
"swarm-controller"
|
||||
"victorialogs"
|
||||
"victoriametrics"
|
||||
"grafana"
|
||||
];
|
||||
enabledServices = lib.filter (name: deployCfg.${name}.enable) swarmServices;
|
||||
|
||||
|
|
@ -179,6 +180,7 @@ let
|
|||
ci-metrics
|
||||
victorialogs
|
||||
victoriametrics
|
||||
grafana
|
||||
;
|
||||
};
|
||||
in
|
||||
|
|
@ -320,7 +322,7 @@ in
|
|||
none of those pods.
|
||||
|
||||
- `hyperhive.darkest.space/state-<service>` for each service whose data the
|
||||
cluster keeps: `nats`, `ci-metrics`, `victorialogs` and `victoriametrics`, each when enabled. A volume's `nodeAffinity` and the pod's `nodeSelector` name it.
|
||||
cluster keeps: `nats`, `ci-metrics`, `victorialogs`, `victoriametrics` and `grafana`, each when enabled. A volume's `nodeAffinity` and the pod's `nodeSelector` name it.
|
||||
- `hyperhive.darkest.space/entry`: the node the hosts' DNS points at.
|
||||
- `svccontroller.k3s.cattle.io/enablelb`: with it on any node, the
|
||||
service load balancer binds a published port on the labelled nodes
|
||||
|
|
|
|||
|
|
@ -344,6 +344,38 @@ let
|
|||
egress = [ "store" ];
|
||||
otlp = "none";
|
||||
};
|
||||
# Grafana: the swarm's metrics UI, on a static local volume that is its
|
||||
# data directory. Its configuration, provisioning and plugins are in the
|
||||
# image; an init container fetches its secrets and a sidecar keeps the
|
||||
# controller's token (`pod`). It logs in to nothing itself and pushes no
|
||||
# telemetry. The UI and the API take Grafana's own login; its `/metrics`
|
||||
# takes the listener credential.
|
||||
swarm-grafana = {
|
||||
inherit (deployCfg.grafana) enable unit pod;
|
||||
package = deployCfg.grafana.startPackage;
|
||||
kind = "Deployment";
|
||||
healthEnv = null;
|
||||
probe = {
|
||||
path = "/api/health";
|
||||
startupFailureThreshold = 30;
|
||||
};
|
||||
etcFiles = [ ];
|
||||
publicCredentials."bao-ca.pem" = baoServerCaKey;
|
||||
listener.port = deployCfg.grafana.servicePort;
|
||||
# The secret store, and the gateway's 443: authelia's token and userinfo
|
||||
# routes and both datasources.
|
||||
egress = [
|
||||
"store"
|
||||
"identity"
|
||||
];
|
||||
baoRole = "swarm-grafana-oidc";
|
||||
localState = {
|
||||
service = "grafana";
|
||||
hostDir = deployCfg.grafana.hostDataDir;
|
||||
};
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
otlp = "none";
|
||||
};
|
||||
};
|
||||
|
||||
# Where a pod pushes telemetry. A `"hive"` service pushes to the hive
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
# The listener credentials of the Victoria stores the cluster runs and of the
|
||||
# queue's exporter: the unit that creates each in the swarm secret store when it
|
||||
# The listener credentials of the Victoria stores and Grafana the cluster runs and
|
||||
# of the queue's exporter: the unit that creates each in the swarm secret store when it
|
||||
# holds none, hands it to the gateway's nginx and publishes it to the cluster as
|
||||
# the Secret the pod reads it from (the store's password, the exporter's bcrypt
|
||||
# hash). The stores' flags and the locations that send the credential are in
|
||||
# ../swarm-victorialogs.nix and ../swarm-victoriametrics.nix, the exporter's in
|
||||
# ../swarm-nats.nix; ../lib/store-auth.nix names what they share.
|
||||
# hash). The flags and the locations that send the credential are in
|
||||
# ../swarm-victorialogs.nix, ../swarm-victoriametrics.nix and ../swarm-grafana.nix,
|
||||
# the exporter's in ../swarm-nats.nix; ../lib/store-auth.nix names what they share.
|
||||
# docs/4-implementation/k8s/runtime.md has the design.
|
||||
{
|
||||
pkgs,
|
||||
|
|
@ -27,10 +27,11 @@ let
|
|||
# the files `include`d into the store locations.
|
||||
nginxGroup = config.services.nginx.group;
|
||||
|
||||
# The stores this host runs, by the name `store-auth.nix` takes.
|
||||
# The pods this host runs that take the credential, by the name `store-auth.nix` takes.
|
||||
stores =
|
||||
lib.optional deployCfg.victorialogs.enable "victorialogs"
|
||||
++ lib.optional deployCfg.victoriametrics.enable "victoriametrics";
|
||||
++ lib.optional deployCfg.victoriametrics.enable "victoriametrics"
|
||||
++ lib.optional deployCfg.grafana.enable "grafana";
|
||||
|
||||
# The queue's exporter runs in the queue's pod.
|
||||
exporterOn = deployCfg.nats.enable;
|
||||
|
|
@ -96,7 +97,7 @@ in
|
|||
];
|
||||
|
||||
systemd.services.swarm-bao-store-auth = lib.mkIf haveIdentity {
|
||||
description = "create the Victoria stores' and the queue exporter's listener credentials in the swarm secret store if absent, and publish them";
|
||||
description = "create the stores', Grafana's and the queue exporter's listener credentials in the swarm secret store if absent, and publish them";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [
|
||||
|
|
@ -216,7 +217,7 @@ in
|
|||
store_init
|
||||
store_login
|
||||
if [ "$STORE_UP" != 1 ]; then
|
||||
echo "could not log in to the swarm secret store; the stores' credentials are not published." >&2
|
||||
echo "could not log in to the swarm secret store; the listener credentials are not published." >&2
|
||||
exit 1
|
||||
fi
|
||||
${lib.concatMapStrings publish stores}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# What the Victoria stores' listener credential is, where it lives, and who
|
||||
# What the listener credential of the Victoria stores and of Grafana is, where it lives, and who
|
||||
# names it. The store's pod, the gateway's vhost and the unit that mints and
|
||||
# publishes it (../k8s/store-credentials.nix) all spell it from here.
|
||||
#
|
||||
|
|
@ -7,6 +7,9 @@
|
|||
# leaf of the swarm secret store, created by that unit when the store holds
|
||||
# none. The pod reads it from the Secret `secretName`; nginx sends it in the
|
||||
# `Authorization` header that `nginxFile` sets.
|
||||
#
|
||||
# Grafana asks for the same login on `/metrics` alone (`[metrics] basic_auth_*`);
|
||||
# its other routes take its own login.
|
||||
rec {
|
||||
# The Basic login's user name, the same for every store.
|
||||
user = "swarm-store";
|
||||
|
|
@ -16,7 +19,7 @@ rec {
|
|||
credentialId = "store-auth";
|
||||
|
||||
# Under KV v2's `secret/` mount, as `bao kv` takes it. `store` is
|
||||
# `victorialogs` or `victoriametrics`.
|
||||
# `victorialogs`, `victoriametrics` or `grafana`.
|
||||
leaf = store: "swarm/services/${store}/store-auth";
|
||||
|
||||
# On the host, a directory for root and the gateway's group (`0750`): the nginx
|
||||
|
|
|
|||
|
|
@ -85,23 +85,20 @@ let
|
|||
# below takes a list either way and the units stay identical apart from
|
||||
# the objects they write.
|
||||
#
|
||||
# Grafana's leaf also creates its admin password (`swarm-bao-grafana-admin`
|
||||
# in ./swarm-grafana.nix) and the bearer its metrics datasource presents
|
||||
# (`swarm-bao-grafana-metrics-bearer`) and its datasource-encryption key
|
||||
# (`swarm-bao-grafana-secret-key`). `create` without `update`, so a stored
|
||||
# value is never replaced.
|
||||
# Grafana's pod logs in under this role. It creates its admin password, the
|
||||
# bearer its datasources present and its datasource-encryption key
|
||||
# (`swarm-grafana-fetch` in ./swarm-grafana.nix), `create` without `update`, so a
|
||||
# stored value is never replaced.
|
||||
#
|
||||
# The controller's Grafana token is the one it may replace:
|
||||
# `swarm-bao-grafana-controller-token` mints a new one when Grafana refuses
|
||||
# the stored one, as it does after its database is recreated.
|
||||
# The controller's Grafana token is the one it may replace: its sidecar mints a
|
||||
# new one when Grafana refuses the stored one, as it does after its database
|
||||
# is recreated.
|
||||
grafanaOidcReaders = [
|
||||
{
|
||||
name = "swarm-grafana-oidc";
|
||||
cn = baoDeploy.grafanaOidcCommonName;
|
||||
policyText =
|
||||
readStanza "${credentialMountPath}/data/swarm/services/${hyperhiveCfg.swarm.grafana.oidc.clientId}/oidc/client"
|
||||
# The journal forwarder in its container, under this same leaf.
|
||||
+ readStanza "${credentialMountPath}/data/swarm/services/${hyperhiveCfg.swarm.grafana.otel.clientId}/oidc/client"
|
||||
+ createStanza "${credentialMountPath}/data/${grafanaAdminLeaf}"
|
||||
+ createStanza "${credentialMountPath}/data/${grafanaMetricsBearerLeaf}"
|
||||
+ createStanza "${credentialMountPath}/data/${grafanaSecretKeyLeaf}"
|
||||
|
|
@ -362,11 +359,11 @@ let
|
|||
}
|
||||
];
|
||||
|
||||
# The unit that publishes the stores' listener credentials
|
||||
# The unit that publishes the stores' and Grafana's listener credentials
|
||||
# (`swarm-bao-store-auth`, ./k8s/store-credentials.nix): it creates each
|
||||
# credential when the store holds none and reads it back, `create` without
|
||||
# `update`, so a stored value is never replaced. One principal for both
|
||||
# stores and the queue's exporter, a leaf each.
|
||||
# `update`, so a stored value is never replaced. One principal for the
|
||||
# stores, Grafana and the queue's exporter, a leaf each.
|
||||
storeAuthWriters = [
|
||||
{
|
||||
name = "swarm-store-auth";
|
||||
|
|
@ -376,6 +373,7 @@ let
|
|||
[
|
||||
"victorialogs"
|
||||
"victoriametrics"
|
||||
"grafana"
|
||||
]
|
||||
+ createReadStanza "${credentialMountPath}/data/${storeAuth.exporter.leaf}";
|
||||
}
|
||||
|
|
@ -441,6 +439,9 @@ let
|
|||
# The metrics store's two responders, likewise under the ServiceAccount of
|
||||
# their pod (./k8s/render.nix, `swarm-metrics-auth`).
|
||||
++ metricsAuthReaders
|
||||
# Grafana's pod runs under the ServiceAccount of its service, `swarm-grafana`,
|
||||
# and logs in under the role its certificate has always had.
|
||||
++ map (obj: obj // { serviceAccount = grafanaPodAccount; }) grafanaOidcReaders
|
||||
++ [ { name = controllerPolicyName; } ]
|
||||
# The queue's pod holds both of its roles under one ServiceAccount: the
|
||||
# server's leaf is issued with `swarm-nats`, and the responder reads its
|
||||
|
|
@ -453,6 +454,10 @@ let
|
|||
# it: the pod is the service `swarm-nats`.
|
||||
natsPodAccount = "swarm-nats";
|
||||
|
||||
# The ServiceAccount Grafana's pod runs under: the pod is the service
|
||||
# `swarm-grafana`.
|
||||
grafanaPodAccount = "swarm-grafana";
|
||||
|
||||
# The jwt role of one principal: the token of exactly its ServiceAccount (the
|
||||
# one of its name, unless the record names another), for this store's
|
||||
# audience. Both the subject and the audience are bound, so a
|
||||
|
|
|
|||
|
|
@ -117,9 +117,8 @@ let
|
|||
collectorServiceName = "bao";
|
||||
|
||||
# Upstream's own default, kept so its documentation matches. The raft data
|
||||
# lives INSIDE the container on `ephemeral = false`, the same way
|
||||
# ./swarm-grafana.nix keeps its sqlite database — no sibling service binds
|
||||
# its state out to the host.
|
||||
# lives INSIDE the container on `ephemeral = false`; no container of
|
||||
# the swarm binds its state out to the host.
|
||||
#
|
||||
# ⚠️ Do not bind-mount this path. Upstream pairs `StateDirectory=` with
|
||||
# `DynamicUser=`, which makes systemd hold the state at
|
||||
|
|
@ -1799,7 +1798,8 @@ in
|
|||
example = "swarm-bao-grafana-oidc.svc";
|
||||
description = ''
|
||||
Subject the store's `swarm-grafana-oidc` cert-auth role accepts — the
|
||||
identity the unit that fetches Grafana's OIDC client secret presents.
|
||||
identity the fetch of Grafana's OIDC client secret presents; the pod's
|
||||
`swarm-grafana-oidc` jwt role carries the same policy.
|
||||
|
||||
Its grant is one path,
|
||||
`swarm/services/<grafana client id>/oidc/client`, and read only. Not
|
||||
|
|
@ -2051,11 +2051,12 @@ in
|
|||
default = "swarm-store-auth";
|
||||
description = ''
|
||||
Subject the store's `swarm-store-auth` cert-auth role accepts: the
|
||||
identity the unit that publishes the log store's, the metrics store's and the
|
||||
queue exporter's listener credentials presents from the host
|
||||
(./k8s/store-credentials.nix). Its grant is create and read on
|
||||
identity the unit that publishes the log store's, the metrics store's,
|
||||
Grafana's and the queue exporter's listener credentials presents from the
|
||||
host (./k8s/store-credentials.nix). Its grant is create and read on
|
||||
`swarm/services/victorialogs/store-auth`,
|
||||
`swarm/services/victoriametrics/store-auth` and
|
||||
`swarm/services/victoriametrics/store-auth`,
|
||||
`swarm/services/grafana/store-auth` and
|
||||
`swarm/services/nats/exporter-auth`, and nothing else.
|
||||
|
||||
⚠️ Reserved as a hive name by ./swarm.nix, like its siblings.
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ in
|
|||
services.hyperhive.gateway.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.dns.enable = lib.mkDefault true;
|
||||
|
||||
# Shaped after ./swarm-grafana.nix's `swarm-bao-grafana-oidc`, except that
|
||||
# Shaped after the forge's `swarm-bao-forge-oidc`, except that
|
||||
# a missing token fails too: swarm-controller publishes it at its start and
|
||||
# every five minutes, so a retry is what turns "no value there" into one.
|
||||
systemd.services.swarm-bao-ci-runner = {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue