pin queue and poller state to per-service node labels instead of the hostname
This commit is contained in:
parent
cafbf3262f
commit
ff2bdea78d
1 changed files with 348 additions and 40 deletions
|
|
@ -67,6 +67,15 @@ let
|
|||
# is passed explicitly below, so the address the host's resolver forwards
|
||||
# to and the one CoreDNS gets agree by construction.
|
||||
clusterDns = intToIp (networkOf cfg.serviceCidr + 10);
|
||||
|
||||
labels = import ./labels.nix;
|
||||
deployCfg = config.services.hyperhive.deploy;
|
||||
|
||||
# The services whose data the module keeps in the cluster: those with a
|
||||
# `runtime` that is `k8s`. Each puts its state label on this node.
|
||||
stateful = lib.filterAttrs (_: svc: svc.enable && svc.runtime == "k8s") {
|
||||
inherit (deployCfg) nats ci-metrics;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.services.hyperhive.deploy.k8s = {
|
||||
|
|
@ -176,6 +185,37 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
nodeLabels = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.str;
|
||||
readOnly = true;
|
||||
default =
|
||||
lib.genAttrs [
|
||||
labels.entryLabel
|
||||
labels.loadBalancerLabel
|
||||
] (_: "true")
|
||||
// lib.mapAttrs' (name: _: lib.nameValuePair (labels.stateLabel name) "true") stateful;
|
||||
defaultText = lib.literalMD "computed from the services whose `runtime` is `k8s`";
|
||||
description = ''
|
||||
The labels this node carries, which the module sets with
|
||||
`services.k3s.nodeLabel`. The pods and volumes that need a node select
|
||||
on them, so a node that joins the cluster and has none of them takes
|
||||
none of those pods.
|
||||
|
||||
- `hyperhive.darkest.space/state-<service>` for each service whose data the
|
||||
cluster keeps: `nats` and `ci-metrics`, each when its `runtime` is
|
||||
`k8s`. A volume's `nodeAffinity` and the pod's `nodeSelector` name it.
|
||||
- `hyperhive.darkest.space/entry`: the node the hosts' DNS points at.
|
||||
- `svccontroller.k3s.cattle.io/enablelb`: with it on any node, the
|
||||
service load balancer binds a published port on the labelled nodes
|
||||
only, so a joined node does not publish the queue's port.
|
||||
|
||||
k3s puts these on the node's object at every start, registered or not.
|
||||
It never takes one off: a label left from a service that has moved
|
||||
back to `host` stays and does nothing, and `kubectl label node <name>
|
||||
<label>-` removes one.
|
||||
'';
|
||||
};
|
||||
|
||||
manifestDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
readOnly = true;
|
||||
|
|
@ -232,6 +272,7 @@ in
|
|||
"traefik"
|
||||
"metrics-server"
|
||||
];
|
||||
nodeLabel = lib.mapAttrsToList (k: v: "${k}=${v}") cfg.nodeLabels;
|
||||
extraFlags = [
|
||||
"--secrets-encryption"
|
||||
"--cluster-cidr=${cfg.podCidr}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue