the queue's exporter asks every request for a login the gateway supplies
This commit is contained in:
parent
9b12532fc1
commit
da53e19636
1 changed files with 488 additions and 133 deletions
|
|
@ -26,6 +26,7 @@ let
|
|||
machine = "swarm-nats";
|
||||
|
||||
labels = import ./k8s/labels.nix;
|
||||
storeAuth = import ./lib/store-auth.nix;
|
||||
|
||||
# The container's journal forwarder pushes to its own receiver on the swarm
|
||||
# collector, the route `serviceProducers.swarm-nats` in
|
||||
|
|
@ -1006,7 +1007,30 @@ let
|
|||
(toString deployCfg.nats.metricsPort)
|
||||
]
|
||||
++ exporterFlags
|
||||
++ [ monitorUrl ];
|
||||
++ [
|
||||
# Every request to `/metrics` needs this login. The exporter takes
|
||||
# the password only on its command line and compares it as bcrypt
|
||||
# for a value that starts with `$2a$`, so the argument is the hash
|
||||
# the host's unit publishes (./k8s/store-credentials.nix), which
|
||||
# Kubernetes substitutes from the environment. The gateway's
|
||||
# `/metrics` location sends the password. A Secret that does not
|
||||
# exist keeps the container from starting; it does not leave the
|
||||
# exporter open.
|
||||
"-http_user"
|
||||
storeAuth.exporter.user
|
||||
"-http_pass"
|
||||
"$(${storeAuth.exporter.hashEnv})"
|
||||
monitorUrl
|
||||
];
|
||||
env = [
|
||||
{
|
||||
name = storeAuth.exporter.hashEnv;
|
||||
valueFrom.secretKeyRef = {
|
||||
name = storeAuth.exporter.secretName;
|
||||
key = storeAuth.exporter.hashKey;
|
||||
};
|
||||
}
|
||||
];
|
||||
# The port the metrics Service targets.
|
||||
ports = [
|
||||
{
|
||||
|
|
@ -1049,9 +1073,10 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
# The exporter answers a request with every client's name, so only the
|
||||
# node may read it: the Service is reached by name from the host's
|
||||
# gateway, and the policy admits the node's own traffic (which the
|
||||
# The exporter answers a request with every client's name, so it asks every
|
||||
# request for a login (`-http_user`, `-http_pass` above) and only the node
|
||||
# reaches it: the Service is reached by name from the host's gateway, which
|
||||
# sends the login, and the policy admits the node's own traffic (which the
|
||||
# cluster's policy engine always lets in, ./k8s/render.nix) and, from
|
||||
# anywhere else, the client port alone.
|
||||
objects."${machine}/service" = {
|
||||
|
|
@ -1177,7 +1202,8 @@ in
|
|||
the swarm collector's authelia check.
|
||||
|
||||
This is the exporter container's port in the pod, which the Service `swarm-nats-metrics` publishes on the same
|
||||
number and only the node reaches.
|
||||
number. Only the node reaches it, and it answers a request only with the
|
||||
login in `lib/store-auth.nix`.
|
||||
|
||||
⚠️ This and {option}`services.hyperhive.deploy.nats.monitorPort` are two
|
||||
more claims on a port
|
||||
|
|
@ -1399,6 +1425,9 @@ in
|
|||
resolver ${networkCfg.bridgeIp} valid=10s ipv6=off;
|
||||
set $swarm_nats_metrics_upstream ${metricsHost}:${toString deployCfg.nats.metricsPort};
|
||||
auth_request /__nats_metrics_authz;
|
||||
# The exporter's login in place of the caller's `Authorization`;
|
||||
# an empty file sends none and the exporter answers 401.
|
||||
include ${storeAuth.exporter.nginxFile};
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue