Compare commits
8 commits
master
...
pr-simulac
Author | SHA1 | Date | |
---|---|---|---|
f73ad62ed5 | |||
5853b69982 | |||
059e76d959 | |||
7e2f7e3fde | |||
88fa396e31 | |||
d19745cd69 | |||
d160865db4 | |||
3a61dbca1d |
10 changed files with 20 additions and 7 deletions
|
@ -1,9 +1,8 @@
|
||||||
{ config, lib, name, ... }:
|
{ config, lib, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
filterGroup = group: hostName: builtins.filter (x: x != hostName) group;
|
filterGroup = group: hostName: builtins.filter (x: x != hostName) group;
|
||||||
serviceName = name;
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -65,6 +64,11 @@ in
|
||||||
type = types.deferredModule;
|
type = types.deferredModule;
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
availableNodes = mkOption {
|
||||||
|
description = "Nodes to include in the scenario.";
|
||||||
|
type = with types; nullOr (listOf str);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config.otherNodes = builtins.mapAttrs (const filterGroup) config.nodes;
|
config.otherNodes = builtins.mapAttrs (const filterGroup) config.nodes;
|
||||||
|
|
|
@ -25,7 +25,7 @@ in
|
||||||
bind_addr = hl.ipv4;
|
bind_addr = hl.ipv4;
|
||||||
ports.serf_lan = hl.port;
|
ports.serf_lan = hl.port;
|
||||||
retry_join = map (hostName: hostLinks.${hostName}.consul.tuple) (cfg.otherNodes.agent hostName);
|
retry_join = map (hostName: hostLinks.${hostName}.consul.tuple) (cfg.otherNodes.agent hostName);
|
||||||
bootstrap_expect = builtins.length cfg.nodes.agent;
|
bootstrap_expect = 3;
|
||||||
addresses.http = config.links.consulAgent.ipv4;
|
addresses.http = config.links.consulAgent.ipv4;
|
||||||
ports.http = config.links.consulAgent.port;
|
ports.http = config.links.consulAgent.port;
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
deps = [ "wireguard" ];
|
deps = [ "wireguard" ];
|
||||||
settings = ./test.nix;
|
settings = ./test.nix;
|
||||||
|
availableNodes = lib.take 3 cfg.nodes.agent;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
deps = [ "consul" "acme-client" "patroni" ];
|
deps = [ "consul" "acme-client" "patroni" ];
|
||||||
settings = ./test.nix;
|
settings = ./test.nix;
|
||||||
|
availableNodes = cfg.nodes.authoritative;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
deps = [ "consul" "incandescence" "locksmith" ];
|
deps = [ "consul" "incandescence" "locksmith" ];
|
||||||
settings = ./simulacrum/test.nix;
|
settings = ./simulacrum/test.nix;
|
||||||
|
availableNodes = config.services.patroni.nodes.worker;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
deps = [ "wireguard" "consul" "locksmith" "dns" "incandescence" "ways" ];
|
deps = [ "wireguard" "consul" "locksmith" "dns" "incandescence" "ways" ];
|
||||||
settings = ./simulacrum/test.nix;
|
settings = ./simulacrum/test.nix;
|
||||||
|
availableNodes = config.services.storage.nodes.garage;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
deps = [ "nginx" "acme-client" "dns" "certificates" "consul" ];
|
deps = [ "nginx" "acme-client" "dns" "certificates" "consul" ];
|
||||||
settings = ./simulacrum/test.nix;
|
settings = ./simulacrum/test.nix;
|
||||||
|
availableNodes = lib.take 3 config.services.ways.nodes.host;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
(lib.genAttrs cluster.config.services.ways.nodes.host (lib.const {
|
(lib.genAttrs cluster.config.services.ways.simulacrum.availableNodes (lib.const {
|
||||||
services.nginx.upstreams.nowhere.servers = {
|
services.nginx.upstreams.nowhere.servers = {
|
||||||
"${(builtins.head config.nodes.nowhere.networking.interfaces.eth1.ipv4.addresses).address}:8080" = {};
|
"${(builtins.head config.nodes.nowhere.networking.interfaces.eth1.ipv4.addresses).address}:8080" = {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,8 +22,10 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = lib.attrNames config.gods.fromLight;
|
nodesConfigured = config.cluster.config.services.${service}.simulacrum.availableNodes;
|
||||||
nodes' = lib.attrNames (config.gods.fromLight // { nowhere = null; });
|
availableNodes = if nodesConfigured == null then config.gods.fromLight else lib.genAttrs nodesConfigured (_: throw "unreachable");
|
||||||
|
nodes = lib.attrNames availableNodes;
|
||||||
|
nodes' = lib.attrNames (availableNodes // { nowhere = null; });
|
||||||
digits = lib.attrsets.listToAttrs (lib.zipListsWith lib.nameValuePair nodes' (lib.range 1 255));
|
digits = lib.attrsets.listToAttrs (lib.zipListsWith lib.nameValuePair nodes' (lib.range 1 255));
|
||||||
depot' = extendModules {
|
depot' = extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
|
|
|
@ -52,6 +52,8 @@ let
|
||||||
genHostCert = hostname: genCert [ "--hostname=${hostname}" ] { CN = hostname; };
|
genHostCert = hostname: genCert [ "--hostname=${hostname}" ] { CN = hostname; };
|
||||||
|
|
||||||
getNodeAddr = node: (builtins.head config.nodes.${node}.networking.interfaces.eth1.ipv4.addresses).address;
|
getNodeAddr = node: (builtins.head config.nodes.${node}.networking.interfaces.eth1.ipv4.addresses).address;
|
||||||
|
|
||||||
|
filterActiveNodes = lib.filterAttrs (node: _: config.nodes ? ${node});
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -79,7 +81,7 @@ in
|
||||||
address = hour.interfaces.primary.addrPublic;
|
address = hour.interfaces.primary.addrPublic;
|
||||||
prefixLength = 32;
|
prefixLength = 32;
|
||||||
via = getNodeAddr name;
|
via = getNodeAddr name;
|
||||||
}) depot.gods.fromLight;
|
}) (filterActiveNodes depot.gods.fromLight);
|
||||||
nameservers = map (name: depot.hours.${name}.interfaces.primary.addrPublic) cluster.config.services.dns.nodes.authoritative;
|
nameservers = map (name: depot.hours.${name}.interfaces.primary.addrPublic) cluster.config.services.dns.nodes.authoritative;
|
||||||
};
|
};
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
|
|
Loading…
Reference in a new issue