From d5a0ebc73ed2fcc84a67949850e7607b57cb6f4b Mon Sep 17 00:00:00 2001 From: Jonas Juselius Date: Wed, 6 Oct 2021 11:01:00 +0200 Subject: [PATCH] Refactor modules/features a bit --- clusters/k0/cluster.nix | 2 +- clusters/k0/default.nix | 11 +++++++---- clusters/k1/cluster.nix | 12 +++++++++++- clusters/k1/default.nix | 15 +++++++-------- clusters/k2/cluster.nix | 13 ++++++++++++- clusters/k2/default.nix | 17 +++++++---------- 6 files changed, 45 insertions(+), 25 deletions(-) diff --git a/clusters/k0/cluster.nix b/clusters/k0/cluster.nix index c3a500e..0aada64 100644 --- a/clusters/k0/cluster.nix +++ b/clusters/k0/cluster.nix @@ -1,7 +1,7 @@ { pkgs, lib, config, ... }: with lib; let - cfg = config.features.k8s.host; + cfg = config.features.host; mkSANs = host: [ host.name diff --git a/clusters/k0/default.nix b/clusters/k0/default.nix index ccc963e..5b3e58f 100644 --- a/clusters/k0/default.nix +++ b/clusters/k0/default.nix @@ -15,10 +15,13 @@ let }; master = { + features.host = { + name = "k0-0"; + address = "10.1.8.50"; + }; features.k8s = { - host.name = "k0-0"; - host.address = "10.1.8.50"; master.enable = true; + master.socat443 = true; nodes = nodes; inherit etcdCluster; }; @@ -34,7 +37,7 @@ let "${x.name}" = lib.mkMerge [ { - features.k8s.host = x; + features.host = x; } (if builtins.hasAttr x.name etcdNodes then { @@ -47,5 +50,5 @@ let in builtins.foldl' (a: x: a // mkNode x) { - "${master.features.k8s.host.name}" = master; + "${master.features.host.name}" = master; } nodes diff --git a/clusters/k1/cluster.nix b/clusters/k1/cluster.nix index 4f5a451..de11476 100644 --- a/clusters/k1/cluster.nix +++ b/clusters/k1/cluster.nix @@ -1,7 +1,7 @@ { pkgs, lib, config, ... }: with lib; let - cfg = config.features.k8s.host; + cfg = config.features.host; mkSANs = host: [ host.name @@ -96,6 +96,16 @@ let address = cfg.address; }; + fileSystems = { + "/vol/local-storage/vol1" = { + device = "/vol/vol1"; + options = [ "bind" ]; + }; + "/vol/local-storage/vol2" = { + device = "/vol/vol2"; + options = [ "bind" ]; + }; + }; }; in { config = configuration; diff --git a/clusters/k1/default.nix b/clusters/k1/default.nix index 9415b9a..85537aa 100644 --- a/clusters/k1/default.nix +++ b/clusters/k1/default.nix @@ -13,19 +13,18 @@ let }; master = { + features.host = { + name = "k1-0"; + address = "10.1.30.100"; + }; features.k8s = { host.name = "k1-0"; host.address = "10.1.30.100"; master.enable = true; + master.socat443 = true; nodes = nodes; inherit etcdCluster; }; - fileSystems = { - "/vol/local-storage/vol1" = { - device = "/vol/vol1"; - options = [ "bind" ]; - }; - }; imports = [ ./cluster.nix ./hw/k1-0.nix ]; }; @@ -41,7 +40,7 @@ let "${x.name}" = lib.mkMerge [ { - features.k8s.host = x; + features.host = x; } (if builtins.hasAttr x.name etcdNodes then { @@ -54,6 +53,6 @@ let in builtins.foldl' (a: x: a // mkNode x) { - "${master.features.k8s.host.name}" = master; + "${master.features.host.name}" = master; } nodes diff --git a/clusters/k2/cluster.nix b/clusters/k2/cluster.nix index d1d4b2c..b1c716d 100644 --- a/clusters/k2/cluster.nix +++ b/clusters/k2/cluster.nix @@ -1,7 +1,7 @@ { pkgs, lib, config, ... }: with lib; let - cfg = config.features.k8s.host; + cfg = config.features.host; mkSANs = host: [ 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 = { hostName = cfg.name; domain = "itpartner.intern"; diff --git a/clusters/k2/default.nix b/clusters/k2/default.nix index d365f37..7cec877 100644 --- a/clusters/k2/default.nix +++ b/clusters/k2/default.nix @@ -13,19 +13,16 @@ let }; master = { + features.host = { + name = "k2-0"; + address = "10.1.8.60"; + }; features.k8s = { - host.name = "k2-0"; - host.address = "10.1.8.60"; master.enable = true; + master.socat443 = true; nodes = nodes; inherit etcdCluster; }; - fileSystems = { - "/vol/local-storage/vol1" = { - device = "/vol/vol1"; - options = [ "bind" ]; - }; - }; imports = [ ./cluster.nix ./hw/k2-0.nix ]; }; @@ -42,7 +39,7 @@ let "${x.name}" = lib.mkMerge [ { - features.k8s.host = x; + features.host = x; } (if builtins.hasAttr x.name etcdNodes then { @@ -63,5 +60,5 @@ let }; in builtins.foldl' (a: x: a // mkNode x) { - "${master.features.k8s.host.name}" = master; + "${master.features.host.name}" = master; } nodes