Watch
0
0
Fork
You've already forked hyperhive
0

run the log store and its auth responders as pods

swarm-logs-auth and swarm-metrics-auth take --listen for a TCP address beside
--socket. The log store is a Deployment on a static local volume that is its
old container's data directory, behind a ClusterIP Service the gateway dials by
name. Its two auth_request responders are one unpinned pod with a jwt role.
The renderer gains a plain HTTP listener, a probe path, fsGroupChangePolicy,
and one policy for a pod with both a listener and egress.
This commit is contained in:
atlas 2026-11-26 10:17:57 +01:00 • committed by maia
commit 71b2e9310c

View file

@ -1276,7 +1276,17 @@ let
leaf = "swarm/services/${allLocal.services.hyperhive.swarm.grafana.oidc.clientId}/metrics/bearer";
in
logs.secureJsonData.httpHeaderValue1 == metrics.secureJsonData.httpHeaderValue1
&& lib.hasInfix "--store-path ${leaf}" allLocal.systemd.services.swarm-logs-grafana-auth.serviceConfig.ExecStart;
&&
(lib.findFirst (c: c.name == "grafana-auth") null (
allLocal.services.hyperhive.k8s.rendered.services.swarm-logs-auth.objects."swarm-logs-auth/deployment".spec.template.spec.containers
)).args == [
"--listen"
"0.0.0.0:8082"
"--store-cert-role"
"swarm-logs-auth"
"--store-path"
leaf
];
}
{
# The responder reads the store as itself, with the leaf the store's
@ -1359,10 +1369,11 @@ let
let
l = allLocal.services.nginx.virtualHosts."logs.t.local".locations;
http = allLocal.services.nginx.appendHttpConfig;
unit = allLocal.systemd.services.swarm-logs-auth;
grafanaUnit = allLocal.systemd.services.swarm-logs-grafana-auth;
logs = allLocal.services.hyperhive.deploy.victorialogs;
metrics = allLocal.services.hyperhive.deploy.victoriametrics;
unit = logs.authUnit;
pod =
allLocal.services.hyperhive.k8s.rendered.services.swarm-logs-auth.objects."swarm-logs-auth/deployment".spec.template.spec;
grafana = lib.findFirst (c: c.name == "grafana-auth") null pod.containers;
in
lib.hasInfix "map \$http_authorization \$swarm_logs_auth_target" http
&& lib.hasInfix "\"~^Bearer swarm-agent\\.\" /__swarm_logs_agent_auth;" http
@ -1371,17 +1382,26 @@ let
&& lib.hasInfix "auth_request /__swarm_logs_auth;" l."^~ /select/logsql/".extraConfig
&& lib.hasInfix "rewrite ^ \$swarm_logs_auth_target last;" l."= /__swarm_logs_auth".extraConfig
&& lib.hasInfix "internal;" l."= /__swarm_logs_agent_auth".extraConfig
&& l."= /__swarm_logs_agent_auth".proxyPass == "http://unix:/run/swarm-logs-auth/auth.sock:/"
&& lib.hasInfix "--socket /run/swarm-logs-auth/auth.sock" unit.serviceConfig.ExecStart
# Each hop dials the Service of its own pod, by the port that pod's
# container listens on, and the variable it writes is the one it dials.
&& l."= /__swarm_logs_agent_auth".proxyPass == "http://$swarm_logs_agent_auth_upstream/"
&&
lib.hasInfix "set $swarm_logs_agent_auth_upstream swarm-logs-auth.hyperhive.svc.cluster.local:8081;"
l."= /__swarm_logs_agent_auth".extraConfig
&& hasStorePath "${logs.authPackage}/bin/swarm-logs-auth " unit.serviceConfig.ExecStart
&& lib.hasInfix "--listen 0.0.0.0:8081" unit.serviceConfig.ExecStart
&& !(lib.hasInfix "--socket" unit.serviceConfig.ExecStart)
&& lib.hasInfix "--surface logs" unit.serviceConfig.ExecStart
&& lib.hasInfix "internal;" l."= /__swarm_logs_grafana_auth".extraConfig
&& l."= /__swarm_logs_grafana_auth".proxyPass == "http://$swarm_logs_grafana_auth_upstream/"
&&
l."= /__swarm_logs_grafana_auth".proxyPass == "http://unix:/run/swarm-logs-grafana-auth/auth.sock:/"
&& lib.hasInfix "--socket /run/swarm-logs-grafana-auth/auth.sock" grafanaUnit.serviceConfig.ExecStart
&& hasStorePath "${logs.grafanaAuthPackage}/bin/swarm-metrics-auth " grafanaUnit.serviceConfig.ExecStart
&& !(hasStorePath "${metrics.authPackage}" grafanaUnit.serviceConfig.ExecStart)
&& hasStorePath "${logs.authPackage}/bin/swarm-logs-auth " unit.serviceConfig.ExecStart
&& lib.hasInfix "--store-cert-role swarm-logs-auth" grafanaUnit.serviceConfig.ExecStart
lib.hasInfix
"set $swarm_logs_grafana_auth_upstream swarm-logs-grafana-auth.hyperhive.svc.cluster.local:8082;"
l."= /__swarm_logs_grafana_auth".extraConfig
&& builtins.elem "--listen" grafana.args
&& builtins.elem "0.0.0.0:8082" grafana.args
&& builtins.elem "swarm-logs-auth" grafana.args
&& pod.serviceAccountName == "swarm-logs-auth"
&& l ? "= /__hive_authelia";
}
{
@ -1389,7 +1409,7 @@ let
# `/run/private/` (0700 root:root), which nginx cannot traverse, so a
# socket there answers every proxied request with a 502. Each `unix:`
# upstream under `/run/<dir>/` is matched to the units creating `<dir>`.
# The first two clauses are the control: the match finds both responders.
# The first clauses are the control: the match finds the metrics store's responders.
name = "no unix socket nginx proxies to sits in a DynamicUser's preserved runtime directory";
ok =
let
@ -1423,9 +1443,7 @@ let
"no"
]);
in
owners ? swarm-logs-auth
&& owners ? swarm-logs-grafana-auth
&& owners ? swarm-metrics-auth
owners ? swarm-metrics-auth
&& owners ? swarm-metrics-agent-auth
&& !(lib.any (u: hidden u.serviceConfig) (lib.attrValues owners));
}
@ -1439,8 +1457,8 @@ let
let
l = allLocal.services.nginx.virtualHosts."logs.t.local".locations;
http = allLocal.services.nginx.appendHttpConfig;
unit = allLocal.systemd.services.swarm-logs-auth;
v = allLocal.services.hyperhive.deploy.victorialogs;
unit = v.authUnit;
in
lib.hasInfix "limit_req_zone $binary_remote_addr zone=swarm_logs_agent_auth:1m rate=${v.authRate};" http
&&
@ -1458,12 +1476,14 @@ let
ok =
let
v = allLocal.services.hyperhive.deploy.victorialogs;
lc = allLocal.systemd.services.swarm-logs-auth.serviceConfig.LoadCredential;
lc = v.authUnit.serviceConfig.LoadCredential;
in
lib.hasSuffix "/logs-auth.pem" v.authBaoClientCertFile
&& lib.hasSuffix "/logs-auth-key.pem" v.authBaoClientKeyFile
&& builtins.elem "bao-client.pem:${v.authBaoClientCertFile}" lc
&& builtins.elem "bao-client-key.pem:${v.authBaoClientKeyFile}" lc;
# The pod's unit names the ids and no host path.
&& builtins.elem "bao-client.pem" lc
&& builtins.elem "bao-client-key.pem" lc
&& !(lib.any (lib.hasInfix ":") lc);
}
{
# The absence arm for the case above, and the option's own rule — a
@ -2496,9 +2516,10 @@ let
&& h.deploy.nats.otel.telemetryPort == 8891
&& h.deploy.swarm-otel.telemetryPort == 8889
&& lib.hasInfix ":7777;" (locs h.swarm.nats.domain)."= /metrics".extraConfig
&& (locs h.swarm.victorialogs.domain)."= /metrics".proxyPass == "http://$swarm_logs_store_upstream"
&&
(locs h.swarm.victorialogs.domain)."= /metrics".proxyPass
== "http://unix:/run/swarm-victorialogs/victorialogs.sock:/metrics"
lib.hasInfix "set $swarm_logs_store_upstream swarm-victorialogs.hyperhive.svc.cluster.local:9428;"
(locs h.swarm.victorialogs.domain)."= /metrics".extraConfig
&& (locs h.swarm.forge.domain)."/".proxyPass == "http://unix:/run/hive-forge/forgejo.sock:/"
&& !allLocal.containers.hive-matrix.config.services.matrix-tuwunel.settings.global.allow_encryption
&& env.SWARM_CONTROLLER_MATRIX_ADMIN_SYNC_IGNORE_USERS == ""
@ -2896,7 +2917,6 @@ let
"swarm-builder"
"swarm-grafana"
"swarm-otel"
"swarm-victorialogs"
"swarm-victoriametrics"
]
&& lib.all (carries allLocal) names