Watch
0
0
Fork
You've already forked hyperhive
0

k8s: the controller pod keeps no volume; the state gate goes

This commit is contained in:
atlas 2026-11-23 05:45:57 +01:00 • committed by mara
commit 513be8f7d0

View file

@ -4,11 +4,8 @@
#
# The file has one entry per service that has a `runtime` option: the
# option's path, the runtime the configuration wants, the host units that run
# the service when it is on the host, and, where the service keeps state in a
# volume, that state: the claim, the mount in the pod, where the data lives
# on the host, and what a copy leaves out. Paths are computed here, never
# derived by `swarmctl`. Both exist only on a host with the node
# (./node.nix): without a cluster there is nothing to read.
# the service when it is on the host. The file and the wrapper exist only on a
# host with the node (./node.nix): without a cluster there is nothing to read.
{
lib,
pkgs,
@ -21,71 +18,22 @@ let
node = deployCfg.k8s;
controllerCfg = deployCfg.swarm-controller;
# The path of a unit's state directory in a pod, which ./render.nix mounts
# the claim at.
stateMount = unit: "/var/lib/${unit.serviceConfig.StateDirectory}";
pathsWithin = import ../lib/paths-within.nix { inherit lib; };
controllerStateDir = "/var/lib/swarm-controller";
# `option` is the service's name under `services.hyperhive.deploy`. `state`
# is null for a service with nothing to copy: no volume, an `emptyDir`, a
# volume that starts empty with no gate, or (the queue) the host unit's own
# directory, mounted into the pod.
#
# The claim is `<service>-state`, as ./render.nix names it.
stateTable = {
swarm-controller = {
option = "swarm-controller";
state = {
mount = stateMount controllerCfg.unit;
hostPath = controllerStateDir;
# The pod issues its own leaf with its own store login, so a bao
# identity an operator keeps in this directory stays behind.
excludes = pathsWithin controllerStateDir [
controllerCfg.baoClientCertFile
controllerCfg.baoClientKeyFile
];
};
};
swarm-nats = {
option = "nats";
state = null;
};
swarm-notify-router = {
option = "notify-router";
state = null;
};
swarm-stt = {
option = "stt";
state = null;
};
swarm-review-classifier = {
option = "review-classifier";
state = null;
};
swarm-claude-login = {
option = "claude-login";
state = null;
};
swarm-ci-metrics = {
option = "ci-metrics";
state = null;
};
# Each service's name under `services.hyperhive.deploy`.
optionOf = {
swarm-controller = "swarm-controller";
swarm-nats = "nats";
swarm-notify-router = "notify-router";
swarm-stt = "stt";
swarm-review-classifier = "review-classifier";
swarm-claude-login = "claude-login";
swarm-ci-metrics = "ci-metrics";
};
entry =
name: switch:
let
row = stateTable.${name};
in
{
option = "services.hyperhive.deploy.${row.option}.runtime";
inherit (switch) runtime;
hostUnits = lib.toList switch.hostUnit;
state = lib.mapNullable (s: s // { claim = "${name}-state"; }) row.state;
};
entry = name: switch: {
option = "services.hyperhive.deploy.${optionOf.${name}}.runtime";
inherit (switch) runtime;
hostUnits = lib.toList switch.hostUnit;
};
migrateJson = {
inherit (cfg) namespace;