Watch
0
0
Fork
You've already forked hyperhive
0

swarm-victorialogs: own network namespace, gateway over a unix socket

This commit is contained in:
maia 2026-11-18 19:12:53 +01:00 • committed by mara
commit 188dbcea8b

View file

@ -843,14 +843,14 @@ let
}
{
# Both values come from ../container-modules/swarm-container.nix.
# Four of the 16 service containers share the host netns (hive-forge, bao,
# the queue, the log store) and twelve have one of their own.
# Three of the 16 service containers share the host netns (hive-forge, bao,
# the queue) and thirteen have one of their own.
name = "a service container on the host netns runs no firewall or resolvconf of its own";
ok =
let
shared = lib.filter (c: !c.privateNetwork) (lib.attrValues serviceContainers);
in
lib.length shared == 4
lib.length shared == 3
&& lib.all (
c: !c.config.networking.firewall.enable && !c.config.networking.resolvconf.enable
) shared;
@ -990,6 +990,50 @@ let
&& bridge.serviceConfig.Group == "gateway-nginx"
&& lib.elem dir unit.serviceConfig.ReadWritePaths;
}
{
# On the bridge by DHCP, listening on a socket only the gateway's group can
# reach, so the store binds no host port. Every location that forwards to
# it goes through the socket (the authelia subrequests are the `https://`
# upstream); the read, ingest, scrape and catch-all locations are named so
# an empty filter can't pass, and the old loopback port is named nowhere.
name = "the log store runs on a netns of its own and the gateway reaches it over its socket";
ok =
let
host = serviceContainersWithCi;
net = host.services.hyperhive.network;
c = host.containers.swarm-victorialogs;
dir = "/run/swarm-victorialogs";
sock = "${dir}/victorialogs.sock";
viaSock = path: "http://unix:${sock}:${path}";
locs =
host.services.nginx.virtualHosts.${host.services.hyperhive.swarm.victorialogs.domain}.locations;
toStore = lib.filter (
p: p != null && !(lib.hasPrefix "https://" p) && !(lib.hasPrefix "http://unix:/run/swarm-logs" p)
) (map (l: l.proxyPass) (lib.attrValues locs));
unit = c.config.systemd.services.victorialogs;
nginxGid = host.ids.gids.nginx;
in
c.privateNetwork
&& c.hostBridge == net.bridgeName
&& c.hostAddress == null
&& c.localAddress == null
&& c.config.networking.interfaces.eth0.useDHCP
&& c.config.services.victorialogs.listenAddress == "unix:${sock}"
&& locs."/".proxyPass == viaSock "/"
&& locs."= /insert/opentelemetry/v1/logs".proxyPass == viaSock "/insert/opentelemetry/v1/logs"
&& locs."^~ /select/logsql/".proxyPass == "http://unix:${sock}"
&& locs."= /metrics".proxyPass == viaSock "/metrics"
&& toStore != [ ]
&& lib.all (lib.hasPrefix "http://unix:${sock}") toStore
&& !(lib.any (lib.hasInfix "127.0.0.1") toStore)
&& c.bindMounts.${dir}.hostPath == dir
&& builtins.elem "d ${dir} 0770 root ${toString nginxGid} - -" host.systemd.tmpfiles.rules
&& c.config.users.groups.gateway-nginx.gid == nginxGid
&& unit.serviceConfig.Group == "gateway-nginx"
&& !unit.serviceConfig.DynamicUser
&& unit.serviceConfig.UMask == "0007"
&& lib.hasInfix "--unix-socket ${sock}" unit.postStart;
}
{
# On the bridge by DHCP, listening on a socket (protocol `socket` ignores the
# upstream-default `http_port`, which stays in the settings): the