diff --git a/clusters/hosts.nix b/clusters/hosts.nix index be232ac..8fa4b38 100644 --- a/clusters/hosts.nix +++ b/clusters/hosts.nix @@ -14,6 +14,8 @@ 10.1.8.62 k2-2 k2-2.itpartner.intern 10.1.8.63 k2-3 k2-3.itpartner.intern 10.1.8.64 k2-4 k2-4.itpartner.intern + 10.1.8.65 k2-5 k2-5.itpartner.intern + 10.1.8.66 k2-6 k2-6.itpartner.intern 10.1.30.100 k1-0 k1-0.itpartner.intern 10.1.30.101 k1-1 k1-1.itpartner.intern diff --git a/clusters/k2/cluster.nix b/clusters/k2/cluster.nix index d8054fd..d1d4b2c 100644 --- a/clusters/k2/cluster.nix +++ b/clusters/k2/cluster.nix @@ -1,7 +1,7 @@ { pkgs, lib, config, ... }: with lib; let - cfg = config.node; + cfg = config.features.k8s.host; mkSANs = host: [ host.name @@ -94,18 +94,6 @@ let }; in { - options.node = { - address = mkOption { - type = types.str; - default = null; - }; - - name = mkOption { - type = types.str; - default = null; - }; - }; - config = configuration; imports = [ diff --git a/clusters/k2/default.nix b/clusters/k2/default.nix index 9cf74f9..3fd4f8a 100644 --- a/clusters/k2/default.nix +++ b/clusters/k2/default.nix @@ -1,10 +1,29 @@ with import {}; let + etcdNodes = { + # k2-0 = "10.1.8.60"; + # k2-1 = "10.1.8.61"; + # k2-2 = "10.1.8.62"; + }; + master = { - node.name = "k2-0"; - node.address = "10.1.8.60"; - features.k8s.master.enable = true; - features.k8s.nodes = nodes; + features.k8s = { + host.name = "k2-0"; + host.address = "10.1.8.60"; + master.enable = true; + nodes = nodes; + etcdCluster = { + enable = false; + nodes = etcdNodes; + }; + }; + fileSystems = { + "/vol/local-storage/vol1" = { + device = "/vol/vol1"; + options = [ "bind" ]; + }; + }; + services.kubernetes.kubelet.unschedulable = true; imports = [ ./cluster.nix ./hw/k2-0.nix ]; }; @@ -13,17 +32,30 @@ let { name = "k2-2"; address = "10.1.8.62"; } { name = "k2-3"; address = "10.1.8.63"; } { name = "k2-4"; address = "10.1.8.64"; } + { name = "k2-5"; address = "10.1.8.65"; } + { name = "k2-6"; address = "10.1.8.66"; } ]; mkNode = x: { - "${x.name}" = { - node.name = x.name; - node.address = x.address; - imports = [ ./cluster.nix (./hw + "/${x.name}.nix") ]; - }; + "${x.name}" = + lib.mkMerge [ + { + features.k8s.host = x; + } + (if builtins.hasAttr x.name etcdNodes then + { + features.k8s.etcdCluster = { + enable = false; + existing = false; + nodes = etcdNodes; + }; + } + else {}) + ] + // { imports = [ ./cluster.nix (./hw + "/${x.name}.nix") ]; }; }; in builtins.foldl' (a: x: a // mkNode x) { - "${master.node.name}" = master; + "${master.features.k8s.host.name}" = master; } nodes diff --git a/clusters/k2/hw/k2-5.nix b/clusters/k2/hw/k2-5.nix new file mode 100644 index 0000000..38edc36 --- /dev/null +++ b/clusters/k2/hw/k2-5.nix @@ -0,0 +1,27 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ ]; + + boot.initrd.availableKernelModules = [ "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9e5acd6c-3e18-40c0-9826-a620812a7bff"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/255E-65E7"; + fsType = "vfat"; + }; + + swapDevices = []; + + virtualisation.hypervGuest.enable = true; +} diff --git a/clusters/k2/hw/k2-6.nix b/clusters/k2/hw/k2-6.nix new file mode 100644 index 0000000..7201fd4 --- /dev/null +++ b/clusters/k2/hw/k2-6.nix @@ -0,0 +1,27 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ ]; + + boot.initrd.availableKernelModules = [ "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/b34e8c50-665b-4a30-99cb-f845d2313cb8"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/51AC-7FD0"; + fsType = "vfat"; + }; + + swapDevices = []; + + virtualisation.hypervGuest.enable = true; +} diff --git a/clusters/k2/k2.nix b/clusters/k2/k2.nix index f452d68..a4ba509 100644 --- a/clusters/k2/k2.nix +++ b/clusters/k2/k2.nix @@ -25,8 +25,7 @@ let mkNode = x: { "${x.name}" = { config, pkgs, ... }: { deployment.tags = [ "node" ]; - node.name = x.name; - node.address = x.address; + node = x; imports = [ ./cluster.nix (./hw + "/${x.name}.nix") ]; }; };