k8s: deploy.notify-router.runtime moves the router between its container and the cluster
This commit is contained in:
parent
d4eab3348c
commit
0a65778c85
1 changed files with 671 additions and 187 deletions
|
|
@ -1,7 +1,8 @@
|
|||
# The Kubernetes objects that run each in-cluster swarm service this host
|
||||
# deploys, read from that service's systemd unit as this host renders it.
|
||||
# Imported by ./default.nix, which writes the objects out as YAML. Returns
|
||||
# `objects` and the `images` the pods run.
|
||||
# `objects`, the `images` the pods run, and what ./runtime.nix moves services
|
||||
# with.
|
||||
#
|
||||
# The pod takes the unit's environment, credential ids, state and runtime
|
||||
# directories, and timer. Every file the unit names is mounted at the path the
|
||||
|
|
@ -26,12 +27,23 @@ let
|
|||
k8sCfg = hyperhiveCfg.k8s;
|
||||
baoDeployCfg = deployCfg.bao;
|
||||
podAuth = import ../lib/bao-pod-auth.nix;
|
||||
caTrust = import ../lib/hive-ca-trust.nix {
|
||||
inherit lib;
|
||||
tlsCfg = deployCfg.hive-controller.tls;
|
||||
gatewayCfg = hyperhiveCfg.gateway;
|
||||
};
|
||||
|
||||
# The ConfigMap that holds the public CA files the pods trust, and its keys.
|
||||
# A CA certificate is public, so it travels as a ConfigMap, never a Secret.
|
||||
# The file behind each key lives on the host: `caSources` names it, and
|
||||
# ./runtime.nix publishes the ConfigMap from those files.
|
||||
caConfigMap = "hyperhive-ca-trust";
|
||||
trustBundleKey = "trust-bundle.pem";
|
||||
baoServerCaKey = "bao-server-ca.pem";
|
||||
caSources = {
|
||||
${trustBundleKey} = if caTrust.useSelfSigned then caTrust.caHostPath else null;
|
||||
${baoServerCaKey} = baoDeployCfg.serverCaFile;
|
||||
};
|
||||
|
||||
# `serviceUser` is the user every image runs its daemon as. Mounted files are
|
||||
# group-owned by its group through `fsGroup`.
|
||||
|
|
@ -61,6 +73,9 @@ let
|
|||
# /readyz listener; the controller serves /readyz on its unix socket only,
|
||||
# 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"`.
|
||||
services = {
|
||||
swarm-controller = {
|
||||
inherit (deployCfg.swarm-controller) enable package;
|
||||
|
|
@ -69,14 +84,19 @@ let
|
|||
healthEnv = null;
|
||||
etcFiles = [ "hyperhive/swarm-controller.json" ];
|
||||
publicCredentials = { };
|
||||
switch = null;
|
||||
};
|
||||
swarm-notify-router = {
|
||||
inherit (deployCfg.notify-router) enable package;
|
||||
unit = config.containers.swarm-notify-router.config.systemd.services.swarm-notify-router;
|
||||
unit = deployCfg.notify-router.unit;
|
||||
kind = "Deployment";
|
||||
healthEnv = "SWARM_NOTIFY_ROUTER_HEALTH_ADDR";
|
||||
etcFiles = [ ];
|
||||
publicCredentials.notify-router-bao-server-ca = baoServerCaKey;
|
||||
switch = {
|
||||
inherit (deployCfg.notify-router) runtime;
|
||||
hostUnit = "container@swarm-notify-router.service";
|
||||
};
|
||||
};
|
||||
swarm-ci-metrics = {
|
||||
inherit (deployCfg.ci-metrics) enable package;
|
||||
|
|
@ -86,6 +106,7 @@ let
|
|||
healthEnv = null;
|
||||
etcFiles = [ ];
|
||||
publicCredentials = { };
|
||||
switch = null;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -544,4 +565,15 @@ in
|
|||
# The image each enabled service's pod runs: what a node has to hold,
|
||||
# since there is no registry to pull from.
|
||||
images = lib.mapAttrsToList (_: w: w.image) enabled;
|
||||
|
||||
# What ./runtime.nix moves services with. `switches` holds the services that
|
||||
# have a runtime option and is cheap to read: it names the units that a
|
||||
# switch adds or removes, so it cannot depend on rendering a unit. `services`
|
||||
# holds the objects. `caSources` is the host file behind each key of the CA
|
||||
# ConfigMap, null where there is none.
|
||||
switches = lib.mapAttrs (_: svc: svc.switch) (
|
||||
lib.filterAttrs (_: svc: svc.enable && svc.switch != null) services
|
||||
);
|
||||
services = lib.mapAttrs (_: w: { inherit (w) objects; }) enabled;
|
||||
inherit caConfigMap caSources;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue