# What the Victoria stores' listener credential is, where it lives, and who # names it. The store's pod, the gateway's vhost and the unit that mints and # publishes it (../k8s/store-credentials.nix) all spell it from here. # # The credential is the HTTP Basic login every route of the store's listener # asks for (`-httpAuth.username` and `-httpAuth.password`). The password is a # leaf of the swarm secret store, created by that unit when the store holds # none. The pod reads it from the Secret `secretName`; nginx sends it in the # `Authorization` header that `nginxFile` sets. rec { # The Basic login's user name, the same for every store. user = "swarm-store"; # The credential id the store's unit loads and the key of the Secret that # holds the password. credentialId = "store-auth"; # Under KV v2's `secret/` mount, as `bao kv` takes it. `store` is # `victorialogs` or `victoriametrics`. leaf = store: "swarm/services/${store}/store-auth"; # On the host, a directory only root reads: the password the Secret is made from, # and the nginx file the gateway's locations include. dir = "/var/lib/swarm-store-auth"; passwordFile = store: "${dir}/${store}.password"; nginxFile = store: "${dir}/${store}.conf"; # The Secret the store's pod loads its credentials from # (../k8s/render.nix names it `-credentials`). secretName = store: "swarm-${store}-credentials"; # The queue's exporter takes the same kind of login, with a difference: its # flag takes no file, so the pod gets the password's bcrypt hash from the # Secret `exporter.secretName` (key `hashKey`, environment variable # `hashEnv`, argument `-http_pass`), and the gateway's `/metrics` location # for the queue sends the password itself in the header `exporter.nginxFile` # sets. The password and the hash are files only root reads. `cost` is NATS's # own default for `nats server passwd`; the exporter compares with # `bcrypt.CompareHashAndPassword`, which reads the cost from the hash, and # only for a value that starts with `$2a$`. exporter = { user = "swarm-exporter"; leaf = "swarm/services/nats/exporter-auth"; passwordFile = "${dir}/nats.password"; nginxFile = "${dir}/nats.conf"; hashFile = "${dir}/nats.hash"; secretName = "swarm-nats-exporter-auth"; hashKey = "hash"; hashEnv = "EXPORTER_HASH"; cost = 11; hashPrefix = "$2a$"; }; }