run grafana as a pod in the cluster
The Deployment swarm-grafana replaces the swarm-grafana container: one replica on a static local volume that is the container's data directory, an init container that fetches the OIDC client secret and creates the administrator password, the datasources' bearer and the encryption key in the secret store, and a sidecar that keeps the controller's Viewer token. The datasources reach the stores through the gateway with that bearer, and Grafana's /metrics asks for the stores' kind of credential, which the vhost sends. The five host units, the journal forwarder, its client glue and the unix-socket directory go with the container.
This commit is contained in:
parent
26ef09b0d7
commit
9f62e71dae
1 changed files with 1938 additions and 1953 deletions
|
|
@ -201,7 +201,6 @@ let
|
|||
"swarm-bao"
|
||||
"swarm-builder"
|
||||
"swarm-ci-runner"
|
||||
"swarm-grafana"
|
||||
"swarm-otel"
|
||||
];
|
||||
|
||||
|
|
@ -259,7 +258,6 @@ let
|
|||
"authelia-swarm.service"
|
||||
"forgejo.service"
|
||||
"gitea-runner-swarm.service"
|
||||
"grafana.service"
|
||||
"opentelemetry-collector.service"
|
||||
];
|
||||
}
|
||||
|
|
@ -749,7 +747,6 @@ let
|
|||
lib.all (m: c ? ${m}) [
|
||||
"swarm-authelia"
|
||||
"swarm-bao"
|
||||
"swarm-grafana"
|
||||
"swarm-otel"
|
||||
"hive-matrix"
|
||||
"hive-forge"
|
||||
|
|
@ -797,7 +794,7 @@ let
|
|||
# that lost a container can't pass by comparing fewer of them.
|
||||
name = "every service container restates its host-side privateNetwork";
|
||||
ok =
|
||||
lib.length (lib.attrNames serviceContainers) == 9
|
||||
lib.length (lib.attrNames serviceContainers) == 8
|
||||
&& lib.all (
|
||||
c: c.privateNetwork == (c.config.services.hyperhive.swarmContainer.privateNetwork or null)
|
||||
) (lib.attrValues serviceContainers);
|
||||
|
|
@ -986,37 +983,6 @@ let
|
|||
&& bridge.serviceConfig.Group == "gateway-nginx"
|
||||
&& lib.elem dir unit.serviceConfig.ReadWritePaths;
|
||||
}
|
||||
{
|
||||
# On the bridge by DHCP, listening on a socket (protocol `socket` ignores the
|
||||
# upstream-default `http_port`, which stays in the settings): the
|
||||
# gateway's locations (UI, metrics, websocket upgrade) all forward to it.
|
||||
# `forwarded != []` keeps an empty filter from passing.
|
||||
name = "grafana 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-grafana;
|
||||
dir = "/run/swarm-grafana";
|
||||
sock = "${dir}/grafana.sock";
|
||||
locs = host.services.nginx.virtualHosts.${host.services.hyperhive.swarm.grafana.domain}.locations;
|
||||
forwarded = lib.filter (p: p != null && !(lib.hasPrefix "https://" p)) (
|
||||
map (l: l.proxyPass) (lib.attrValues locs)
|
||||
);
|
||||
server = c.config.services.grafana.settings.server;
|
||||
in
|
||||
c.privateNetwork
|
||||
&& c.hostBridge == net.bridgeName
|
||||
&& c.hostAddress == null
|
||||
&& c.localAddress == null
|
||||
&& c.config.networking.interfaces.eth0.useDHCP
|
||||
&& c.config.networking.firewall.enable
|
||||
&& server.protocol == "socket"
|
||||
&& server.socket == sock
|
||||
&& forwarded != [ ]
|
||||
&& lib.all (lib.hasPrefix "http://unix:${sock}:") forwarded
|
||||
&& c.bindMounts.${dir}.hostPath == dir;
|
||||
}
|
||||
{
|
||||
# atticd listens on the container's own loopback, a relay there forwards
|
||||
# the socket nginx connects to, and the host unit that drives the
|
||||
|
|
@ -1096,7 +1062,7 @@ let
|
|||
&& inner.networking.firewall.enable
|
||||
&& onSocket "h1"
|
||||
&& onSocket otel.producerName
|
||||
&& onSocket "swarm-grafana"
|
||||
&& onSocket "swarm-attic"
|
||||
&& lib.all (n: (receivers.${n}.protocols.http.transport or null) == "unix") (
|
||||
lib.attrNames receivers
|
||||
)
|
||||
|
|
@ -1148,7 +1114,7 @@ let
|
|||
verdict locs
|
||||
&& lib.elem "/run/swarm-otel/h1.sock" receiverSocks
|
||||
&& lib.elem "/run/swarm-otel/${otel.producerName}.sock" receiverSocks
|
||||
&& lib.elem "/run/swarm-otel/swarm-grafana.sock" receiverSocks
|
||||
&& lib.elem "/run/swarm-otel/swarm-attic.sock" receiverSocks
|
||||
&&
|
||||
lib.length unixReceivers == lib.length (lib.attrNames host.services.hyperhive.swarm.hives)
|
||||
+ 1
|
||||
|
|
@ -1338,9 +1304,9 @@ let
|
|||
in
|
||||
lib.length routes > 2
|
||||
&& lib.elem "h1" routes
|
||||
&& lib.elem "swarm-grafana" routes
|
||||
&& lib.elem "swarm-attic" routes
|
||||
&& verdict script
|
||||
&& !verdict (lib.replaceStrings [ " swarm-grafana" ] [ "" ] script)
|
||||
&& !verdict (lib.replaceStrings [ " swarm-attic" ] [ "" ] script)
|
||||
&& !verdict (lib.replaceStrings [ "000 | 502 | 504" ] [ "000 | 504" ] script)
|
||||
&& !verdict (lib.replaceStrings [ "--resolve" ] [ "--noresolve" ] script)
|
||||
&& !verdict (lib.replaceStrings [ "%header{x-swarm-otel-route}" ] [ "" ] script)
|
||||
|
|
@ -1348,7 +1314,7 @@ let
|
|||
}
|
||||
{
|
||||
name = "a service container that sets no stateVersion of its own is on 26.05";
|
||||
ok = serviceContainers.swarm-grafana.config.system.stateVersion == "26.05";
|
||||
ok = serviceContainers.swarm-attic.config.system.stateVersion == "26.05";
|
||||
}
|
||||
{
|
||||
name = "a service container that pins its own stateVersion keeps it";
|
||||
|
|
@ -1473,11 +1439,6 @@ let
|
|||
readers = [
|
||||
"swarm-bao-forge-oidc"
|
||||
"swarm-bao-matrix-oidc"
|
||||
"swarm-bao-grafana-oidc"
|
||||
"swarm-bao-grafana-admin"
|
||||
"swarm-bao-grafana-metrics-bearer"
|
||||
"swarm-bao-grafana-secret-key"
|
||||
"swarm-bao-grafana-controller-token"
|
||||
"swarm-bao-ci-runner"
|
||||
"swarm-bao-otel-oidc"
|
||||
];
|
||||
|
|
@ -1501,9 +1462,9 @@ let
|
|||
!(lib.any (n: lib.elem n (s.after ++ s.wants ++ s.requires)) storeUnits);
|
||||
in
|
||||
lib.all waits readers
|
||||
&& lib.length readersHere == 9
|
||||
&& lib.elem "swarm-bao-grafana-admin" readersHere
|
||||
&& lib.length readersElsewhere == 7
|
||||
&& lib.length readersHere == 4
|
||||
&& lib.elem "swarm-bao-forge-oidc" readersHere
|
||||
&& lib.length readersElsewhere == 2
|
||||
&& lib.all namesNoStoreUnit readersElsewhere
|
||||
&& !(lib.any (u: storeOnlyNoHive.systemd.services ? ${u}) readers);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue