k8s: deploy.review-classifier.runtime and deploy.claude-login.runtime move the claude daemons between their containers and the cluster
This commit is contained in:
parent
d747a63ca8
commit
2110f51ff9
5 changed files with 491 additions and 276 deletions
|
|
@ -790,6 +790,9 @@ in
|
|||
and `reviewClassifierClientKeyFile`, minted on the store's host). The
|
||||
key is never written for you: until the operator writes it the service
|
||||
runs and every run fails with "no API key…".
|
||||
|
||||
Set {option}`services.hyperhive.deploy.review-classifier.runtime` to
|
||||
`k8s` to run it as a pod in the host's cluster instead.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -810,6 +813,9 @@ in
|
|||
host has the minter's store identity (the pair
|
||||
{option}`services.hyperhive.deploy.bao.claudeLoginClientCertFile`
|
||||
and `claudeLoginClientKeyFile`, minted on the store's host).
|
||||
|
||||
Set {option}`services.hyperhive.deploy.claude-login.runtime` to `k8s`
|
||||
to run it as a pod in the host's cluster instead.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,32 @@ let
|
|||
hostUnit = "container@swarm-stt.service";
|
||||
};
|
||||
};
|
||||
swarm-review-classifier = {
|
||||
inherit (deployCfg.review-classifier) enable package;
|
||||
unit = deployCfg.review-classifier.unit;
|
||||
kind = "Deployment";
|
||||
healthEnv = "SWARM_REVIEW_CLASSIFIER_HEALTH_ADDR";
|
||||
etcFiles = [ ];
|
||||
publicCredentials.review-classifier-bao-server-ca = baoServerCaKey;
|
||||
otlp = "hive";
|
||||
switch = {
|
||||
inherit (deployCfg.review-classifier) runtime;
|
||||
hostUnit = "container@swarm-review-classifier.service";
|
||||
};
|
||||
};
|
||||
swarm-claude-login = {
|
||||
inherit (deployCfg.claude-login) enable package;
|
||||
unit = deployCfg.claude-login.unit;
|
||||
kind = "Deployment";
|
||||
healthEnv = "SWARM_CLAUDE_LOGIN_HEALTH_ADDR";
|
||||
etcFiles = [ ];
|
||||
publicCredentials.claude-login-bao-server-ca = baoServerCaKey;
|
||||
otlp = "hive";
|
||||
switch = {
|
||||
inherit (deployCfg.claude-login) runtime;
|
||||
hostUnit = "container@swarm-claude-login.service";
|
||||
};
|
||||
};
|
||||
swarm-ci-metrics = {
|
||||
inherit (deployCfg.ci-metrics) enable package;
|
||||
unit = deployCfg.ci-metrics.unit;
|
||||
|
|
|
|||
|
|
@ -412,7 +412,12 @@ let
|
|||
# principal's name, policy and token lifetimes, and its ServiceAccount is
|
||||
# named after it (../k8s/render.nix renders the pod under that account).
|
||||
k8sPrincipals =
|
||||
notifyRouterReaders ++ sttReaders ++ ciMetricsReaders ++ [ { name = controllerPolicyName; } ];
|
||||
notifyRouterReaders
|
||||
++ sttReaders
|
||||
++ reviewClassifierReaders
|
||||
++ claudeLoginWriters
|
||||
++ ciMetricsReaders
|
||||
++ [ { name = controllerPolicyName; } ];
|
||||
|
||||
# The jwt role of one principal: the token of exactly its ServiceAccount, for
|
||||
# this store's audience. Both the subject and the audience are bound, so a
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
# and the pasted code over the queue, and the daemon runs `claude auth login`
|
||||
# and writes the credentials to that agent's store leaf.
|
||||
# docs/4-implementation/swarm/claude-login.md has the design.
|
||||
# With `deploy.claude-login.runtime = "k8s"` it runs as a pod instead, rendered
|
||||
# from the unit below (docs/4-implementation/k8s/runtime.md).
|
||||
#
|
||||
# Its own network namespace on the bridge, as ./swarm-review-classifier.nix
|
||||
# has: it reaches the swarm services by name and nothing on the host's
|
||||
|
|
@ -90,84 +92,13 @@ let
|
|||
forwarderCredential = id: "/run/credentials/${forwarderUnit}.service/${id}";
|
||||
|
||||
privateNetwork = true;
|
||||
in
|
||||
{
|
||||
options.services.hyperhive.swarm.claude-login.clientId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
readOnly = true;
|
||||
default = "swarm-claude-login";
|
||||
description = ''
|
||||
The OAuth2 client id the claude login minter presents to the swarm
|
||||
queue. Read-only: the host running authelia registers it, the queue's
|
||||
auth-callout responder grants it the login subject, and
|
||||
authelia's mint stores its secret in the store, all from this one value.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.claude-login.package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
defaultText = lib.literalExpression "hyperhive.packages.\${system}.swarm-claude-login";
|
||||
description = "The claude login minter daemon package.";
|
||||
};
|
||||
onK8s = cfg.runtime == "k8s";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = haveClientIdentity;
|
||||
message = ''
|
||||
services.hyperhive.deploy.claude-login.enable requires the minter's
|
||||
swarm-secret-store client identity: set both
|
||||
|
||||
services.hyperhive.deploy.bao.claudeLoginClientCertFile
|
||||
services.hyperhive.deploy.bao.claudeLoginClientKeyFile
|
||||
|
||||
The minter reads its queue client secret and writes agents' claude
|
||||
credentials with it.
|
||||
|
||||
Both default to the pair glue-bao-tls.nix mints when
|
||||
services.hyperhive.deploy.bao.enable is true (the host that runs the
|
||||
store). Otherwise copy claude-login.pem and claude-login-key.pem from
|
||||
the store host's /var/lib/swarm-bao-pki/ and name them in those two
|
||||
options.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = lib.all oneWord (lib.attrValues storeFiles);
|
||||
message = ''
|
||||
The claude login minter's store identity paths must not contain
|
||||
whitespace: nspawn's --load-credential receives them through
|
||||
nixos-container's unquoted extra flags.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# The container hangs off the bridge, takes its address from the gateway's
|
||||
# DHCP and resolves through its dnsmasq.
|
||||
services.hyperhive.network.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.dns.enable = lib.mkDefault true;
|
||||
|
||||
# nspawn fails to start the container when a credential source is
|
||||
# missing, so where this host mints the leaf the container waits for it.
|
||||
systemd.services."container@${machine}" = lib.mkMerge [
|
||||
caTrust.containerOrdering
|
||||
(rootfsCheck.warnOnly machine)
|
||||
{ after = [ "swarm-bao-pki.service" ]; }
|
||||
];
|
||||
|
||||
containers.${machine} = {
|
||||
autoStart = true;
|
||||
# The daemon keeps no state; each login's scratch directory is under
|
||||
# PrivateTmp.
|
||||
ephemeral = false;
|
||||
# No `--link-journal=host`: the journal stays in the guest, where the
|
||||
# container's own forwarder reads it (../container-modules/swarm-journal-forwarder.nix).
|
||||
extraFlags = lib.mapAttrsToList (id: source: "--load-credential=${id}:${source}") storeFiles;
|
||||
inherit privateNetwork;
|
||||
hostBridge = networkCfg.bridgeName;
|
||||
bindMounts = caTrust.bindMount;
|
||||
|
||||
config =
|
||||
# The module the container runs: its own NixOS system on the host's bridge,
|
||||
# or, with the service on the cluster, only the source of the unit the pod is
|
||||
# rendered from (`deploy.claude-login.unit`).
|
||||
containerConfig =
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
|
|
@ -260,6 +191,164 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# The container's system, evaluated as `containers.<name>.config` evaluates
|
||||
# it, for a host that has no such container.
|
||||
podSystem =
|
||||
(import "${pkgs.path}/nixos/lib/eval-config.nix" {
|
||||
modules = [
|
||||
(
|
||||
{ options, ... }:
|
||||
{
|
||||
config = {
|
||||
nixpkgs =
|
||||
if options.nixpkgs ? hostPlatform then
|
||||
{ inherit (pkgs.stdenv) hostPlatform; }
|
||||
else
|
||||
{ localSystem = pkgs.stdenv.hostPlatform; };
|
||||
boot.isNspawnContainer = true;
|
||||
networking.hostName = lib.mkDefault machine;
|
||||
networking.useDHCP = false;
|
||||
};
|
||||
}
|
||||
)
|
||||
containerConfig
|
||||
];
|
||||
system = null;
|
||||
}).config;
|
||||
in
|
||||
{
|
||||
options.services.hyperhive.swarm.claude-login.clientId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
readOnly = true;
|
||||
default = "swarm-claude-login";
|
||||
description = ''
|
||||
The OAuth2 client id the claude login minter presents to the swarm
|
||||
queue. Read-only: the host running authelia registers it, the queue's
|
||||
auth-callout responder grants it the login subject, and
|
||||
authelia's mint stores its secret in the store, all from this one value.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.claude-login.package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
defaultText = lib.literalExpression "hyperhive.packages.\${system}.swarm-claude-login";
|
||||
description = "The claude login minter daemon package.";
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.claude-login.runtime = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"host"
|
||||
"k8s"
|
||||
];
|
||||
default = "host";
|
||||
description = ''
|
||||
Where the claude login minter runs: `host` in its `swarm-claude-login`
|
||||
container, or `k8s` as a pod in this host's cluster
|
||||
({option}`services.hyperhive.deploy.k8s.enable`), which the host's
|
||||
configuration must enable. A switch moves the service: the container
|
||||
goes and its objects are applied, or the objects are deleted and the
|
||||
container returns. The service keeps no state, so nothing moves with it;
|
||||
each login's scratch directory is in the pod's `/tmp` volume and goes with the pod.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.claude-login.unit = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
default =
|
||||
if onK8s then
|
||||
podSystem.systemd.services.${unit}
|
||||
else
|
||||
config.containers.${machine}.config.systemd.services.${unit};
|
||||
description = ''
|
||||
The service's evaluated systemd unit, which the cluster's manifests are
|
||||
rendered from (./k8s/render.nix). It is the unit the
|
||||
container runs, taken from the container's configuration, or from the
|
||||
same configuration evaluated alone when the service runs in the cluster
|
||||
and the host has no container.
|
||||
'';
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = !onK8s || hyperhiveCfg.deploy.k8s.enable;
|
||||
message = ''
|
||||
services.hyperhive.deploy.claude-login.runtime = "k8s" needs the cluster: set
|
||||
services.hyperhive.deploy.k8s.enable on this host, or leave the
|
||||
service's runtime at "host".
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
(lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = haveClientIdentity;
|
||||
message = ''
|
||||
services.hyperhive.deploy.claude-login.enable requires the minter's
|
||||
swarm-secret-store client identity: set both
|
||||
|
||||
services.hyperhive.deploy.bao.claudeLoginClientCertFile
|
||||
services.hyperhive.deploy.bao.claudeLoginClientKeyFile
|
||||
|
||||
The minter reads its queue client secret and writes agents' claude
|
||||
credentials with it.
|
||||
|
||||
Both default to the pair glue-bao-tls.nix mints when
|
||||
services.hyperhive.deploy.bao.enable is true (the host that runs the
|
||||
store). Otherwise copy claude-login.pem and claude-login-key.pem from
|
||||
the store host's /var/lib/swarm-bao-pki/ and name them in those two
|
||||
options.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = lib.all oneWord (lib.attrValues storeFiles);
|
||||
message = ''
|
||||
The claude login minter's store identity paths must not contain
|
||||
whitespace: nspawn's --load-credential receives them through
|
||||
nixos-container's unquoted extra flags.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# The container hangs off the bridge, and the cluster's pods reach the
|
||||
# host's services through it.
|
||||
services.hyperhive.network.enable = lib.mkDefault true;
|
||||
})
|
||||
|
||||
(lib.mkIf (cfg.enable && !onK8s) {
|
||||
# The container takes its address from the gateway's DHCP and resolves
|
||||
# through its dnsmasq.
|
||||
services.hyperhive.gateway.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.dns.enable = lib.mkDefault true;
|
||||
|
||||
# nspawn fails to start the container when a credential source is
|
||||
# missing, so where this host mints the leaf the container waits for it.
|
||||
systemd.services."container@${machine}" = lib.mkMerge [
|
||||
caTrust.containerOrdering
|
||||
(rootfsCheck.warnOnly machine)
|
||||
{ after = [ "swarm-bao-pki.service" ]; }
|
||||
];
|
||||
|
||||
containers.${machine} = {
|
||||
autoStart = true;
|
||||
# The daemon keeps no state; each login's scratch directory is under
|
||||
# PrivateTmp.
|
||||
ephemeral = false;
|
||||
# No `--link-journal=host`: the journal stays in the guest, where the
|
||||
# container's own forwarder reads it (../container-modules/swarm-journal-forwarder.nix).
|
||||
extraFlags = lib.mapAttrsToList (id: source: "--load-credential=${id}:${source}") storeFiles;
|
||||
inherit privateNetwork;
|
||||
hostBridge = networkCfg.bridgeName;
|
||||
bindMounts = caTrust.bindMount;
|
||||
|
||||
config = containerConfig;
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
# the queue, and the daemon runs `claude`, or `opencode` on the ACP runtime,
|
||||
# once per classification and replies.
|
||||
# docs/4-implementation/swarm/review-classifier.md has the design.
|
||||
# With `deploy.review-classifier.runtime = "k8s"` it runs as a pod instead,
|
||||
# rendered from the unit below (docs/4-implementation/k8s/runtime.md).
|
||||
#
|
||||
# ⚠️ Its own network namespace on the bridge, as ./swarm-ci-runner.nix has: a
|
||||
# PR's diff and commit messages are model input, so the container reaches the
|
||||
|
|
@ -110,89 +112,13 @@ let
|
|||
};
|
||||
|
||||
privateNetwork = true;
|
||||
in
|
||||
{
|
||||
options.services.hyperhive.swarm.review-classifier.clientId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
readOnly = true;
|
||||
default = "swarm-review-classifier";
|
||||
description = ''
|
||||
The OAuth2 client id the review classifier presents to the swarm queue.
|
||||
Read-only: the host running authelia registers it, the queue's
|
||||
auth-callout responder grants it the try-out subject, and
|
||||
authelia's mint stores its secret in the store, all from this one value.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.review-classifier.package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
defaultText = lib.literalExpression "hyperhive.packages.\${system}.swarm-review-classifier";
|
||||
description = "The review classifier daemon package.";
|
||||
};
|
||||
onK8s = cfg.runtime == "k8s";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = haveClientIdentity;
|
||||
message = ''
|
||||
services.hyperhive.deploy.review-classifier.enable requires the
|
||||
classifier's swarm-secret-store client identity: set both
|
||||
|
||||
services.hyperhive.deploy.bao.reviewClassifierClientCertFile
|
||||
services.hyperhive.deploy.bao.reviewClassifierClientKeyFile
|
||||
|
||||
The classifier reads its queue client secret and its runtime keys with it.
|
||||
|
||||
Both default to the pair glue-bao-tls.nix mints when
|
||||
services.hyperhive.deploy.bao.enable is true (the host that runs the
|
||||
store). Otherwise copy review-classifier.pem and
|
||||
review-classifier-key.pem from the store host's /var/lib/swarm-bao-pki/
|
||||
and name them in those two options.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = lib.all oneWord (lib.attrValues storeFiles);
|
||||
message = ''
|
||||
The review classifier's store identity paths must not contain
|
||||
whitespace: nspawn's --load-credential receives them through
|
||||
nixos-container's unquoted extra flags.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# The container hangs off the bridge, takes its address from the gateway's
|
||||
# DHCP and resolves through its dnsmasq.
|
||||
services.hyperhive.network.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.dns.enable = lib.mkDefault true;
|
||||
|
||||
# nspawn fails to start the container when a credential source is
|
||||
# missing, so where this host mints the leaf the container pulls the
|
||||
# minting unit in and waits for it. Ordering alone is not enough: the
|
||||
# container starts from `machines.target`, outside the transaction that
|
||||
# runs the minting unit from `multi-user.target`. Ignored elsewhere, where
|
||||
# the unit does not exist.
|
||||
systemd.services."container@${machine}" = lib.mkMerge [
|
||||
caTrust.containerOrdering
|
||||
(rootfsCheck.warnOnly machine)
|
||||
{
|
||||
after = [ "swarm-bao-pki.service" ];
|
||||
wants = [ "swarm-bao-pki.service" ];
|
||||
}
|
||||
];
|
||||
|
||||
containers.${machine} = {
|
||||
autoStart = true;
|
||||
# The daemon keeps no state; its scratch directories are under PrivateTmp.
|
||||
ephemeral = false;
|
||||
# No `--link-journal=host`: the journal stays in the guest, where the
|
||||
# container's own forwarder reads it (../container-modules/swarm-journal-forwarder.nix).
|
||||
extraFlags = lib.mapAttrsToList (id: source: "--load-credential=${id}:${source}") storeFiles;
|
||||
inherit privateNetwork;
|
||||
hostBridge = networkCfg.bridgeName;
|
||||
bindMounts = caTrust.bindMount;
|
||||
|
||||
config =
|
||||
# The module the container runs: its own NixOS system on the host's bridge,
|
||||
# or, with the service on the cluster, only the source of the unit the pod is
|
||||
# rendered from (`deploy.review-classifier.unit`).
|
||||
containerConfig =
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
|
|
@ -274,6 +200,169 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# The container's system, evaluated as `containers.<name>.config` evaluates
|
||||
# it, for a host that has no such container.
|
||||
podSystem =
|
||||
(import "${pkgs.path}/nixos/lib/eval-config.nix" {
|
||||
modules = [
|
||||
(
|
||||
{ options, ... }:
|
||||
{
|
||||
config = {
|
||||
nixpkgs =
|
||||
if options.nixpkgs ? hostPlatform then
|
||||
{ inherit (pkgs.stdenv) hostPlatform; }
|
||||
else
|
||||
{ localSystem = pkgs.stdenv.hostPlatform; };
|
||||
boot.isNspawnContainer = true;
|
||||
networking.hostName = lib.mkDefault machine;
|
||||
networking.useDHCP = false;
|
||||
};
|
||||
}
|
||||
)
|
||||
containerConfig
|
||||
];
|
||||
system = null;
|
||||
}).config;
|
||||
in
|
||||
{
|
||||
options.services.hyperhive.swarm.review-classifier.clientId = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
readOnly = true;
|
||||
default = "swarm-review-classifier";
|
||||
description = ''
|
||||
The OAuth2 client id the review classifier presents to the swarm queue.
|
||||
Read-only: the host running authelia registers it, the queue's
|
||||
auth-callout responder grants it the try-out subject, and
|
||||
authelia's mint stores its secret in the store, all from this one value.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.review-classifier.package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
defaultText = lib.literalExpression "hyperhive.packages.\${system}.swarm-review-classifier";
|
||||
description = "The review classifier daemon package.";
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.review-classifier.runtime = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"host"
|
||||
"k8s"
|
||||
];
|
||||
default = "host";
|
||||
description = ''
|
||||
Where the review classifier runs: `host` in its `swarm-review-classifier`
|
||||
container, or `k8s` as a pod in this host's cluster
|
||||
({option}`services.hyperhive.deploy.k8s.enable`), which the host's
|
||||
configuration must enable. A switch moves the service: the container
|
||||
goes and its objects are applied, or the objects are deleted and the
|
||||
container returns. The service keeps no state, so nothing moves with it;
|
||||
each classification's scratch directory is in the pod's `/tmp` volume and goes with the pod.
|
||||
'';
|
||||
};
|
||||
|
||||
options.services.hyperhive.deploy.review-classifier.unit = lib.mkOption {
|
||||
type = lib.types.raw;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
default =
|
||||
if onK8s then
|
||||
podSystem.systemd.services.${unit}
|
||||
else
|
||||
config.containers.${machine}.config.systemd.services.${unit};
|
||||
description = ''
|
||||
The service's evaluated systemd unit, which the cluster's manifests are
|
||||
rendered from (./k8s/render.nix). It is the unit the
|
||||
container runs, taken from the container's configuration, or from the
|
||||
same configuration evaluated alone when the service runs in the cluster
|
||||
and the host has no container.
|
||||
'';
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = !onK8s || hyperhiveCfg.deploy.k8s.enable;
|
||||
message = ''
|
||||
services.hyperhive.deploy.review-classifier.runtime = "k8s" needs the cluster: set
|
||||
services.hyperhive.deploy.k8s.enable on this host, or leave the
|
||||
service's runtime at "host".
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
(lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = haveClientIdentity;
|
||||
message = ''
|
||||
services.hyperhive.deploy.review-classifier.enable requires the
|
||||
classifier's swarm-secret-store client identity: set both
|
||||
|
||||
services.hyperhive.deploy.bao.reviewClassifierClientCertFile
|
||||
services.hyperhive.deploy.bao.reviewClassifierClientKeyFile
|
||||
|
||||
The classifier reads its queue client secret and its runtime keys with it.
|
||||
|
||||
Both default to the pair glue-bao-tls.nix mints when
|
||||
services.hyperhive.deploy.bao.enable is true (the host that runs the
|
||||
store). Otherwise copy review-classifier.pem and
|
||||
review-classifier-key.pem from the store host's /var/lib/swarm-bao-pki/
|
||||
and name them in those two options.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = lib.all oneWord (lib.attrValues storeFiles);
|
||||
message = ''
|
||||
The review classifier's store identity paths must not contain
|
||||
whitespace: nspawn's --load-credential receives them through
|
||||
nixos-container's unquoted extra flags.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# The container hangs off the bridge, and the cluster's pods reach the
|
||||
# host's services through it.
|
||||
services.hyperhive.network.enable = lib.mkDefault true;
|
||||
})
|
||||
|
||||
(lib.mkIf (cfg.enable && !onK8s) {
|
||||
# The container takes its address from the gateway's DHCP and resolves
|
||||
# through its dnsmasq.
|
||||
services.hyperhive.gateway.enable = lib.mkDefault true;
|
||||
services.hyperhive.gateway.dns.enable = lib.mkDefault true;
|
||||
|
||||
# nspawn fails to start the container when a credential source is
|
||||
# missing, so where this host mints the leaf the container pulls the
|
||||
# minting unit in and waits for it. Ordering alone is not enough: the
|
||||
# container starts from `machines.target`, outside the transaction that
|
||||
# runs the minting unit from `multi-user.target`. Ignored elsewhere, where
|
||||
# the unit does not exist.
|
||||
systemd.services."container@${machine}" = lib.mkMerge [
|
||||
caTrust.containerOrdering
|
||||
(rootfsCheck.warnOnly machine)
|
||||
{
|
||||
after = [ "swarm-bao-pki.service" ];
|
||||
wants = [ "swarm-bao-pki.service" ];
|
||||
}
|
||||
];
|
||||
|
||||
containers.${machine} = {
|
||||
autoStart = true;
|
||||
# The daemon keeps no state; its scratch directories are under PrivateTmp.
|
||||
ephemeral = false;
|
||||
# No `--link-journal=host`: the journal stays in the guest, where the
|
||||
# container's own forwarder reads it (../container-modules/swarm-journal-forwarder.nix).
|
||||
extraFlags = lib.mapAttrsToList (id: source: "--load-credential=${id}:${source}") storeFiles;
|
||||
inherit privateNetwork;
|
||||
hostBridge = networkCfg.bridgeName;
|
||||
bindMounts = caTrust.bindMount;
|
||||
|
||||
config = containerConfig;
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue