Refactor modules/features a bit

This commit is contained in:
Jonas Juselius
2021-10-06 11:01:00 +02:00
parent 7226e50139
commit d5a0ebc73e
6 changed files with 45 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.features.k8s.host; cfg = config.features.host;
mkSANs = host: [ mkSANs = host: [
host.name host.name

View File

@@ -15,10 +15,13 @@ let
}; };
master = { master = {
features.host = {
name = "k0-0";
address = "10.1.8.50";
};
features.k8s = { features.k8s = {
host.name = "k0-0";
host.address = "10.1.8.50";
master.enable = true; master.enable = true;
master.socat443 = true;
nodes = nodes; nodes = nodes;
inherit etcdCluster; inherit etcdCluster;
}; };
@@ -34,7 +37,7 @@ let
"${x.name}" = "${x.name}" =
lib.mkMerge [ lib.mkMerge [
{ {
features.k8s.host = x; features.host = x;
} }
(if builtins.hasAttr x.name etcdNodes then (if builtins.hasAttr x.name etcdNodes then
{ {
@@ -47,5 +50,5 @@ let
in in
builtins.foldl' (a: x: a // mkNode x) { builtins.foldl' (a: x: a // mkNode x) {
"${master.features.k8s.host.name}" = master; "${master.features.host.name}" = master;
} nodes } nodes

View File

@@ -1,7 +1,7 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.features.k8s.host; cfg = config.features.host;
mkSANs = host: [ mkSANs = host: [
host.name host.name
@@ -96,6 +96,16 @@ let
address = cfg.address; address = cfg.address;
}; };
fileSystems = {
"/vol/local-storage/vol1" = {
device = "/vol/vol1";
options = [ "bind" ];
};
"/vol/local-storage/vol2" = {
device = "/vol/vol2";
options = [ "bind" ];
};
};
}; };
in { in {
config = configuration; config = configuration;

View File

@@ -13,19 +13,18 @@ let
}; };
master = { master = {
features.host = {
name = "k1-0";
address = "10.1.30.100";
};
features.k8s = { features.k8s = {
host.name = "k1-0"; host.name = "k1-0";
host.address = "10.1.30.100"; host.address = "10.1.30.100";
master.enable = true; master.enable = true;
master.socat443 = true;
nodes = nodes; nodes = nodes;
inherit etcdCluster; inherit etcdCluster;
}; };
fileSystems = {
"/vol/local-storage/vol1" = {
device = "/vol/vol1";
options = [ "bind" ];
};
};
imports = [ ./cluster.nix ./hw/k1-0.nix ]; imports = [ ./cluster.nix ./hw/k1-0.nix ];
}; };
@@ -41,7 +40,7 @@ let
"${x.name}" = "${x.name}" =
lib.mkMerge [ lib.mkMerge [
{ {
features.k8s.host = x; features.host = x;
} }
(if builtins.hasAttr x.name etcdNodes then (if builtins.hasAttr x.name etcdNodes then
{ {
@@ -54,6 +53,6 @@ let
in in
builtins.foldl' (a: x: a // mkNode x) { builtins.foldl' (a: x: a // mkNode x) {
"${master.features.k8s.host.name}" = master; "${master.features.host.name}" = master;
} nodes } nodes

View File

@@ -1,7 +1,7 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.features.k8s.host; cfg = config.features.host;
mkSANs = host: [ mkSANs = host: [
host.name host.name
@@ -71,6 +71,17 @@ let
}; };
}; };
fileSystems = {
"/vol/local-storage/vol1" = {
device = "/vol/vol1";
options = [ "bind" ];
};
"/vol/local-storage/vol2" = {
device = "/vol/vol2";
options = [ "bind" ];
};
};
networking = { networking = {
hostName = cfg.name; hostName = cfg.name;
domain = "itpartner.intern"; domain = "itpartner.intern";

View File

@@ -13,19 +13,16 @@ let
}; };
master = { master = {
features.host = {
name = "k2-0";
address = "10.1.8.60";
};
features.k8s = { features.k8s = {
host.name = "k2-0";
host.address = "10.1.8.60";
master.enable = true; master.enable = true;
master.socat443 = true;
nodes = nodes; nodes = nodes;
inherit etcdCluster; inherit etcdCluster;
}; };
fileSystems = {
"/vol/local-storage/vol1" = {
device = "/vol/vol1";
options = [ "bind" ];
};
};
imports = [ ./cluster.nix ./hw/k2-0.nix ]; imports = [ ./cluster.nix ./hw/k2-0.nix ];
}; };
@@ -42,7 +39,7 @@ let
"${x.name}" = "${x.name}" =
lib.mkMerge [ lib.mkMerge [
{ {
features.k8s.host = x; features.host = x;
} }
(if builtins.hasAttr x.name etcdNodes then (if builtins.hasAttr x.name etcdNodes then
{ {
@@ -63,5 +60,5 @@ let
}; };
in in
builtins.foldl' (a: x: a // mkNode x) { builtins.foldl' (a: x: a // mkNode x) {
"${master.features.k8s.host.name}" = master; "${master.features.host.name}" = master;
} nodes } nodes