remove swarmctl migrate, migrate.json and the migrate docs
This commit is contained in:
parent
210c60cde0
commit
077f6f707d
3 changed files with 25 additions and 1398 deletions
|
|
@ -1,7 +1,6 @@
|
|||
# Kubernetes manifests for the swarm services this host deploys, rendered by
|
||||
# ./render.nix from their systemd units, and the per-service switch that moves
|
||||
# a service between its host unit and the cluster (./runtime.nix), and what
|
||||
# `swarmctl migrate` reads of both (./migrate.nix). Rendering
|
||||
# a service between its host unit and the cluster (./runtime.nix). Rendering
|
||||
# alone changes no unit and applies nothing. docs/4-implementation/k8s/manifests.md
|
||||
# and runtime.md have the design.
|
||||
{
|
||||
|
|
@ -25,7 +24,6 @@ in
|
|||
{
|
||||
imports = [
|
||||
./host-services.nix
|
||||
./migrate.nix
|
||||
./node.nix
|
||||
./pod-logs.nix
|
||||
./runtime.nix
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
# What `swarmctl migrate` reads of this host: `/etc/hyperhive/migrate.json`, and
|
||||
# the environment that tells `swarmctl` which `kubectl` and kubeconfig to use.
|
||||
# Imported by ./default.nix. docs/4-implementation/k8s/migrate.md has the design.
|
||||
#
|
||||
# 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. 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,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.services.hyperhive.k8s;
|
||||
deployCfg = config.services.hyperhive.deploy;
|
||||
node = deployCfg.k8s;
|
||||
controllerCfg = deployCfg.swarm-controller;
|
||||
|
||||
# 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: {
|
||||
option = "services.hyperhive.deploy.${optionOf.${name}}.runtime";
|
||||
inherit (switch) runtime;
|
||||
hostUnits = lib.toList switch.hostUnit;
|
||||
};
|
||||
|
||||
migrateJson = {
|
||||
inherit (cfg) namespace;
|
||||
services = lib.mapAttrs entry cfg.rendered.switches;
|
||||
};
|
||||
|
||||
# The `swarmctl` wrapper's variables. The same `kubectl` that ./runtime.nix
|
||||
# runs, with the cluster's admin kubeconfig.
|
||||
kubeEnv = {
|
||||
SWARMCTL_KUBECTL = "${pkgs.kubectl}/bin/kubectl";
|
||||
SWARMCTL_KUBECONFIG = "/etc/rancher/k3s/k3s.yaml";
|
||||
};
|
||||
|
||||
# `swarmctl` where the controller's module does not install one.
|
||||
swarmctlKube = pkgs.symlinkJoin {
|
||||
name = "swarmctl-kube";
|
||||
paths = [ deployCfg.swarm-controller.swarmctlPackage ];
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/swarmctl ${
|
||||
lib.concatStringsSep " " (
|
||||
lib.mapAttrsToList (name: value: "--set ${name} ${lib.escapeShellArg value}") kubeEnv
|
||||
)
|
||||
}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
config = lib.mkIf (node.enable && cfg.enable) {
|
||||
environment.etc."hyperhive/migrate.json".text = builtins.toJSON migrateJson;
|
||||
|
||||
# The controller module's wrapper carries these where the controller is
|
||||
# enabled, which it stays at `runtime = "k8s"`.
|
||||
services.hyperhive.deploy.swarm-controller.swarmctlEnvironment = kubeEnv;
|
||||
environment.systemPackages = lib.mkIf (!controllerCfg.enable) [ swarmctlKube ];
|
||||
};
|
||||
}
|
||||
|
|
@ -247,7 +247,6 @@ let
|
|||
&& usesSecret { projected.sources = [ { secret.name = "x"; } ]; }
|
||||
&& !(usesSecret { projected.sources = [ { configMap.name = "x"; } ]; });
|
||||
|
||||
migrateOf = c: builtins.fromJSON c.environment.etc."hyperhive/migrate.json".text;
|
||||
routerUnit = c: c.services.hyperhive.deploy.notify-router.unit;
|
||||
manifestNames = c: lib.sort lib.lessThan (lib.attrNames c.services.k3s.manifests);
|
||||
routerPrune = withNode.systemd.services.swarm-notify-router-k8s-prune;
|
||||
|
|
@ -2182,63 +2181,6 @@ let
|
|||
&& problems withCaps != [ ]
|
||||
&& problems withoutSeccomp != [ ];
|
||||
}
|
||||
{
|
||||
# The file names the runtime and the host units of every service and no
|
||||
# state: nothing is copied. The units of the poller (timer and service)
|
||||
# are the control for a list of more than one.
|
||||
name = "migrate.json names every service with its option, host units and the runtime the configuration wants, and no state";
|
||||
ok =
|
||||
let
|
||||
host = (migrateOf withNode).services;
|
||||
cluster = (migrateOf onCluster).services;
|
||||
in
|
||||
(migrateOf withNode).namespace == "hyperhive"
|
||||
&&
|
||||
lib.sort lib.lessThan (lib.attrNames host) == [
|
||||
"swarm-ci-metrics"
|
||||
"swarm-claude-login"
|
||||
"swarm-controller"
|
||||
"swarm-nats"
|
||||
"swarm-notify-router"
|
||||
"swarm-review-classifier"
|
||||
"swarm-stt"
|
||||
]
|
||||
&& lib.all (s: !(s ? state)) (lib.attrValues host)
|
||||
&& lib.all (n: lib.hasPrefix "services.hyperhive.deploy." host.${n}.option) (lib.attrNames host)
|
||||
&&
|
||||
host.swarm-ci-metrics.hostUnits == [
|
||||
"swarm-ci-metrics.timer"
|
||||
"swarm-ci-metrics.service"
|
||||
]
|
||||
&& host.swarm-nats.hostUnits == [ "container@swarm-nats.service" ]
|
||||
&& host.swarm-ci-metrics.option == "services.hyperhive.deploy.ci-metrics.runtime"
|
||||
&& lib.all (s: s.runtime == "host") (lib.attrValues host)
|
||||
# The runtime follows the option: the cluster fixture has every one on k8s.
|
||||
&& lib.all (s: s.runtime == "k8s") (lib.attrValues cluster);
|
||||
}
|
||||
{
|
||||
name = "swarmctl is wrapped with kubectl and the cluster's kubeconfig, by one wrapper per host";
|
||||
ok =
|
||||
let
|
||||
env = c: c.services.hyperhive.deploy.swarm-controller.swarmctlEnvironment;
|
||||
wrappers =
|
||||
c:
|
||||
map lib.getName (
|
||||
lib.filter (p: lib.hasPrefix "swarmctl-" (lib.getName p)) c.environment.systemPackages
|
||||
);
|
||||
in
|
||||
(env withNode).SWARMCTL_KUBECTL == "${pkgs.kubectl}/bin/kubectl"
|
||||
&& (env withNode).SWARMCTL_KUBECONFIG == "/etc/rancher/k3s/k3s.yaml"
|
||||
# The controller's own wrapper carries them where the controller is
|
||||
# enabled; elsewhere the k8s module installs one.
|
||||
&& wrappers withNode == [ "swarmctl-configured" ]
|
||||
&& wrappers nodeNoBridge == [ "swarmctl-kube" ]
|
||||
# Without the node there is no cluster to name, though the manifests render.
|
||||
&& allLocal.services.hyperhive.k8s.enable
|
||||
&& !(env allLocal ? SWARMCTL_KUBECTL)
|
||||
&& !(allLocal.environment.etc ? "hyperhive/migrate.json")
|
||||
&& wrappers allLocal == [ "swarmctl-configured" ];
|
||||
}
|
||||
];
|
||||
in
|
||||
runGroup "k8s" cases
|
||||
|
|
|
|||
Loading…
Reference in a new issue