run the metrics store and its auth responders as pods
This commit is contained in:
parent
1606f1e9bb
commit
681426b53b
1 changed files with 1308 additions and 1031 deletions
|
|
@ -188,10 +188,6 @@ let
|
|||
machine = "hive-matrix";
|
||||
option = "matrix";
|
||||
}
|
||||
{
|
||||
machine = "swarm-victoriametrics";
|
||||
option = "victoriametrics";
|
||||
}
|
||||
];
|
||||
ownClientIdOf = h: svc: h.services.hyperhive.swarm.${svc.option}.otel.clientId;
|
||||
|
||||
|
|
@ -799,72 +795,6 @@ let
|
|||
ok =
|
||||
!shared.matrixNoBaoIdentity.containers.hive-matrix.config.services.opentelemetry-collector.enable;
|
||||
}
|
||||
{
|
||||
# The metrics store's container has no network: the forwarder dials the
|
||||
# relay on loopback and reads a secret the host fetched and bound in.
|
||||
name = "the metrics store container forwards its journal through the relay as its own client";
|
||||
ok =
|
||||
let
|
||||
h = servicesHost;
|
||||
container = h.containers.swarm-victoriametrics;
|
||||
c = container.config;
|
||||
s = c.services.opentelemetry-collector.settings;
|
||||
otel = h.services.hyperhive.swarm.otel;
|
||||
clientId = h.services.hyperhive.swarm.victoriametrics.otel.clientId;
|
||||
secret = "/run/swarm-victoriametrics-forwarder-oidc/${clientId}.secret";
|
||||
fetch = h.systemd.services.swarm-victoriametrics-forwarder-oidc;
|
||||
in
|
||||
c.services.opentelemetry-collector.enable
|
||||
&& s.exporters.otlphttp.endpoint == "http://127.0.0.1:4380/swarm-victoriametrics"
|
||||
&& s.extensions."oauth2client/swarm".token_url == "http://127.0.0.1:4380/api/oidc/token"
|
||||
&& s.extensions."oauth2client/swarm".client_id == clientId
|
||||
&& s.extensions."oauth2client/swarm".endpoint_params.audience == clientId
|
||||
&& otel.serviceProducers.swarm-victoriametrics.clientId == clientId
|
||||
&&
|
||||
(lib.findFirst (a: a.key == "service.name") null s.processors.resource.attributes).value
|
||||
== "victoriametrics"
|
||||
&& lib.elem "oidc-client-secret:${secret}" c.systemd.services.opentelemetry-collector.serviceConfig.LoadCredential
|
||||
&& !(c.systemd.services ? swarm-journal-forwarder-oidc)
|
||||
&& container.bindMounts."/run/swarm-victoriametrics-forwarder-oidc".isReadOnly
|
||||
&& !(lib.elem "--link-journal=host" (container.extraFlags or [ ]))
|
||||
&&
|
||||
fetch.environment.BAO_CLIENT_CERT
|
||||
== h.services.hyperhive.deploy.victoriametrics.authBaoClientCertFile
|
||||
&&
|
||||
fetch.environment.BAO_CLIENT_KEY == h.services.hyperhive.deploy.victoriametrics.authBaoClientKeyFile
|
||||
&& lib.hasInfix "bao kv get -field=value secret/swarm/services/${clientId}/oidc/client" fetch.script
|
||||
&& lib.hasInfix "refresh_consumer swarm-victoriametrics opentelemetry-collector.service" fetch.script;
|
||||
}
|
||||
{
|
||||
# The relay: a loopback listener in the container, a proxy to the bound
|
||||
# socket, and the host nginx server on that socket, which opens the
|
||||
# forwarder's two routes and nothing else.
|
||||
name = "the metrics store's egress relay leads loopback to the collector's route and authelia's token endpoint only";
|
||||
ok =
|
||||
let
|
||||
h = servicesHost;
|
||||
container = h.containers.swarm-victoriametrics;
|
||||
c = container.config;
|
||||
sock = "/run/swarm-victoriametrics-egress/egress.sock";
|
||||
relay = "swarm-victoriametrics-egress-relay";
|
||||
nginx = h.services.nginx.appendHttpConfig;
|
||||
otelDomain = h.services.hyperhive.swarm.otel.domain;
|
||||
autheliaDomain = h.services.hyperhive.swarm.authelia.domain;
|
||||
in
|
||||
c.systemd.sockets.${relay}.listenStreams == [ "127.0.0.1:4380" ]
|
||||
&&
|
||||
lib.hasSuffix "/lib/systemd/systemd-socket-proxyd ${sock}"
|
||||
c.systemd.services.${relay}.serviceConfig.ExecStart
|
||||
&& !container.bindMounts."/run/swarm-victoriametrics-egress".isReadOnly
|
||||
&& lib.hasInfix "listen unix:${sock};" nginx
|
||||
&& lib.hasInfix "location / {\n return 403;" nginx
|
||||
&& lib.hasInfix "location ^~ /swarm-victoriametrics/ {\n proxy_pass https://${otelDomain}" nginx
|
||||
&& lib.hasInfix "proxy_ssl_name ${otelDomain};" nginx
|
||||
&& lib.hasInfix "location = /api/oidc/token {\n proxy_pass https://${autheliaDomain};" nginx
|
||||
&& lib.hasInfix "proxy_ssl_name ${autheliaDomain};" nginx
|
||||
&& lib.elem "-/run/swarm-victoriametrics-egress" h.systemd.services.nginx.serviceConfig.ReadWritePaths
|
||||
&& lib.hasInfix "rm -f ${sock}" h.systemd.services.nginx.preStart;
|
||||
}
|
||||
{
|
||||
# Authelia's forwarder reads its secret from the store under the
|
||||
# publisher's identity, handed in for both units. The IdP host with no
|
||||
|
|
|
|||
Loading…
Reference in a new issue