swarm-grafana: run in its own network namespace
This commit is contained in:
parent
5fe71fd056
commit
08f010b742
3 changed files with 55 additions and 23 deletions
|
|
@ -312,8 +312,8 @@ let
|
|||
) ":${toString gatewayCfg.httpsPort}";
|
||||
forwarderEndpoint = "https://${hyperhiveCfg.swarm.otel.domain}${gatewayPortSuffix}/${cfg.machine}";
|
||||
forwarderUnit = "swarm-journal-forwarder-oidc";
|
||||
# In the host netns: distinct from every other collector's there, which the
|
||||
# assertion below checks.
|
||||
# Loopback port of the forwarder's own metrics, inside the container's netns:
|
||||
# no other collector shares it. The module requires a value.
|
||||
forwarderTelemetryPort = 8896;
|
||||
|
||||
# Grafana's store identity, handed into the container as system credentials
|
||||
|
|
@ -410,9 +410,10 @@ let
|
|||
# container on a switch.
|
||||
ensureSecretDir = "install -d -m 0755 ${lib.escapeShellArg secretDir}";
|
||||
|
||||
# Shared host netns, like every sibling swarm container: the gateway
|
||||
# reaches this at 127.0.0.1:<port>.
|
||||
privateNetwork = false;
|
||||
# A netns of its own on the hive bridge: the container dials the store,
|
||||
# authelia, the swarm collector and both datasources through the bridge, and
|
||||
# the gateway reaches Grafana over its socket, so no TCP port is bound.
|
||||
privateNetwork = true;
|
||||
storeRetry = import ./lib/store-retry.nix { };
|
||||
storeRefreshTimer = import ./lib/store-refresh-timer.nix { };
|
||||
in
|
||||
|
|
@ -554,6 +555,9 @@ in
|
|||
services.hyperhive.gateway.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.dns.enable = lib.mkDefault true;
|
||||
|
||||
# The hive bridge carries the container's DHCP lease and its resolver.
|
||||
services.hyperhive.network.enable = lib.mkDefault true;
|
||||
|
||||
# Registering the client is NOT here: it has to happen on the host that
|
||||
# runs authelia, and this whole block is gated on the host that runs
|
||||
# Grafana. ./glue-grafana-oidc-client.nix does it.
|
||||
|
|
@ -611,21 +615,6 @@ in
|
|||
it in swarm-otel-service.nix.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
!(lib.elem forwarderTelemetryPort [
|
||||
hyperhiveCfg.otel.telemetryPort
|
||||
hyperhiveCfg.swarm.otel.telemetryPort
|
||||
hyperhiveCfg.swarm.bao.otel.telemetryPort
|
||||
hyperhiveCfg.swarm.nats.otel.telemetryPort
|
||||
]);
|
||||
message = ''
|
||||
Grafana's journal forwarder's telemetry port (${toString forwarderTelemetryPort})
|
||||
collides with another collector's in the host netns: the hive
|
||||
collector's, the swarm collector's, the store forwarder's or the
|
||||
queue forwarder's.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# Websockets: Grafana Live streams panel updates over one, and without
|
||||
|
|
@ -1181,6 +1170,7 @@ in
|
|||
# container's own forwarder reads it (../container-modules/swarm-journal-forwarder.nix).
|
||||
extraFlags = lib.mapAttrsToList (id: source: "--load-credential=${id}:${source}") storeFiles;
|
||||
inherit privateNetwork;
|
||||
hostBridge = networkCfg.bridgeName;
|
||||
|
||||
# The socket directory, shared with the host so nginx can reach in.
|
||||
#
|
||||
|
|
@ -1238,6 +1228,11 @@ in
|
|||
|
||||
services.hyperhive.swarmContainer = { inherit privateNetwork; };
|
||||
|
||||
# The bridge address comes from the gateway's DHCP. `swarm-bridge-dns`
|
||||
# owns resolv.conf, so dhcpcd must not write it over that unit.
|
||||
networking.interfaces.eth0.useDHCP = true;
|
||||
networking.dhcpcd.extraConfig = "nohook resolv.conf";
|
||||
|
||||
# Authenticated as the forwarder's own OIDC client, with Grafana's
|
||||
# store identity: one identity for the whole container. It is a
|
||||
# system credential, so the fetch unit loads it.
|
||||
|
|
|
|||
Loading…
Reference in a new issue