Automate hw config import

This commit is contained in:
Jonas Juselius
2020-11-25 10:12:57 +01:00
parent 898b2800fd
commit e36126e429

View File

@@ -35,7 +35,9 @@ in {
cfg cfg
{ {
hostName = host.name; hostName = host.name;
address = host.address;
k8s.master.enable = true; k8s.master.enable = true;
k8s.node.enable = true;
} }
]; ];
@@ -53,6 +55,7 @@ in {
cfg cfg
{ {
hostName = host.name; hostName = host.name;
address = host.address;
k8s.node.enable = true; k8s.node.enable = true;
} }
]; ];
@@ -62,18 +65,20 @@ in {
imports = [ host.hw ./modules.nix ../overrides/kubelet.nix ]; imports = [ host.hw ./modules.nix ../overrides/kubelet.nix ];
}; };
mkDeployment = mkDeployment = top:
let let
master = cfg.k8s.master; master = cfg.k8s.master // { hw = "${top}/${master.name}.nix"; };
nodes = cfg.k8s.nodes; nodes = cfg.k8s.nodes;
server = { "${master.name}" = apiserver master; }; server = { "${master.name}" = apiserver master; };
in in
builtins.foldl' (a: x: builtins.foldl' (a: x:
a // { "${x.name}" = node x; }) server nodes; a // {
"${x.name}" = node (x // { hw = "${top}/${x.name}.nix"; });
}) server nodes;
}; };
fs = rec { fs = rec {
mkNode = host: self: { node = host: self: {
deployment.targetHost = host.address; deployment.targetHost = host.address;
inherit customize; inherit customize;
@@ -82,16 +87,19 @@ in {
cfg cfg
{ {
hostName = host.name; hostName = host.name;
address = host.address;
cert = mkCert host.name; cert = mkCert host.name;
} }
]; ];
imports = [ ../overrides host.hw ./modules.nix ]; imports = [ host.hw ./modules.nix ];
}; };
mkDeployment = nodes: mkDeployment = top: nodes:
builtins.foldl' (a: x: builtins.foldl' (a: x:
a // { "${x.name}" = mkNode x; }) {} nodes; a // {
"${x.name}" = node (x // { hw = "${top}/${x.name}.nix"; });
}) {} nodes;
} ; } ;
host = rec { host = rec {
@@ -104,6 +112,7 @@ in {
cfg cfg
{ {
hostName = host.name; hostName = host.name;
address = host.address;
cert = mkCert host.name; cert = mkCert host.name;
} }
]; ];
@@ -111,8 +120,10 @@ in {
imports = [ host.hw ./modules.nix ]; imports = [ host.hw ./modules.nix ];
}; };
mkDeployment = nodes: mkDeployment = top: nodes:
builtins.foldl' (a: x: builtins.foldl' (a: x:
a // { "${x.name}" = node x; }) {} nodes; a // {
"${x.name}" = node (x // { hw = "${top}/${x.name}.nix"; });
}) {} nodes;
}; };
} }