k8s: deploy.ci-metrics.runtime moves the CI run poller between its timer and the cluster
This commit is contained in:
parent
49406498a7
commit
6512aaa3e9
1 changed files with 351 additions and 107 deletions
|
|
@ -74,8 +74,12 @@ let
|
|||
# which the kubelet cannot probe. `publicCredentials` maps the ids of the
|
||||
# credentials that hold a public CA file to their key in the CA ConfigMap.
|
||||
# `switch` is null for a service that always runs on the host, and for one
|
||||
# with a `runtime` option names the option's value and the host unit that
|
||||
# runs the service when it is `"host"`.
|
||||
# with a `runtime` option names the option's value and the host unit or units
|
||||
# that run the service when it is `"host"`. `otlp` is where the pod pushes
|
||||
# its telemetry: `"hive"` is the hive collector. A swarm-tier producer is
|
||||
# `"own"` and keeps the route its unit names, because the hive collector
|
||||
# stamps the `hive` label on what it forwards and a swarm-level series must
|
||||
# not carry one (../swarm-otel.nix, the swarm tier's own pipeline).
|
||||
services = {
|
||||
swarm-controller = {
|
||||
inherit (deployCfg.swarm-controller) enable package;
|
||||
|
|
@ -84,6 +88,7 @@ let
|
|||
healthEnv = null;
|
||||
etcFiles = [ "hyperhive/swarm-controller.json" ];
|
||||
publicCredentials = { };
|
||||
otlp = "hive";
|
||||
switch = null;
|
||||
};
|
||||
swarm-notify-router = {
|
||||
|
|
@ -93,6 +98,7 @@ let
|
|||
healthEnv = "SWARM_NOTIFY_ROUTER_HEALTH_ADDR";
|
||||
etcFiles = [ ];
|
||||
publicCredentials.notify-router-bao-server-ca = baoServerCaKey;
|
||||
otlp = "hive";
|
||||
switch = {
|
||||
inherit (deployCfg.notify-router) runtime;
|
||||
hostUnit = "container@swarm-notify-router.service";
|
||||
|
|
@ -105,6 +111,7 @@ let
|
|||
healthEnv = "SWARM_STT_HEALTH_ADDR";
|
||||
etcFiles = [ ];
|
||||
publicCredentials.stt-bao-server-ca = baoServerCaKey;
|
||||
otlp = "hive";
|
||||
switch = {
|
||||
inherit (deployCfg.stt) runtime;
|
||||
hostUnit = "container@swarm-stt.service";
|
||||
|
|
@ -112,21 +119,32 @@ let
|
|||
};
|
||||
swarm-ci-metrics = {
|
||||
inherit (deployCfg.ci-metrics) enable package;
|
||||
unit = config.systemd.services.swarm-ci-metrics;
|
||||
timer = config.systemd.timers.swarm-ci-metrics;
|
||||
unit = deployCfg.ci-metrics.unit;
|
||||
timer = deployCfg.ci-metrics.timer;
|
||||
kind = "CronJob";
|
||||
healthEnv = null;
|
||||
etcFiles = [ ];
|
||||
publicCredentials = { };
|
||||
switch = null;
|
||||
publicCredentials."bao-ca.pem" = baoServerCaKey;
|
||||
otlp = "own";
|
||||
# The timer and the service both: the prune unit holds back either, and a
|
||||
# service started by hand cannot run beside the CronJob.
|
||||
switch = {
|
||||
inherit (deployCfg.ci-metrics) runtime;
|
||||
hostUnit = [
|
||||
"swarm-ci-metrics.timer"
|
||||
"swarm-ci-metrics.service"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Where a pod pushes telemetry: the hive collector, by the name the node's
|
||||
# CoreDNS answers with the bridge address (./host-services.nix). A unit's own
|
||||
# endpoint is a loopback forwarder or a gateway route that needs a token, and
|
||||
# a pod has neither. `otlpEndpointVars` are the variables a unit may name its
|
||||
# endpoint in; the first is the standard one and is always set.
|
||||
# Where a pod pushes telemetry. A `"hive"` service pushes to the hive
|
||||
# collector, by the name the node's CoreDNS answers with the bridge address
|
||||
# (./host-services.nix): a unit's own endpoint is a loopback forwarder or a
|
||||
# gateway route that needs a token, and a pod has neither. An `"own"` service
|
||||
# keeps its unit's endpoint, a swarm route it logs in to by itself.
|
||||
# `otlpEndpointVars` are the variables a unit may name its endpoint in; the
|
||||
# first is the standard one and is always set for a `"hive"` service.
|
||||
otelCfg = hyperhiveCfg.otel;
|
||||
collectorEndpoint = "http://${otelCfg.collector.host}:${toString hyperhiveCfg.swarm.hiveOtel.collectorPort}";
|
||||
otlpEndpointVars = [
|
||||
|
|
@ -134,8 +152,8 @@ let
|
|||
"SWARM_CI_METRICS_OTLP_ENDPOINT"
|
||||
];
|
||||
podOtlpEnv =
|
||||
unitEnv:
|
||||
lib.optionalAttrs otelCfg.collector.enable (
|
||||
svc: unitEnv:
|
||||
lib.optionalAttrs (svc.otlp == "hive" && otelCfg.collector.enable) (
|
||||
lib.genAttrs (lib.filter (
|
||||
n: n == "OTEL_EXPORTER_OTLP_ENDPOINT" || unitEnv ? ${n}
|
||||
) otlpEndpointVars) (_: collectorEndpoint)
|
||||
|
|
@ -289,7 +307,7 @@ let
|
|||
else
|
||||
unitEnv
|
||||
)
|
||||
// podOtlpEnv unitEnv
|
||||
// podOtlpEnv svc unitEnv
|
||||
// lib.optionalAttrs (runtimeDir != null) { RUNTIME_DIRECTORY = runtimeDir; }
|
||||
// lib.optionalAttrs (stateDir != null) { STATE_DIRECTORY = stateDir; }
|
||||
// lib.optionalAttrs (svc.healthEnv != null) {
|
||||
|
|
@ -628,6 +646,8 @@ let
|
|||
in
|
||||
if !(lib.all (p: lib.elem (lib.getName p) nixosDefaultPath) unit.path) then
|
||||
fail name "the unit puts packages on PATH, which the image does not carry"
|
||||
else if svc.otlp == "own" && !(lib.any (n: unitEnv ? ${n}) otlpEndpointVars) then
|
||||
fail name "the unit names no OTLP endpoint of its own, which the pod would push to"
|
||||
else if svc.healthEnv != null && unitEnv ? ${svc.healthEnv} then
|
||||
fail name "the unit already sets ${svc.healthEnv}"
|
||||
else if lib.head execWords != entrypoint then
|
||||
|
|
|
|||
Loading…
Reference in a new issue