Automate hw config import
This commit is contained in:
@@ -13,17 +13,17 @@ let
|
||||
|
||||
mkCert = host: {
|
||||
${host.name} = pki.gencert {
|
||||
cn = host.name;
|
||||
ca = cfg.ca;
|
||||
o = cfg.clusterName;
|
||||
hosts = [
|
||||
host.name
|
||||
"${host.name}.${cfg.domain}"
|
||||
host.address
|
||||
"127.0.0.1"
|
||||
];
|
||||
};
|
||||
cn = host.name;
|
||||
ca = cfg.ca;
|
||||
o = cfg.clusterName;
|
||||
hosts = [
|
||||
host.name
|
||||
"${host.name}.${cfg.domain}"
|
||||
host.address
|
||||
"127.0.0.1"
|
||||
];
|
||||
};
|
||||
};
|
||||
in {
|
||||
k8s = rec {
|
||||
apiserver = host: self: {
|
||||
@@ -35,7 +35,9 @@ in {
|
||||
cfg
|
||||
{
|
||||
hostName = host.name;
|
||||
address = host.address;
|
||||
k8s.master.enable = true;
|
||||
k8s.node.enable = true;
|
||||
}
|
||||
];
|
||||
|
||||
@@ -53,6 +55,7 @@ in {
|
||||
cfg
|
||||
{
|
||||
hostName = host.name;
|
||||
address = host.address;
|
||||
k8s.node.enable = true;
|
||||
}
|
||||
];
|
||||
@@ -62,18 +65,20 @@ in {
|
||||
imports = [ host.hw ./modules.nix ../overrides/kubelet.nix ];
|
||||
};
|
||||
|
||||
mkDeployment =
|
||||
mkDeployment = top:
|
||||
let
|
||||
master = cfg.k8s.master;
|
||||
master = cfg.k8s.master // { hw = "${top}/${master.name}.nix"; };
|
||||
nodes = cfg.k8s.nodes;
|
||||
server = { "${master.name}" = apiserver master; };
|
||||
in
|
||||
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 {
|
||||
mkNode = host: self: {
|
||||
node = host: self: {
|
||||
deployment.targetHost = host.address;
|
||||
|
||||
inherit customize;
|
||||
@@ -82,16 +87,19 @@ in {
|
||||
cfg
|
||||
{
|
||||
hostName = host.name;
|
||||
address = host.address;
|
||||
cert = mkCert host.name;
|
||||
}
|
||||
];
|
||||
|
||||
imports = [ ../overrides host.hw ./modules.nix ];
|
||||
imports = [ host.hw ./modules.nix ];
|
||||
};
|
||||
|
||||
mkDeployment = nodes:
|
||||
mkDeployment = top: nodes:
|
||||
builtins.foldl' (a: x:
|
||||
a // { "${x.name}" = mkNode x; }) {} nodes;
|
||||
a // {
|
||||
"${x.name}" = node (x // { hw = "${top}/${x.name}.nix"; });
|
||||
}) {} nodes;
|
||||
} ;
|
||||
|
||||
host = rec {
|
||||
@@ -104,6 +112,7 @@ in {
|
||||
cfg
|
||||
{
|
||||
hostName = host.name;
|
||||
address = host.address;
|
||||
cert = mkCert host.name;
|
||||
}
|
||||
];
|
||||
@@ -111,8 +120,10 @@ in {
|
||||
imports = [ host.hw ./modules.nix ];
|
||||
};
|
||||
|
||||
mkDeployment = nodes:
|
||||
mkDeployment = top: nodes:
|
||||
builtins.foldl' (a: x:
|
||||
a // { "${x.name}" = node x; }) {} nodes;
|
||||
a // {
|
||||
"${x.name}" = node (x // { hw = "${top}/${x.name}.nix"; });
|
||||
}) {} nodes;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user