semi-spread example: name the store's CA on the machines without the store
This commit is contained in:
parent
1ad4ebdd7b
commit
250118d558
5 changed files with 36 additions and 13 deletions
|
|
@ -170,10 +170,12 @@ addresses for you, so the key steps above go away. Three things change:
|
||||||
## Reading the store
|
## Reading the store
|
||||||
|
|
||||||
Only `swarm-central` runs the secret store, and every service on the other
|
Only `swarm-central` runs the secret store, and every service on the other
|
||||||
machines reads it with a client certificate that the store's host mints. The
|
machines reads it with a client certificate that the store's host mints, and
|
||||||
example names each leaf under `/var/lib/swarm-pki/` on the machine that uses
|
checks the store against its CA (`ca.pem`). The example names each leaf, and
|
||||||
it. After the first deploy of `swarm-central`, copy the files from
|
`ca.pem`, under `/var/lib/swarm-pki/` on the machine that uses it. Without
|
||||||
`/var/lib/swarm-bao-pki/` there over the VPN (for a hive, from
|
`ca.pem` the machines don't trust the store's certificate. After the first
|
||||||
|
deploy of `swarm-central`, copy the files from `/var/lib/swarm-bao-pki/` there
|
||||||
|
over the VPN (for a hive, `ca.pem` and the files from
|
||||||
`/var/lib/swarm-bao-pki/hives/<name>/`), then deploy the other machines. The
|
`/var/lib/swarm-bao-pki/hives/<name>/`), then deploy the other machines. The
|
||||||
private keys travel over a channel you trust and stay readable by root only.
|
private keys travel over a channel you trust and stay readable by root only.
|
||||||
[`credentials.md`](credentials.md) lists which leaf each service reads and what
|
[`credentials.md`](credentials.md) lists which leaf each service reads and what
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,12 @@ let
|
||||||
hyperhive = config.services.hyperhive;
|
hyperhive = config.services.hyperhive;
|
||||||
name = lib.removePrefix "hive-" config.networking.hostName;
|
name = lib.removePrefix "hive-" config.networking.hostName;
|
||||||
|
|
||||||
# The leaves for this hive, copied from swarm-central, where the secret store
|
# The store's CA (`ca.pem`, from `/var/lib/swarm-bao-pki/`) and the leaves
|
||||||
# runs: `client.pem` and `client-key.pem` from
|
# for this hive, copied from swarm-central, where the secret store runs:
|
||||||
|
# `client.pem` and `client-key.pem` from
|
||||||
# `/var/lib/swarm-bao-pki/hives/<name>/`, along with that directory's
|
# `/var/lib/swarm-bao-pki/hives/<name>/`, along with that directory's
|
||||||
# `hive-leaf.pem` and `hive-leaf-key.pem`, which the hive's gateway
|
# `hive-leaf.pem` and `hive-leaf-key.pem`, which the hive's gateway
|
||||||
# certificate comes from. Both pairs sit in one directory.
|
# certificate comes from. All of them sit in one directory.
|
||||||
pki = "/var/lib/swarm-pki";
|
pki = "/var/lib/swarm-pki";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -20,6 +21,7 @@ in
|
||||||
hiveName = name;
|
hiveName = name;
|
||||||
};
|
};
|
||||||
bao = {
|
bao = {
|
||||||
|
serverCaFile = "${pki}/ca.pem";
|
||||||
clientCertFile = "${pki}/client.pem";
|
clientCertFile = "${pki}/client.pem";
|
||||||
clientKeyFile = "${pki}/client-key.pem";
|
clientKeyFile = "${pki}/client-key.pem";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
let
|
let
|
||||||
hyperhive = config.services.hyperhive;
|
hyperhive = config.services.hyperhive;
|
||||||
|
|
||||||
# Leaves copied from swarm-central, where the secret store runs. See
|
# The store's CA and the leaves, copied from swarm-central, where the secret
|
||||||
# swarm-services.nix for the helper's naming.
|
# store runs. See swarm-services.nix for the helper's naming.
|
||||||
pki = "/var/lib/swarm-pki";
|
pki = "/var/lib/swarm-pki";
|
||||||
pair = option: stem: {
|
pair = option: stem: {
|
||||||
"${option}ClientCertFile" = "${pki}/${stem}.pem";
|
"${option}ClientCertFile" = "${pki}/${stem}.pem";
|
||||||
|
|
@ -23,6 +23,7 @@ in
|
||||||
});
|
});
|
||||||
|
|
||||||
deploy.bao = lib.mergeAttrsList [
|
deploy.bao = lib.mergeAttrsList [
|
||||||
|
{ serverCaFile = "${pki}/ca.pem"; }
|
||||||
(pair "builder" "builder")
|
(pair "builder" "builder")
|
||||||
(pair "ciRunner" "ci-runner")
|
(pair "ciRunner" "ci-runner")
|
||||||
(pair "attic" "attic")
|
(pair "attic" "attic")
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@
|
||||||
let
|
let
|
||||||
hyperhive = config.services.hyperhive;
|
hyperhive = config.services.hyperhive;
|
||||||
|
|
||||||
# The secret store runs on swarm-central, so each service here reads it with
|
# The secret store runs on swarm-central, so each service here checks it
|
||||||
# a leaf copied from there. `pair "grafanaOidc" "grafana-oidc"` names the
|
# against the CA (`ca.pem`) and reads it with a leaf, both copied from there.
|
||||||
# options `deploy.bao.grafanaOidcClientCertFile` and `…KeyFile` and the files
|
# `pair "grafanaOidc" "grafana-oidc"` names the options
|
||||||
|
# `deploy.bao.grafanaOidcClientCertFile` and `…KeyFile` and the files
|
||||||
# `grafana-oidc.pem` and `grafana-oidc-key.pem`.
|
# `grafana-oidc.pem` and `grafana-oidc-key.pem`.
|
||||||
pki = "/var/lib/swarm-pki";
|
pki = "/var/lib/swarm-pki";
|
||||||
pair = option: stem: {
|
pair = option: stem: {
|
||||||
|
|
@ -37,7 +38,10 @@ in
|
||||||
});
|
});
|
||||||
|
|
||||||
deploy.bao = lib.mergeAttrsList [
|
deploy.bao = lib.mergeAttrsList [
|
||||||
{ enable = false; }
|
{
|
||||||
|
enable = false;
|
||||||
|
serverCaFile = "${pki}/ca.pem";
|
||||||
|
}
|
||||||
(pair "forgePublisher" "forge-publisher")
|
(pair "forgePublisher" "forge-publisher")
|
||||||
(pair "servicesIssuer" "services-issuer")
|
(pair "servicesIssuer" "services-issuer")
|
||||||
(pair "grafanaOidc" "grafana-oidc")
|
(pair "grafanaOidc" "grafana-oidc")
|
||||||
|
|
|
||||||
|
|
@ -488,6 +488,20 @@ let
|
||||||
&& lib.all (p: lib.any (a: lib.hasSuffix "/128" a) p.allowedIPs) wg.peers
|
&& lib.all (p: lib.any (a: lib.hasSuffix "/128" a) p.allowedIPs) wg.peers
|
||||||
) (builtins.attrNames all);
|
) (builtins.attrNames all);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
# The store's certificate is signed by its own CA, which only the store's
|
||||||
|
# host has by default; every machine without the store names the copy.
|
||||||
|
name = "every machine without the store checks it against the CA copied from swarm-central";
|
||||||
|
ok =
|
||||||
|
lib.all (n: all.${n}.services.hyperhive.deploy.bao.serverCaFile == "/var/lib/swarm-pki/ca.pem") [
|
||||||
|
"swarm-services"
|
||||||
|
"swarm-heavyduty"
|
||||||
|
"hive-one"
|
||||||
|
"hive-two"
|
||||||
|
]
|
||||||
|
# Control: the machine with the store keeps the CA it minted.
|
||||||
|
&& central.services.hyperhive.deploy.bao.serverCaFile == "/var/lib/swarm-bao-pki/ca.pem";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "a hive resolves the internal names to the IPv6 addresses as well";
|
name = "a hive resolves the internal names to the IPv6 addresses as well";
|
||||||
ok =
|
ok =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue