The Deployment swarm-grafana replaces the swarm-grafana container: one replica on a static local volume that is the container's data directory, an init container that fetches the OIDC client secret and creates the administrator password, the datasources' bearer and the encryption key in the secret store, and a sidecar that keeps the controller's Viewer token. The datasources reach the stores through the gateway with that bearer, and Grafana's /metrics asks for the stores' kind of credential, which the vhost sends. The five host units, the journal forwarder, its client glue and the unix-socket directory go with the container.
57 lines
2.6 KiB
Nix
57 lines
2.6 KiB
Nix
# What the listener credential of the Victoria stores and of Grafana is, where it lives, and who
|
|
# names it. The store's pod, the gateway's vhost and the unit that mints and
|
|
# publishes it (../k8s/store-credentials.nix) all spell it from here.
|
|
#
|
|
# 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.
|
|
#
|
|
# Grafana asks for the same login on `/metrics` alone (`[metrics] basic_auth_*`);
|
|
# its other routes take its own login.
|
|
rec {
|
|
# The Basic login's user name, the same for every store.
|
|
user = "swarm-store";
|
|
|
|
# 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`, `victoriametrics` or `grafana`.
|
|
leaf = store: "swarm/services/${store}/store-auth";
|
|
|
|
# On the host, a directory for root and the gateway's group (`0750`): the nginx
|
|
# 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";
|
|
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 `<service>-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$";
|
|
};
|
|
}
|