require k8s: swarm services with a pod run in the cluster only
This commit is contained in:
parent
272af0b3e8
commit
57d40ae8ea
1 changed files with 1044 additions and 3125 deletions
|
|
@ -1,15 +1,11 @@
|
|||
# The script that issues the swarm-controller's TCP listener leaf from the
|
||||
# store's `pki` mount, and the two places that run it: the host's
|
||||
# `swarm-controller-tls.service` (../swarm-controller.nix) and the pod's init
|
||||
# and renewal containers (../k8s/render.nix). One script, so the leaf's checks
|
||||
# (name, half-life, the role it is issued through) cannot differ between them.
|
||||
# store's `pki` mount, which the pod's init and renewal containers run
|
||||
# (../k8s/render.nix). The directory is the pod's `emptyDir`, which exists and
|
||||
# belongs to another user.
|
||||
#
|
||||
# Pure function of the evaluated configuration, NOT a NixOS module. `login`
|
||||
# is the command that prints a store token on stdout, `credential` names what
|
||||
# it logs in with (for the error), and `group` is the group the
|
||||
# key is readable by, or null where the files are already the daemon's own.
|
||||
# `createDir` is false where the directory exists and belongs to another user,
|
||||
# as an `emptyDir` does in a pod.
|
||||
# is the command that prints a store token on stdout, and `credential` names
|
||||
# what it logs in with (for the error).
|
||||
{ lib, config }:
|
||||
let
|
||||
deployCfg = config.services.hyperhive.deploy;
|
||||
|
|
@ -21,19 +17,11 @@ in
|
|||
{
|
||||
login,
|
||||
credential,
|
||||
group,
|
||||
createDir ? true,
|
||||
}:
|
||||
let
|
||||
groupFlag = lib.optionalString (group != null) " -g ${group}";
|
||||
mkDir = lib.optionalString createDir "install -d -m 0750${groupFlag} \"$d\"";
|
||||
chgrp = lib.optionalString (group != null) "chgrp ${group} \"$d/key.pem.new\" \"$d/cert.pem.new\"";
|
||||
in
|
||||
''
|
||||
set -euo pipefail
|
||||
d=${lib.escapeShellArg tcpHost.tlsDir}
|
||||
name=${lib.escapeShellArg tcpCfg.domain}
|
||||
${mkDir}
|
||||
|
||||
# Missing, past half its window, or naming something other than the
|
||||
# configured domain.
|
||||
|
|
@ -76,7 +64,6 @@ in
|
|||
exit 1
|
||||
fi
|
||||
done
|
||||
${chgrp}
|
||||
chmod 0640 "$d/key.pem.new" "$d/cert.pem.new"
|
||||
# Key first: the daemon pairs whatever it reads, and a new key beside
|
||||
# the old certificate is a pair it refuses and retries.
|
||||
|
|
|
|||
Loading…
Reference in a new issue