Browse Source

manager: better dhcp

main
Dustin Frisch 6 months ago
parent
commit
2902a741c6
No known key found for this signature in database GPG Key ID: B4C3BF012D9B26BE
  1. 1
      machines/manager/default.nix
  2. 106
      machines/manager/dhcp.nix
  3. 41
      machines/manager/netinstall/default.nix
  4. 10
      machines/node/default.nix
  5. 4
      machines/node/network.nix
  6. 30
      machines/nodes.nix

1
machines/manager/default.nix

@ -15,6 +15,7 @@ with lib;
./mail.nix
#./beegfs.nix
./ntp.nix
./dhcp.nix
./netinstall
./cache.nix
./rdma.nix

106
machines/manager/dhcp.nix

@ -0,0 +1,106 @@
{ pkgs, lib, config, nodes, ... }:
with lib;
{
services.kea = {
dhcp4 = {
enable = true;
settings = {
"valid-lifetime" = 4000;
"renew-timer" = 1000;
"rebind-timer" = 2000;
"interfaces-config" = {
"interfaces" = [ "mngt" "data" ];
};
"lease-database" = {
"type" = "memfile";
"persist" = true;
"name" = "/var/lib/kea/dhcp4.leases";
};
"subnet4" = [
{
"subnet" = "10.32.46.0/24";
"interface" = "mngt";
"option-data" = [
{
"name" = "routers";
"data" = "10.32.46.1";
}
{
"name" = "domain-name-servers";
"data" = "10.0.0.53,10.1.1.10";
}
{
"name" = "domain-name";
"data" = "mngt.${config.networking.domain}";
}
{
"name" = "domain-search";
"data" = "mngt.${config.networking.domain}";
}
];
"pools" = [
{
"pool" = "10.32.46.100-10.32.46.200";
}
];
"reservations" = concatLists (mapAttrsToList
(_: node: optional
(node.config.networking.interfaces."mngt".macAddress != null)
{
"hw-address" = node.config.networking.interfaces."mngt".macAddress;
"ip-address" = "10.32.46.${toString (100 + node.options._module.args.value.nodeId)}";
})
nodes);
}
{
"subnet" = "10.32.47.0/24";
"interface" = "data";
"option-data" = [
{
"name" = "routers";
"data" = "10.32.47.1";
}
{
"name" = "domain-name-servers";
"data" = "10.0.0.53,10.1.1.10";
}
{
"name" = "domain-name";
"data" = config.networking.domain;
}
{
"name" = "domain-search";
"data" = config.networking.domain;
}
];
"pools" = [
{
"pool" = "10.32.47.100-10.32.47.200";
}
];
"reservations" = concatLists (mapAttrsToList
(_: node: optional
(node.config.networking.interfaces."data".macAddress != null)
{
"hw-address" = node.config.networking.interfaces."data".macAddress;
"ip-address" = "10.32.47.${toString (100 + node.options._module.args.value.nodeId)}";
})
nodes);
}
];
};
};
};
}

41
machines/manager/netinstall/default.nix

@ -7,15 +7,15 @@
with lib;
let
targets = {
"50:46:5d:da:0b:d6" = "node-00";
"50:46:5d:da:0c:56" = "node-01";
"10:bf:48:1f:a6:8f" = "node-02";
"10:bf:48:1b:57:47" = "node-03";
"10:bf:48:19:a2:4d" = "node-04";
"10:bf:48:1b:56:df" = "node-05";
"50:46:5d:da:0c:52" = "node-06";
};
targets = [
"node-00"
"node-01"
"node-02"
"node-03"
"node-04"
"node-05"
"node-06"
];
installer = pkgs.nixos [
./installer.nix
@ -59,9 +59,9 @@ let
message = "NixOS Automatic Installer for ${name}";
});
api = pkgs.linkFarm "pixiecore-api" (mapAttrs'
(mac: name: nameValuePair "pixiecore/v1/boot/${mac}" (apiEntry name))
targets);
api = pkgs.linkFarm "pixiecore-api" (listToAttrs (map
(name: nameValuePair "pixiecore/v1/boot/${nodes."${name}".config.networking.interfaces."data".macAddress}" (apiEntry name))
targets));
in
{
services.pixiecore = {
@ -85,23 +85,6 @@ in
};
};
services.dhcpd4 = {
enable = true;
interfaces = [ "enp11s0f0" ];
extraConfig = ''
option domain-name-servers 10.0.0.53, 10.1.1.10;
option domain-name "${config.networking.domain}";
subnet 10.32.47.0 netmask 255.255.255.0 {
interface enp11s0f0;
range 10.32.47.200 10.32.47.230;
option routers 10.32.47.1;
}
'';
};
hpc.hostFile.aliases = [
"boot.${config.networking.domain}"
];

10
machines/node/default.nix

@ -3,6 +3,10 @@
with lib;
let
nodeName = "node-${fixedWidthNumber 2 id}";
in
{
imports = [
./hardware.nix
@ -10,6 +14,7 @@ with lib;
./network.nix
./users.nix
./slurm.nix
(import ../nodes.nix).${nodeName}
];
deployment = {
@ -20,10 +25,11 @@ with lib;
};
_module.args = {
node-id = id;
nodeId = id;
inherit nodeName;
};
networking.hostName = "node-${fixedWidthNumber 2 id}";
networking.hostName = nodeName;
networking.timeServers = [
"manager.${config.networking.domain}"

4
machines/node/network.nix

@ -1,11 +1,11 @@
{ lib, node-id, ... }:
{ lib, nodeId, ... }:
with lib;
{
networking.interfaces."enp2s0f0" = {
ipv4.addresses = [{
address = "10.32.47.${fixedWidthNumber 3 (100 + node-id)}";
address = "10.32.47.${fixedWidthNumber 3 (100 + nodeId)}";
prefixLength = 24;
}];
};

30
machines/nodes.nix

@ -0,0 +1,30 @@
{
"node-00" = {
networking.interfaces."mngt".macAddress = "50:46:5D:DA:0C:C9";
networking.interfaces."data".macAddress = "50:46:5d:da:0b:d6";
};
"node-01" = {
networking.interfaces."mngt".macAddress = "50:46:5D:DA:0C:07";
networking.interfaces."data".macAddress = "50:46:5d:da:0c:56";
};
"node-02" = {
networking.interfaces."mngt".macAddress = "10:BF:48:19:B0:04";
networking.interfaces."data".macAddress = "10:bf:48:1f:a6:8f";
};
"node-03" = {
networking.interfaces."mngt".macAddress = "10:BF:48:19:A4:FE";
networking.interfaces."data".macAddress = "10:bf:48:1b:57:47";
};
"node-04" = {
networking.interfaces."mngt".macAddress = "10:BF:48:19:A2:E2";
networking.interfaces."data".macAddress = "10:bf:48:19:a2:4d";
};
"node-05" = {
networking.interfaces."mngt".macAddress = "10:BF:48:15:00:F5";
networking.interfaces."data".macAddress = "10:bf:48:1b:56:df";
};
"node-06" = {
networking.interfaces."mngt".macAddress = "50:46:5D:DA:0C:09";
networking.interfaces."data".macAddress = "50:46:5d:da:0c:52";
};
}
Loading…
Cancel
Save