diff --git a/docs/4-implementation/k8s/runtime.md b/docs/4-implementation/k8s/runtime.md index c37653fbe..2148e83c3 100644 --- a/docs/4-implementation/k8s/runtime.md +++ b/docs/4-implementation/k8s/runtime.md @@ -256,6 +256,30 @@ strategy, and the removed container stops before the pod can start. cluster's policy engine always admits traffic from an address of the node, so the gateway and the kubelet's probes reach the pod, and a pod of the cluster, or a client of the bridge that the host forwards, doesn't reach the exporter. +- **The exporter's login.** The node's processes reach the exporter too, so it + asks every request for a login. The exporter's container runs with + `-http_user swarm-exporter` and `-http_pass $(EXPORTER_HASH)`, the variable + coming from the key `hash` of the Secret `swarm-nats-exporter-auth`. The + exporter's flag takes no file, and it treats a value as bcrypt only when it + starts with `$2a$` (`exporter/exporter.go`, `bcryptPrefix`, in 0.15.0), so the + command line, which anyone who reads the pod spec or `/proc` sees, carries a + `$2a$11$` hash: cost 11 is the default of `nats server passwd`, and a hash of + a 64-digit random password is no credential. An exporter whose Secret is + missing doesn't start; it never runs open. TLS client verification isn't an + option in 0.15.0: `-tlscacert` sets the client CA pool and leaves `ClientAuth` + at `NoClientCert` (`exporter/exporter.go`), so the exporter never asks for a client certificate. + The unit `swarm-bao-store-auth` creates the password in the swarm + secret store at `swarm/services/nats/exporter-auth`, under the same + `swarm-store-auth` principal as the stores' with one more create-and-read + leaf, makes the hash with `htpasswd` (the password on stdin, never an + argument), and writes the password's `Authorization` header to + `/var/lib/swarm-store-auth/nats.conf`, which the gateway's `/metrics` + location `include`s in place of the caller's header. Without that file's + content the location sends no login and the exporter answers 401, so a + gateway that lacks it fails closed. A host that runs the queue gets the unit + and the leaf by default, with no option to name. Rotating works as for the + stores, and the exporter reads the hash as it starts, so the queue's pod + restarts after it. - **The leaf.** `tls-issue` logs in to the store with the pod's token as the role `swarm-nats` and issues the server's leaf from the same script as the host's `swarm-bao-nats-tls`. The key lands in a volume in memory. The diff --git a/docs/4-implementation/swarm/credentials-reference.md b/docs/4-implementation/swarm/credentials-reference.md index 36fc9c932..b03e18570 100644 --- a/docs/4-implementation/swarm/credentials-reference.md +++ b/docs/4-implementation/swarm/credentials-reference.md @@ -16,59 +16,60 @@ the rest of the cell says how. -| store path | minter | reader | automatic re-mint | automatic re-pull | -| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `swarm/agents//matrix/main` | `swarm-controller`, at agent creation and every 5 minutes | the agent | ✅ when missing or rejected by the homeserver | ✅ the daemon restarts within 5 minutes of a rejection | -| `swarm/agents//matrix/` | `swarm-controller`, from a credential you hand it | the agent | must be stated | ✅ retried within 2 to 16 minutes after a rejection | -| `swarm/agents//matrix-recovery/` | `swarm-controller`, a random passphrase per account | the agent | ❌ never replaced: the account's key backup opens only with this passphrase | ❌ read when the account comes up | -| `swarm/controller/swarm-controller/matrix/appservice-token` | `swarm-matrix-ctl appservice sync` in `hive-matrix`, from the registration's `as_token` | `swarm-controller` | ❌ follows the registration below | ✅ read every 5 minutes | -| `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/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//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//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) | -| `swarm/agents//observability` | `swarm-controller`, when an operator sets, clears or creates an agent's permissions with `logs` or `metrics` in the old or new list, and when it destroys the agent; the leaf stays absent for an agent that never held either | the agent (read-only, its own prefix); `swarm-logs-auth` and the metrics store's agents' responder, which deny when it's absent or unreadable | ✅ the controller rewrites it with the permission, and every five minutes makes it equal the record's | ✅ the stores honour a changed grant for up to `deploy.victorialogs.authVerdictTtl` and `deploy.victoriametrics.agentAuthVerdictTtl` (60 s by default) | -| `swarm/agents//forge-token` | `swarm-controller`, at agent creation and every 5 minutes | the agent | ✅ when missing or no longer matching the forge | ✅ every 10 minutes | -| `swarm/agents//forge/