k8s: the gateway's group reads the store credential files nginx includes
This commit is contained in:
parent
132d876668
commit
e0b3c0a644
7 changed files with 119 additions and 64 deletions
|
|
@ -367,9 +367,9 @@ writes to the store and Grafana that reads it.
|
||||||
`swarm/services/victorialogs/store-auth` when the store holds none, as the host's
|
`swarm/services/victorialogs/store-auth` when the store holds none, as the host's
|
||||||
`swarm-store-auth` principal, whose one grant is create and read on this leaf
|
`swarm-store-auth` principal, whose one grant is create and read on this leaf
|
||||||
and the metrics store's. It writes the `Authorization` header to
|
and the metrics store's. It writes the `Authorization` header to
|
||||||
`/var/lib/swarm-store-auth/victorialogs.conf` (`root:root`, `0600`, in a root-only directory;
|
`/var/lib/swarm-store-auth/victorialogs.conf` (`root:` the gateway's group, `0640`, in a `0750` directory of the same owner;
|
||||||
nginx's main process reads its configuration as root, so the file needs no
|
NixOS runs nginx's master and workers as `User=nginx`, so the group is the
|
||||||
other reader, and it's never in the nix store), which the vhost's store
|
only reader besides root, and the file is never in the nix store), which the vhost's store
|
||||||
locations `include`, then reloads nginx, and publishes the password as the
|
locations `include`, then reloads nginx, and publishes the password as the
|
||||||
Secret the way the host publishes the CA ConfigMap. The unit is `Type=simple`
|
Secret the way the host publishes the CA ConfigMap. The unit is `Type=simple`
|
||||||
and retries every 30 seconds, so a boot or a switch with the secret store still
|
and retries every 30 seconds, so a boot or a switch with the secret store still
|
||||||
|
|
|
||||||
|
|
@ -121,52 +121,52 @@ pieces fit, and the reasoning behind them, is in [`credentials.md`](../../2-hand
|
||||||
|
|
||||||
### Swarm-level — one of each per swarm
|
### Swarm-level — one of each per swarm
|
||||||
|
|
||||||
| secret | generated by | lives at | hive elsewhere |
|
| secret | generated by | lives at | hive elsewhere |
|
||||||
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| swarm-services root CA (cert + key) | `swarm-bao.nix`'s granting unit, inside the store's `pki` mount | the **key** never leaves the mount; the **cert** lands at `/var/lib/swarm-bao-services-pki/services-root.pem` (0644) and at `/var/lib/hive-tls/swarm-services-root.pem` on every hive | nothing to copy — every hive receives the cert with the leaf it asks the store for, or from `pki/ca/pem` where it fronts no swarm name and needs a store identity |
|
| swarm-services root CA (cert + key) | `swarm-bao.nix`'s granting unit, inside the store's `pki` mount | the **key** never leaves the mount; the **cert** lands at `/var/lib/swarm-bao-services-pki/services-root.pem` (0644) and at `/var/lib/hive-tls/swarm-services-root.pem` on every hive | nothing to copy — every hive receives the cert with the leaf it asks the store for, or from `pki/ca/pem` where it fronts no swarm name and needs a store identity |
|
||||||
| authelia session, JWT, storage-encryption and OIDC HMAC keys | `authelia-swarm-secrets` in authelia's container. It stores each in the swarm secret store at `swarm/services/swarm-authelia/keys/<name>` when the store holds none: the value of the key an earlier release generated, or a new one when there is no such file. The files stay on disk. While the store is down, refuses the login, or fails the read of a leaf (a refusal, a timeout, an error), the unit runs on the files, logs the store's error, and writes nothing to the store; the unit seeds or mints only a leaf the store reports as absent. A container with no secret publisher identity generates the files, as before | `/var/lib/authelia-swarm/{session,jwt,storage-encryption,oidc-hmac}.key` | nothing to place: the publisher's store leaf is the one in the row below. A store that stays unreachable on a start with no key file keeps authelia from starting |
|
| authelia session, JWT, storage-encryption and OIDC HMAC keys | `authelia-swarm-secrets` in authelia's container. It stores each in the swarm secret store at `swarm/services/swarm-authelia/keys/<name>` when the store holds none: the value of the key an earlier release generated, or a new one when there is no such file. The files stay on disk. While the store is down, refuses the login, or fails the read of a leaf (a refusal, a timeout, an error), the unit runs on the files, logs the store's error, and writes nothing to the store; the unit seeds or mints only a leaf the store reports as absent. A container with no secret publisher identity generates the files, as before | `/var/lib/authelia-swarm/{session,jwt,storage-encryption,oidc-hmac}.key` | nothing to place: the publisher's store leaf is the one in the row below. A store that stays unreachable on a start with no key file keeps authelia from starting |
|
||||||
| authelia OIDC issuer key (RSA) | same unit, same store path (`oidc-issuer`) | `/var/lib/authelia-swarm/oidc-issuer.key` | same — relying parties verify against the **public** half at `/jwks.json` |
|
| authelia OIDC issuer key (RSA) | same unit, same store path (`oidc-issuer`) | `/var/lib/authelia-swarm/oidc-issuer.key` | same — relying parties verify against the **public** half at `/jwks.json` |
|
||||||
| swarm appservice registration (`as_token`, `hs_token`) | `swarm-matrix-ctl appservice render` in `hive-matrix`. The store's pair wins; a store holding none takes the tokens an earlier version kept in the container, so the value doesn't change by moving. Only a store that answers, holds none, and a container with no such files gets a new pair | `/run/swarm-matrix-appservice/swarm.yaml` in `hive-matrix` (tmpfs), which tuwunel loads through `LoadCredential`. The earlier `/var/lib/swarm-matrix-appservice/{as-token,hs-token,swarm.yaml}` stay, unused, and bao wins if they differ; the store path is `swarm/controller/swarm-controller/matrix/appservice-registration` | nothing to place: matrix-ctl's store leaf is the one the container binds. A store that's down keeps the homeserver down and mints nothing, and `render` retries every 30 seconds for 24 hours |
|
| swarm appservice registration (`as_token`, `hs_token`) | `swarm-matrix-ctl appservice render` in `hive-matrix`. The store's pair wins; a store holding none takes the tokens an earlier version kept in the container, so the value doesn't change by moving. Only a store that answers, holds none, and a container with no such files gets a new pair | `/run/swarm-matrix-appservice/swarm.yaml` in `hive-matrix` (tmpfs), which tuwunel loads through `LoadCredential`. The earlier `/var/lib/swarm-matrix-appservice/{as-token,hs-token,swarm.yaml}` stay, unused, and bao wins if they differ; the store path is `swarm/controller/swarm-controller/matrix/appservice-registration` | nothing to place: matrix-ctl's store leaf is the one the container binds. A store that's down keeps the homeserver down and mints nothing, and `render` retries every 30 seconds for 24 hours |
|
||||||
| OIDC client secret, plaintext half | `authelia crypto hash generate --random` | the swarm secret store, at the path its reader fetches: `swarm/hives/<hive>/oidc/client`, `swarm/controller/swarm-controller/oidc/client` or `swarm/services/<client id>/oidc/client`. The bridge reads its own into `/run/swarm-authelia-bridge/client-secret` before each start. A container with no secret publisher identity keeps it in `/var/lib/authelia-swarm/oidc-clients/<id>.secret`; a file an earlier release left seeds the store once when it holds no value, and stays unused | nothing to place: readers fetch it from the store ([how](../../2-handbook/swarm/credentials.md#hive-level-secrets)) |
|
| OIDC client secret, plaintext half | `authelia crypto hash generate --random` | the swarm secret store, at the path its reader fetches: `swarm/hives/<hive>/oidc/client`, `swarm/controller/swarm-controller/oidc/client` or `swarm/services/<client id>/oidc/client`. The bridge reads its own into `/run/swarm-authelia-bridge/client-secret` before each start. A container with no secret publisher identity keeps it in `/var/lib/authelia-swarm/oidc-clients/<id>.secret`; a file an earlier release left seeds the store once when it holds no value, and stays unused | nothing to place: readers fetch it from the store ([how](../../2-handbook/swarm/credentials.md#hive-level-secrets)) |
|
||||||
| OIDC client secret, digest half | the same mint | `oidc-clients/<id>.digest` | authelia's own half; merged at runtime via `settingsFiles` |
|
| OIDC client secret, digest half | the same mint | `oidc-clients/<id>.digest` | authelia's own half; merged at runtime via `settingsFiles` |
|
||||||
| 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 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, `0600`, in a directory of `0700`): the `Authorization` header the vhost's store locations send, and `/var/lib/swarm-store-auth/victorialogs.password` (the same), 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 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, `0600`, in a directory of `0700`): the `Authorization` header the vhost's store locations send, and `/var/lib/swarm-store-auth/victoriametrics.password` (the same), 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 |
|
| 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 |
|
||||||
| 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, `0600`, in a directory of `0700`): the `Authorization` header the gateway's `/metrics` location for the queue sends; `/var/lib/swarm-store-auth/nats.password` (the password) 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 |
|
| 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 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 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 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 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 |
|
||||||
| 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 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 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) |
|
| 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) |
|
||||||
| the secret publisher's 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.secretPublisherCommonName`. `swarm-bao-secret-publisher-policy.service` writes the `swarm-secret-publisher` role: create and update under `swarm/hives/*`, `swarm/services/*` and the controller's client, and read on the `oidc/client` leaves it mints, the controller's client and authelia's five keys alone | `/var/lib/swarm-bao-pki/secret-publisher.pem` and `secret-publisher-key.pem` on the host, handed into authelia's container as nspawn system credentials, which `authelia-swarm-secrets`, `swarm-authelia-bridge` and the forwarder's `swarm-journal-forwarder-oidc` load with `LoadCredential`. nspawn won't start authelia's container while a named file is missing | **the operator** copies the leaf to authelia's host, beside the hive's own store leaf, where `glue-secret-publisher-bao-identity.nix` looks, or names it in `deploy.swarm-secret-publisher.baoClientCertFile` / `baoClientKeyFile` |
|
| the secret publisher's 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.secretPublisherCommonName`. `swarm-bao-secret-publisher-policy.service` writes the `swarm-secret-publisher` role: create and update under `swarm/hives/*`, `swarm/services/*` and the controller's client, and read on the `oidc/client` leaves it mints, the controller's client and authelia's five keys alone | `/var/lib/swarm-bao-pki/secret-publisher.pem` and `secret-publisher-key.pem` on the host, handed into authelia's container as nspawn system credentials, which `authelia-swarm-secrets`, `swarm-authelia-bridge` and the forwarder's `swarm-journal-forwarder-oidc` load with `LoadCredential`. nspawn won't start authelia's container while a named file is missing | **the operator** copies the leaf to authelia's host, beside the hive's own store leaf, where `glue-secret-publisher-bao-identity.nix` looks, or names it in `deploy.swarm-secret-publisher.baoClientCertFile` / `baoClientKeyFile` |
|
||||||
| the operator's store leaf (cert + key) | `signLeaf` in `glue-bao-tls.nix` (`swarm-bao-pki.service`), on every host that runs the secret store, once, subject `deploy.bao.operatorCommonName`. No cert-auth role accepts that subject, so the leaf opens the TLS handshake and logs in to nothing | `/var/lib/swarm-bao-pki/operator.pem` and `operator-key.pem` on the host, `0600` root; the host's `bao` wrapper presents it when the host runs no hive, via `deploy.bao.operatorClientCertFile` / `operatorClientKeyFile`. A store host from before this leaf has no file until `swarm-bao-pki` next runs, and its wrapper sets no client certificate | nothing to place: the leaf is for the shell on the store's host and is never copied to another host |
|
| the operator's store leaf (cert + key) | `signLeaf` in `glue-bao-tls.nix` (`swarm-bao-pki.service`), on every host that runs the secret store, once, subject `deploy.bao.operatorCommonName`. No cert-auth role accepts that subject, so the leaf opens the TLS handshake and logs in to nothing | `/var/lib/swarm-bao-pki/operator.pem` and `operator-key.pem` on the host, `0600` root; the host's `bao` wrapper presents it when the host runs no hive, via `deploy.bao.operatorClientCertFile` / `operatorClientKeyFile`. A store host from before this leaf has no file until `swarm-bao-pki` next runs, and its wrapper sets no client certificate | nothing to place: the leaf is for the shell on the store's host and is never copied to another host |
|
||||||
| the swarm controller's copy of its OIDC secret | `swarm-controller` reads it out of the swarm secret store at start, under its own leaf | the daemon's memory only; never on disk | same read, co-located or not. Nothing for an operator to place beyond the controller's store leaf (`deploy.swarm-controller.baoClientCertFile`) |
|
| the swarm controller's copy of its OIDC secret | `swarm-controller` reads it out of the swarm secret store at start, under its own leaf | the daemon's memory only; never on disk | same read, co-located or not. Nothing for an operator to place beyond the controller's store leaf (`deploy.swarm-controller.baoClientCertFile`) |
|
||||||
| 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`) |
|
| 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 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 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 | `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 |
|
||||||
| 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 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 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) |
|
| 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 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 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, 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 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 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 |
|
| 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 |
|
| 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 |
|
||||||
| authelia subject store | `swarmctl` and `swarm-authelia-bridge` | `users.yml` — one file, read and written by both | `swarmctl`, on the host that runs authelia |
|
| authelia subject store | `swarmctl` and `swarm-authelia-bridge` | `users.yml` — one file, read and written by both | `swarmctl`, on the host that runs authelia |
|
||||||
| queue auth-callout nkeys (user seed + account seed) | `swarm-nats-auth ensure-callout-keys`, run by the pod's `callout-config` init container under the `swarm-nats-auth` jwt role when the store holds no seed | the swarm secret store: the seeds at `swarm/services/swarm-nats/callout/{user,issuer}-seed`, read by the `swarm-nats-auth` role alone; the public halves at `swarm/public/swarm-nats/callout-{user,issuer}` | nothing to place beyond the responder's store leaf (`deploy.nats.authBaoClientCertFile`) |
|
| queue auth-callout nkeys (user seed + account seed) | `swarm-nats-auth ensure-callout-keys`, run by the pod's `callout-config` init container under the `swarm-nats-auth` jwt role when the store holds no seed | the swarm secret store: the seeds at `swarm/services/swarm-nats/callout/{user,issuer}-seed`, read by the `swarm-nats-auth` role alone; the public halves at `swarm/public/swarm-nats/callout-{user,issuer}` | nothing to place beyond the responder's store leaf (`deploy.nats.authBaoClientCertFile`) |
|
||||||
| queue auth-callout xkey (curve seed) | `swarm-nats-auth ensure-callout-keys`, run by the pod's `callout-config` init container under the `swarm-nats-auth` jwt role when the store holds no seed | the swarm secret store: the seed at `swarm/services/swarm-nats/callout/xkey-seed`, read by the `swarm-nats-auth` role alone; the public half at `swarm/public/swarm-nats/callout-xkey` | nothing to place beyond the responder's store leaf (`deploy.nats.authBaoClientCertFile`) |
|
| queue auth-callout xkey (curve seed) | `swarm-nats-auth ensure-callout-keys`, run by the pod's `callout-config` init container under the `swarm-nats-auth` jwt role when the store holds no seed | the swarm secret store: the seed at `swarm/services/swarm-nats/callout/xkey-seed`, read by the `swarm-nats-auth` role alone; the public half at `swarm/public/swarm-nats/callout-xkey` | nothing to place beyond the responder's store leaf (`deploy.nats.authBaoClientCertFile`) |
|
||||||
| the queue's TLS key, copied for the gateway's `/metrics` vhost | `swarm-nats-gateway-cert.service` on the queue's host, where the gateway uses self-signed TLS: a copy of the queue's bao-PKI TLS leaf (`/var/lib/swarm-nats-tls/`) once `swarm-bao-nats-tls` has issued it, else a throwaway 30-day self-signed pair for the queue's name until then | `/var/lib/swarm-nats-gateway-tls/{cert,key}.pem`; the key is `0640` group `nginx`, read by nginx for the queue's `/metrics` vhost. The queue's own key stays `0600` root | the copy is redone on each leaf renewal (`swarm-bao-nats-tls` starts the unit, which queues a non-blocking nginx reload when nginx is running); a restart before any leaf exists keeps the pair already there. Until `swarm-bao-nats-tls` issues the leaf the vhost serves the throwaway cert, so the collector's scrape fails TLS. Nothing for an operator to place |
|
| the queue's TLS key, copied for the gateway's `/metrics` vhost | `swarm-nats-gateway-cert.service` on the queue's host, where the gateway uses self-signed TLS: a copy of the queue's bao-PKI TLS leaf (`/var/lib/swarm-nats-tls/`) once `swarm-bao-nats-tls` has issued it, else a throwaway 30-day self-signed pair for the queue's name until then | `/var/lib/swarm-nats-gateway-tls/{cert,key}.pem`; the key is `0640` group `nginx`, read by nginx for the queue's `/metrics` vhost. The queue's own key stays `0600` root | the copy is redone on each leaf renewal (`swarm-bao-nats-tls` starts the unit, which queues a non-blocking nginx reload when nginx is running); a restart before any leaf exists keeps the pair already there. Until `swarm-bao-nats-tls` issues the leaf the vhost serves the throwaway cert, so the collector's scrape fails TLS. Nothing for an operator to place |
|
||||||
| the queue pod's TLS leaf and key | the pod's `tls-issue` init container: it logs in with the pod's ServiceAccount token as the store's `swarm-nats` jwt role, which has the policy of the `swarm-nats` cert role, and issues one name, `swarm.nats.domain`. The host keeps `swarm-bao-nats-tls`, which issues its own copy for the gateway's `/metrics` vhost and restarts no server | `/var/lib/swarm-nats-tls/{cert,key}.pem` in an in-memory `emptyDir` (`medium: Memory`), gone with the pod. The server reads both as it starts and again on `SIGHUP`; the key never reaches the node's disk | the pod's `tls-renew` container repeats the check every five minutes, issues a new leaf once the old one is past half its 30 days and signals the server, so a long-running pod needs nothing. Nothing to place: the pod's account is the credential |
|
| the queue pod's TLS leaf and key | the pod's `tls-issue` init container: it logs in with the pod's ServiceAccount token as the store's `swarm-nats` jwt role, which has the policy of the `swarm-nats` cert role, and issues one name, `swarm.nats.domain`. The host keeps `swarm-bao-nats-tls`, which issues its own copy for the gateway's `/metrics` vhost and restarts no server | `/var/lib/swarm-nats-tls/{cert,key}.pem` in an in-memory `emptyDir` (`medium: Memory`), gone with the pod. The server reads both as it starts and again on `SIGHUP`; the key never reaches the node's disk | the pod's `tls-renew` container repeats the check every five minutes, issues a new leaf once the old one is past half its 30 days and signals the server, so a long-running pod needs nothing. Nothing to place: the pod's account is the credential |
|
||||||
| the controller's TCP listener certificate and key | the pod's init container, while `swarm.controller.tcp.enable` is on (the default). It issues the leaf into an in-memory `emptyDir` from the store's `swarm-controller-tls` role under its ServiceAccount token: one name, `swarm.controller.tcp.domain`, `serverAuth` only. Its `tls-renew` container repeats the same check daily, because nothing rolls the pod before the leaf expires | `<deploy.swarm-controller.tcp.tlsDir>/{cert,key}.pem` (`/var/lib/swarm-controller-tls`) in the pod, in an in-memory `emptyDir` (`medium: Memory`), gone with the pod. The daemon re-reads both when they change, so a rotation restarts nothing. A store host that leaves the option off has no role to issue from, and the init container fails with the store's refusal naming it | Nothing to place: the controller's own store leaf is the one it already holds |
|
| the controller's TCP listener certificate and key | the pod's init container, while `swarm.controller.tcp.enable` is on (the default). It issues the leaf into an in-memory `emptyDir` from the store's `swarm-controller-tls` role under its ServiceAccount token: one name, `swarm.controller.tcp.domain`, `serverAuth` only. Its `tls-renew` container repeats the same check daily, because nothing rolls the pod before the leaf expires | `<deploy.swarm-controller.tcp.tlsDir>/{cert,key}.pem` (`/var/lib/swarm-controller-tls`) in the pod, in an in-memory `emptyDir` (`medium: Memory`), gone with the pod. The daemon re-reads both when they change, so a rotation restarts nothing. A store host that leaves the option off has no role to issue from, and the init container fails with the store's refusal naming it | Nothing to place: the controller's own store leaf is the one it already holds |
|
||||||
| the gateway's client certificate for the controller's TCP listener | `swarm-controller-gateway-client.service` on the host that runs the controller, while `swarm.controller.tcp.enable` is on (the default). It logs in under the services-issuer identity and issues from the store's `swarm-controller-gateway-client` role: one name, `gateway-client.<swarm.domain>`, `clientAuth` only, so the services leaf can't stand in for it. A daily timer renews it | `<deploy.hive-controller.tls.stateDir>/controller-client.pem` and `controller-client-key.pem`, the key `0640` group `nginx`; the gateway's controller locations name them in `proxy_ssl_certificate`. Until the store answers, a throwaway self-signed pair keeps nginx's config loadable. The listener refuses that pair, so those locations answer 502. Every holder of the services-issuer identity can obtain this leaf: the listener trusts "a gateway of this swarm" | Nothing to place: the services-issuer identity is the one every gateway host already holds |
|
| the gateway's client certificate for the controller's TCP listener | `swarm-controller-gateway-client.service` on the host that runs the controller, while `swarm.controller.tcp.enable` is on (the default). It logs in under the services-issuer identity and issues from the store's `swarm-controller-gateway-client` role: one name, `gateway-client.<swarm.domain>`, `clientAuth` only, so the services leaf can't stand in for it. A daily timer renews it | `<deploy.hive-controller.tls.stateDir>/controller-client.pem` and `controller-client-key.pem`, the key `0640` group `nginx`; the gateway's controller locations name them in `proxy_ssl_certificate`. Until the store answers, a throwaway self-signed pair keeps nginx's config loadable. The listener refuses that pair, so those locations answer 502. Every holder of the services-issuer identity can obtain this leaf: the listener trusts "a gateway of this swarm" | Nothing to place: the services-issuer identity is the one every gateway host already holds |
|
||||||
| the secret store's own contents | openbao, on first `bao operator init` — **an operator action, not a unit** | inside the `swarm-bao` container, at its own `/var/lib/openbao`, kept across rebuilds by `ephemeral = false`. ⚠️ **Not a host path**: `nixos-container destroy swarm-bao` takes the raft data with it, so back up the container's tree, not `/var/lib/`. Only the store's TLS material (`/var/lib/swarm-bao-tls`) and its PKCS11 token (`/var/lib/swarm-bao-token`) are host-level | n/a — there is one store; a hive elsewhere is a _client_ of it and holds none of this |
|
| the secret store's own contents | openbao, on first `bao operator init` — **an operator action, not a unit** | inside the `swarm-bao` container, at its own `/var/lib/openbao`, kept across rebuilds by `ephemeral = false`. ⚠️ **Not a host path**: `nixos-container destroy swarm-bao` takes the raft data with it, so back up the container's tree, not `/var/lib/`. Only the store's TLS material (`/var/lib/swarm-bao-tls`) and its PKCS11 token (`/var/lib/swarm-bao-token`) are host-level | n/a — there is one store; a hive elsewhere is a _client_ of it and holds none of this |
|
||||||
| the secret store's unseal material | the HSM/TPM under `deploy.bao.seal = "pkcs11"`; openbao itself under `"shamir"` | in the token; or held by whoever ran `bao operator init`, which is what `"shamir"` means and why it's stated rather than inferred | n/a — only the host running the store seals anything |
|
| the secret store's unseal material | the HSM/TPM under `deploy.bao.seal = "pkcs11"`; openbao itself under `"shamir"` | in the token; or held by whoever ran `bao operator init`, which is what `"shamir"` means and why it's stated rather than inferred | n/a — only the host running the store seals anything |
|
||||||
| a cluster pod's store login token (a ServiceAccount token) | the cluster's API server, which signs it for the pod's account and the audience `bao`. The kubelet projects it into the pod and rewrites it before it expires | `/var/run/secrets/hyperhive/bao/token` in the pod. The store accepts it at its `jwt-k8s` mount, for the role of that account only, against the public halves of the node's signing keys, which `swarm-bao-k8s-jwt-policy` derives from the key files. A node whose signing keys changed needs that unit restarted, and tokens signed with the old key fail to log in meanwhile | Nothing to place: the pods and the store run on the cluster's one host |
|
| a cluster pod's store login token (a ServiceAccount token) | the cluster's API server, which signs it for the pod's account and the audience `bao`. The kubelet projects it into the pod and rewrites it before it expires | `/var/run/secrets/hyperhive/bao/token` in the pod. The store accepts it at its `jwt-k8s` mount, for the role of that account only, against the public halves of the node's signing keys, which `swarm-bao-k8s-jwt-policy` derives from the key files. A node whose signing keys changed needs that unit restarted, and tokens signed with the old key fail to log in meanwhile | Nothing to place: the pods and the store run on the cluster's one host |
|
||||||
| the k3s join token | `k3s-join-token-publish` on the main node writes `swarm/services/k8s/agent-token` from the file k3s keeps | `/run/k3s-join/token` (tmpfs, root, `0400`) on a node with `deploy.k8s.join`, which `k3s-join-token` fills from the store under that host's own hive identity and k3s reads as its token | A different token than the server's: the node fails to register and k3s retries. The server's file wins: the main node's unit rewrites the leaf at its next k3s start, and the joining node's next k3s start reads it. A node that isn't a NixOS host gets the token from an admin, who reads the leaf (`docs/4-implementation/k8s/node.md`) |
|
| the k3s join token | `k3s-join-token-publish` on the main node writes `swarm/services/k8s/agent-token` from the file k3s keeps | `/run/k3s-join/token` (tmpfs, root, `0400`) on a node with `deploy.k8s.join`, which `k3s-join-token` fills from the store under that host's own hive identity and k3s reads as its token | A different token than the server's: the node fails to register and k3s retries. The server's file wins: the main node's unit rewrites the leaf at its next k3s start, and the joining node's next k3s start reads it. A node that isn't a NixOS host gets the token from an admin, who reads the leaf (`docs/4-implementation/k8s/node.md`) |
|
||||||
|
|
||||||
### Hive-level — one of each per hive
|
### Hive-level — one of each per hive
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ let
|
||||||
storeAuth = import ../lib/store-auth.nix;
|
storeAuth = import ../lib/store-auth.nix;
|
||||||
storeRetry = import ../lib/store-retry.nix { };
|
storeRetry = import ../lib/store-retry.nix { };
|
||||||
|
|
||||||
|
# The gateway's group: nginx's master and workers run as its user, and read
|
||||||
|
# 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 stores this host runs, by the name `store-auth.nix` takes.
|
||||||
stores =
|
stores =
|
||||||
lib.optional deployCfg.victorialogs.enable "victorialogs"
|
lib.optional deployCfg.victorialogs.enable "victorialogs"
|
||||||
|
|
@ -59,16 +63,22 @@ in
|
||||||
config = lib.mkIf (stores != [ ] || exporterOn) (
|
config = lib.mkIf (stores != [ ] || exporterOn) (
|
||||||
lib.mkMerge [
|
lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
# The group exists on a host where the NixOS nginx unit is off too, since
|
||||||
|
# the files below are made with it.
|
||||||
|
users.groups.${nginxGroup} = { };
|
||||||
|
|
||||||
# The files exist before nginx first reads its configuration, because
|
# The files exist before nginx first reads its configuration, because
|
||||||
# an `include` of a missing file is a fatal error there. `f` creates
|
# an `include` of a missing file is a fatal error there. `f` creates
|
||||||
# a file and never overwrites one, and an empty file sets no header:
|
# a file and never overwrites one, and an empty file sets no header:
|
||||||
# the store then refuses the request, which is the only thing a
|
# the store then refuses the request, which is the only thing a
|
||||||
# gateway without the credential can get from it.
|
# gateway without the credential can get from it. The directory and
|
||||||
|
# the nginx files are the gateway's group's to read, which nginx needs
|
||||||
|
# to start; the passwords and the hash stay in files only root reads.
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d ${storeAuth.dir} 0700 root root - -"
|
"d ${storeAuth.dir} 0750 root ${nginxGroup} - -"
|
||||||
]
|
]
|
||||||
++ map (store: "f ${storeAuth.nginxFile store} 0600 root root -") stores
|
++ map (store: "f ${storeAuth.nginxFile store} 0640 root ${nginxGroup} -") stores
|
||||||
++ lib.optional exporterOn "f ${exporter.nginxFile} 0600 root root -";
|
++ lib.optional exporterOn "f ${exporter.nginxFile} 0640 root ${nginxGroup} -";
|
||||||
}
|
}
|
||||||
|
|
||||||
(lib.mkIf (node.enable && k8sCfg.enable) {
|
(lib.mkIf (node.enable && k8sCfg.enable) {
|
||||||
|
|
@ -137,7 +147,7 @@ in
|
||||||
${import ../lib/atomic-write-secret.nix { }}
|
${import ../lib/atomic-write-secret.nix { }}
|
||||||
${import ../lib/refresh-consumer.nix { }}
|
${import ../lib/refresh-consumer.nix { }}
|
||||||
|
|
||||||
install -d -m 0700 ${storeAuth.dir}
|
install -d -m 0750 -o root -g ${lib.escapeShellArg nginxGroup} ${storeAuth.dir}
|
||||||
|
|
||||||
# A password of 64 hex digits, as Grafana's bearer is.
|
# A password of 64 hex digits, as Grafana's bearer is.
|
||||||
mint_password() {
|
mint_password() {
|
||||||
|
|
@ -160,11 +170,14 @@ in
|
||||||
directive="proxy_set_header Authorization \"Basic $(printf '%s:%s' "$user" "$password" | base64 -w0)\";"
|
directive="proxy_set_header Authorization \"Basic $(printf '%s:%s' "$user" "$password" | base64 -w0)\";"
|
||||||
|
|
||||||
if secret_differs "$nginx_file" "$directive"; then
|
if secret_differs "$nginx_file" "$directive"; then
|
||||||
atomic_write_secret 0600 root:root "$nginx_file" "$directive"
|
atomic_write_secret 0640 root:${nginxGroup} "$nginx_file" "$directive"
|
||||||
reload=1
|
reload=1
|
||||||
elif written_after_start nginx.service "$nginx_file"; then
|
elif written_after_start nginx.service "$nginx_file"; then
|
||||||
reload=1
|
reload=1
|
||||||
fi
|
fi
|
||||||
|
# A file that already holds the value keeps the owner it was written with.
|
||||||
|
chown root:${nginxGroup} "$nginx_file"
|
||||||
|
chmod 0640 "$nginx_file"
|
||||||
if secret_differs "$password_file" "$password"; then
|
if secret_differs "$password_file" "$password"; then
|
||||||
atomic_write_secret 0600 root:root "$password_file" "$password"
|
atomic_write_secret 0600 root:root "$password_file" "$password"
|
||||||
password_changed=1
|
password_changed=1
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ rec {
|
||||||
# `victorialogs` or `victoriametrics`.
|
# `victorialogs` or `victoriametrics`.
|
||||||
leaf = store: "swarm/services/${store}/store-auth";
|
leaf = store: "swarm/services/${store}/store-auth";
|
||||||
|
|
||||||
# On the host, a directory only root reads: the password the Secret is made from,
|
# On the host, a directory for root and the gateway's group (`0750`): the nginx
|
||||||
# and the nginx file the gateway's locations include.
|
# file the gateway's locations include, which the group reads (`0640`), and the
|
||||||
|
# password the Secret is made from, which only root reads.
|
||||||
dir = "/var/lib/swarm-store-auth";
|
dir = "/var/lib/swarm-store-auth";
|
||||||
passwordFile = store: "${dir}/${store}.password";
|
passwordFile = store: "${dir}/${store}.password";
|
||||||
nginxFile = store: "${dir}/${store}.conf";
|
nginxFile = store: "${dir}/${store}.conf";
|
||||||
|
|
|
||||||
|
|
@ -2256,7 +2256,7 @@ let
|
||||||
let
|
let
|
||||||
h = allLocal.services.hyperhive;
|
h = allLocal.services.hyperhive;
|
||||||
unit = allLocal.systemd.services.swarm-bao-store-auth;
|
unit = allLocal.systemd.services.swarm-bao-store-auth;
|
||||||
rule = store: "f /var/lib/swarm-store-auth/${store}.conf 0600 root root -";
|
rule = store: "f /var/lib/swarm-store-auth/${store}.conf 0640 root nginx -";
|
||||||
# One store's vhost: every location that dials it includes the file,
|
# One store's vhost: every location that dials it includes the file,
|
||||||
# and no other location does.
|
# and no other location does.
|
||||||
vhost =
|
vhost =
|
||||||
|
|
@ -2348,10 +2348,20 @@ let
|
||||||
&& hasInfix "store-auth.pem" h.deploy.bao.storeAuthClientCertFile
|
&& hasInfix "store-auth.pem" h.deploy.bao.storeAuthClientCertFile
|
||||||
&& lib.elem (rule "victorialogs") allLocal.systemd.tmpfiles.rules
|
&& lib.elem (rule "victorialogs") allLocal.systemd.tmpfiles.rules
|
||||||
&& lib.elem (rule "victoriametrics") allLocal.systemd.tmpfiles.rules
|
&& lib.elem (rule "victoriametrics") allLocal.systemd.tmpfiles.rules
|
||||||
|
# nginx runs as `User=nginx`: the directory and the nginx files are its
|
||||||
|
# group's to read, written that way and fixed when they already hold the
|
||||||
|
# value, and the passwords stay root's.
|
||||||
|
&& lib.elem "d /var/lib/swarm-store-auth 0750 root nginx - -" allLocal.systemd.tmpfiles.rules
|
||||||
|
&& hasInfix "install -d -m 0750 -o root -g nginx /var/lib/swarm-store-auth" unit.script
|
||||||
|
&& hasInfix ''atomic_write_secret 0640 root:nginx "$nginx_file" "$directive"'' unit.script
|
||||||
|
&& hasInfix ''chown root:nginx "$nginx_file"'' unit.script
|
||||||
|
&& hasInfix ''chmod 0640 "$nginx_file"'' unit.script
|
||||||
|
&& hasInfix ''atomic_write_secret 0600 root:root "$password_file" "$password"'' unit.script
|
||||||
# Without either store there is no unit, no file and no location.
|
# Without either store there is no unit, no file and no location.
|
||||||
&& !(noNode.systemd.services ? swarm-bao-store-auth)
|
&& !(noNode.systemd.services ? swarm-bao-store-auth)
|
||||||
&& !(lib.elem (rule "victorialogs") noNode.systemd.tmpfiles.rules)
|
&& !(lib.elem (rule "victorialogs") noNode.systemd.tmpfiles.rules)
|
||||||
&& !(lib.elem (rule "victoriametrics") noNode.systemd.tmpfiles.rules)
|
&& !(lib.elem (rule "victoriametrics") noNode.systemd.tmpfiles.rules)
|
||||||
|
&& !(lib.elem "d /var/lib/swarm-store-auth 0750 root nginx - -" noNode.systemd.tmpfiles.rules)
|
||||||
&& !(noNode.services.nginx.virtualHosts ? ${h.swarm.victorialogs.domain})
|
&& !(noNode.services.nginx.virtualHosts ? ${h.swarm.victorialogs.domain})
|
||||||
&& !(noNode.services.nginx.virtualHosts ? ${h.swarm.victoriametrics.domain});
|
&& !(noNode.services.nginx.virtualHosts ? ${h.swarm.victoriametrics.domain});
|
||||||
}
|
}
|
||||||
|
|
@ -2369,7 +2379,7 @@ let
|
||||||
flag: lib.elemAt exporter.args ((lib.lists.findFirstIndex (a: a == flag) (-1) exporter.args) + 1);
|
flag: lib.elemAt exporter.args ((lib.lists.findFirstIndex (a: a == flag) (-1) exporter.args) + 1);
|
||||||
locations = allLocal.services.nginx.virtualHosts.${h.swarm.nats.domain}.locations;
|
locations = allLocal.services.nginx.virtualHosts.${h.swarm.nats.domain}.locations;
|
||||||
include = "include /var/lib/swarm-store-auth/nats.conf;";
|
include = "include /var/lib/swarm-store-auth/nats.conf;";
|
||||||
rule = "f /var/lib/swarm-store-auth/nats.conf 0600 root root -";
|
rule = "f /var/lib/swarm-store-auth/nats.conf 0640 root nginx -";
|
||||||
in
|
in
|
||||||
after "-http_user" == "swarm-exporter"
|
after "-http_user" == "swarm-exporter"
|
||||||
# The argument is the variable Kubernetes substitutes, and the Secret it
|
# The argument is the variable Kubernetes substitutes, and the Secret it
|
||||||
|
|
|
||||||
|
|
@ -826,9 +826,9 @@ pkgs.testers.runNixOSTest {
|
||||||
assert password not in kube(machine, f"get pod {pod_name} -o json")
|
assert password not in kube(machine, f"get pod {pod_name} -o json")
|
||||||
assert machine.succeed(f"stat -c '%a %U %G' {EXPORTER_PASSWORD} {EXPORTER_CONF} {EXPORTER_HASH_FILE} {STORE_AUTH_DIR}").split("\n")[:4] == [
|
assert machine.succeed(f"stat -c '%a %U %G' {EXPORTER_PASSWORD} {EXPORTER_CONF} {EXPORTER_HASH_FILE} {STORE_AUTH_DIR}").split("\n")[:4] == [
|
||||||
"600 root root",
|
"600 root root",
|
||||||
|
"640 root nginx",
|
||||||
"600 root root",
|
"600 root root",
|
||||||
"600 root root",
|
"750 root nginx",
|
||||||
"700 root root",
|
|
||||||
]
|
]
|
||||||
login = base64.b64encode(f"swarm-exporter:{password}".encode()).decode()
|
login = base64.b64encode(f"swarm-exporter:{password}".encode()).decode()
|
||||||
assert machine.succeed(f"cat {EXPORTER_CONF}").strip() == f'proxy_set_header Authorization "Basic {login}";'
|
assert machine.succeed(f"cat {EXPORTER_CONF}").strip() == f'proxy_set_header Authorization "Basic {login}";'
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,13 @@ pkgs.testers.runNixOSTest {
|
||||||
# which needs certificates this host does not mint, so a second nginx
|
# which needs certificates this host does not mint, so a second nginx
|
||||||
# carries the passthrough alone, as `k8s-bao-login` does.
|
# carries the passthrough alone, as `k8s-bao-login` does.
|
||||||
services.nginx.enable = lib.mkForce false;
|
services.nginx.enable = lib.mkForce false;
|
||||||
|
# The user the module would create: the stub gateway below runs as it, so a
|
||||||
|
# file it includes has to be the gateway's to read, as under the real unit
|
||||||
|
# (`User = cfg.user`).
|
||||||
|
users.users.nginx = {
|
||||||
|
isSystemUser = true;
|
||||||
|
group = "nginx";
|
||||||
|
};
|
||||||
networking.hosts."${bridgeIp}" = [
|
networking.hosts."${bridgeIp}" = [
|
||||||
baoName
|
baoName
|
||||||
natsName
|
natsName
|
||||||
|
|
@ -510,16 +517,20 @@ pkgs.testers.runNixOSTest {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
User = "nginx";
|
||||||
|
Group = "nginx";
|
||||||
RuntimeDirectory = "logs-gateway-test";
|
RuntimeDirectory = "logs-gateway-test";
|
||||||
ExecStart = "${pkgs.nginx}/bin/nginx -c ${gatewayConf config} -g 'daemon off;'";
|
ExecStart = "${pkgs.nginx}/bin/nginx -e stderr -c ${gatewayConf config} -g 'daemon off;'";
|
||||||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = 2;
|
RestartSec = 2;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.etc."logs-gateway.conf".source = gatewayConf config;
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.kubectl
|
pkgs.kubectl
|
||||||
|
pkgs.nginx
|
||||||
pkgs.curl
|
pkgs.curl
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
pkgs.openssl
|
pkgs.openssl
|
||||||
|
|
@ -1095,7 +1106,7 @@ pkgs.testers.runNixOSTest {
|
||||||
assert machine.succeed(f"cat {STORE_PASSWORD}").strip() == stored
|
assert machine.succeed(f"cat {STORE_PASSWORD}").strip() == stored
|
||||||
secret = machine.succeed(f"kubectl -n {NS} get secret swarm-victorialogs-credentials -o jsonpath='{{.data.store-auth}}' | base64 -d").strip()
|
secret = machine.succeed(f"kubectl -n {NS} get secret swarm-victorialogs-credentials -o jsonpath='{{.data.store-auth}}' | base64 -d").strip()
|
||||||
assert secret == stored
|
assert secret == stored
|
||||||
assert machine.succeed(f"stat -c '%a %U %G' {STORE_PASSWORD} {STORE_CONF} {STORE_AUTH_DIR}").split("\n")[:3] == ["600 root root", "600 root root", "700 root root"]
|
assert machine.succeed(f"stat -c '%a %U %G' {STORE_PASSWORD} {STORE_CONF} {STORE_AUTH_DIR}").split("\n")[:3] == ["600 root root", "640 root nginx", "750 root nginx"]
|
||||||
assert stored not in machine.succeed(f"cat {MANIFESTS}/{VL}.yaml"), "the manifest holds no credential"
|
assert stored not in machine.succeed(f"cat {MANIFESTS}/{VL}.yaml"), "the manifest holds no credential"
|
||||||
# Insert, select, a delete route, the admin routes, the store's own
|
# Insert, select, a delete route, the admin routes, the store's own
|
||||||
# metrics and the UI answer 401 with no credential and with a caller's
|
# metrics and the UI answer 401 with no credential and with a caller's
|
||||||
|
|
@ -1159,6 +1170,26 @@ pkgs.testers.runNixOSTest {
|
||||||
assert machine.succeed(f"cat {STORE_CONF}") == saved
|
assert machine.succeed(f"cat {STORE_CONF}") == saved
|
||||||
wait_for_record(AGENT_TOKEN, "switch", "written before the switch")
|
wait_for_record(AGENT_TOKEN, "switch", "written before the switch")
|
||||||
|
|
||||||
|
with subtest("the gateway's user reads the credential file and not the password, and a file only root reads keeps nginx from loading its configuration"):
|
||||||
|
# The stub gateway runs as the user the module's nginx unit runs as
|
||||||
|
# (`User = cfg.user`), so what it includes has to be that user's to read.
|
||||||
|
nginx_check = "runuser -u nginx -- ${pkgs.nginx}/bin/nginx -e stderr -t -c /etc/logs-gateway.conf 2>&1"
|
||||||
|
assert machine.succeed("systemctl show --property=User --value logs-gateway").strip() == "nginx"
|
||||||
|
machine.succeed(f"runuser -u nginx -- cat {STORE_CONF}")
|
||||||
|
machine.fail(f"runuser -u nginx -- cat {STORE_PASSWORD}")
|
||||||
|
machine.succeed(nginx_check)
|
||||||
|
# Control: the same file owned and moded as it was, root's alone.
|
||||||
|
machine.succeed(f"chown root:root {STORE_CONF} && chmod 0600 {STORE_CONF}")
|
||||||
|
status, out = machine.execute(nginx_check)
|
||||||
|
assert status != 0 and f'open() "{STORE_CONF}" failed (13: Permission denied)' in out, (status, out)
|
||||||
|
# The unit finds the value right and the owner wrong, and puts it back.
|
||||||
|
machine.succeed("systemctl restart swarm-bao-store-auth.service")
|
||||||
|
store_credential_published()
|
||||||
|
assert machine.succeed(f"stat -c '%a %U %G' {STORE_CONF}").strip() == "640 root nginx"
|
||||||
|
machine.succeed(nginx_check)
|
||||||
|
machine.succeed("systemctl reload logs-gateway")
|
||||||
|
machine.wait_until_succeeds("systemctl is-active logs-gateway", timeout=30)
|
||||||
|
|
||||||
with subtest("a record posted to the ingest route and the store's own metrics come through the gateway, and a restarted pod still holds both records"):
|
with subtest("a record posted to the ingest route and the store's own metrics come through the gateway, and a restarted pod still holds both records"):
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
|
@ -1485,7 +1516,7 @@ pkgs.testers.runNixOSTest {
|
||||||
assert machine.succeed(f"cat {VM_PASSWORD}").strip() == stored
|
assert machine.succeed(f"cat {VM_PASSWORD}").strip() == stored
|
||||||
secret = machine.succeed(f"kubectl -n {NS} get secret swarm-victoriametrics-credentials -o jsonpath='{{.data.store-auth}}' | base64 -d").strip()
|
secret = machine.succeed(f"kubectl -n {NS} get secret swarm-victoriametrics-credentials -o jsonpath='{{.data.store-auth}}' | base64 -d").strip()
|
||||||
assert secret == stored
|
assert secret == stored
|
||||||
assert machine.succeed(f"stat -c '%a %U %G' {VM_PASSWORD} {VM_CONF}").split("\n")[:2] == ["600 root root", "600 root root"]
|
assert machine.succeed(f"stat -c '%a %U %G' {VM_PASSWORD} {VM_CONF}").split("\n")[:2] == ["600 root root", "640 root nginx"]
|
||||||
assert stored not in machine.succeed(f"cat {MANIFESTS}/{VM}.yaml"), "the manifest holds no credential"
|
assert stored not in machine.succeed(f"cat {MANIFESTS}/{VM}.yaml"), "the manifest holds no credential"
|
||||||
# Writes, imports, queries, exports, the routes that delete and
|
# Writes, imports, queries, exports, the routes that delete and
|
||||||
# snapshot, the config and reload routes, the store's own metrics and
|
# snapshot, the config and reload routes, the store's own metrics and
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue