modularize cluster configs

This commit is contained in:
Jonas Juselius
2022-08-24 10:46:23 +02:00
parent e28c7abf20
commit 2e5e39c03b
3 changed files with 153 additions and 136 deletions

View File

@@ -3,14 +3,16 @@ with lib;
let
cfg = config.features.host;
nodes = import ./nodes.nix;
etcdCluster = {
enable = true;
existing = true;
nodes =
{
etcd0 = "10.255.241.100";
# etcd1 = "10.255.241.80";
# etcd2 = "10.255.241.81";
etcd1 = "10.255.241.90";
etcd2 = "10.255.241.80";
};
};
@@ -38,9 +40,9 @@ let
# ];
};
services.udev.extraRules = ''
KERNEL=="ibp1s0", SUBSYSTEM=="net", ATTR{create_child}:="0x3666"
'';
# services.udev.extraRules = ''
# KERNEL=="ibp1s0", SUBSYSTEM=="net", ATTR{create_child}:="0x3666"
# '';
console = {
font = "Lat2-Terminus16";
@@ -102,68 +104,8 @@ let
docker.enable = false;
};
cachix.enable = false;
monitoring.nodeExporter.enable = false;
pki = { ca = ./ca; };
hpc = {
enable = true;
slurm = {
client = true;
mungeKey = ./munge.key;
mungeUid = 995; # hack
controlMachine = "ekman";
nodeName = [
"c0-[1-2] Sockets=2 CoresPerSocket=64 ThreadsPerCore=1 RealMemory=256000 TmpDisk=500000 State=UNKNOWN"
"ekman Sockets=2 CoresPerSocket=64 ThreadsPerCore=2 RealMemory=256000 TmpDisk=500000 State=UNKNOWN"
];
partitionName = [
"batch Nodes=c0-[1-2] Default=YES MaxTime=INFINITE State=UP"
"frontend Nodes=ekman MaxTime=1:00:00 State=UP"
];
};
beegfs = {
enable = false;
beegfs = {
bee0-0 = {
mgmtdHost = "mds1-0";
connAuthFile = "/etc/beegfs/connauthfile";
client = {
enable = false;
mountPoint = "/work";
};
};
};
};
};
k8s = {
enable = true;
node.enable = true;
clusterName = "ekman";
initca = ./ca;
cidr = "10.100.0.0/16";
master = {
name = "ekman";
address = "10.255.241.100";
extraSANs = [ "ekman.local" "ekman.oceanbox.io" ];
};
ingressNodes = [
"ekman.oceanbox.io"
];
fileserver = "mds1-0";
charts = {
acme_email = "innovasjon@itpartner.no";
grafana_smtp_user = "utvikling";
grafana_smtp_password = "S0m3rp0m@de#21!";
};
};
};
services.kubernetes.kubelet.extraSANs = mkSANs {
name = cfg.name;
address = cfg.address;
};
networking = {
@@ -177,22 +119,9 @@ let
'';
};
fileSystems = {
# "/opt" = {
# device = "10.255.241.81:/opt";
# fsType = "nfs";
# options = [ "soft" "rdma" "defaults" "vers=4.2" ];
# };
# "/data" = {
# device = "255.241.81:/data";
# fsType = "nfs";
# options = [ "soft" "rdma" "defaults" "vers=4.2" ];
# };
};
environment.variables = {};
systemd.services."serial-getty@ttyS0".enable = true;
# systemd.services."serial-getty@ttyS0".enable = true;
environment.etc."beegfs/connauthfile" = {
source = ./connauthfile;
@@ -210,6 +139,86 @@ let
};
};
compute = {
features = {
hpc = {
enable = true;
slurm = {
client = true;
mungeKey = ./munge.key;
mungeUid = 996; # hack
controlMachine = "ekman";
nodeName = [
"c0-[1-2] Sockets=2 CoresPerSocket=64 ThreadsPerCore=1 RealMemory=256000 TmpDisk=500000 State=UNKNOWN"
"ekman Sockets=2 CoresPerSocket=64 ThreadsPerCore=2 RealMemory=256000 TmpDisk=500000 State=UNKNOWN"
];
partitionName = [
"batch Nodes=c0-[1-2] Default=YES MaxTime=INFINITE State=UP"
"frontend Nodes=ekman MaxTime=1:00:00 State=UP"
];
};
beegfs = {
enable = false;
beegfs = {
bee0-0 = {
mgmtdHost = "beegfs0";
connAuthFile = "/etc/beegfs/connauthfile";
client = {
enable = false;
mountPoint = "/work";
};
};
};
};
};
};
fileSystems = {
"/opt" = {
device = "10.255.243.80:/opt";
fsType = "nfs";
options = [ "soft" "rdma" "defaults" "vers=4.2" ];
};
"/data" = {
device = "10.255.243.80:/data";
fsType = "nfs";
options = [ "soft" "rdma" "defaults" "vers=4.2" ];
};
};
};
k8s-node = {
features = {
k8s = {
enable = true;
node.enable = true;
clusterName = "ekman";
inherit etcdCluster;
initca = ./ca;
cidr = "10.100.0.0/16";
master = {
name = "ekman";
address = "10.255.241.100";
extraSANs = [ "ekman.local" "ekman.oceanbox.io" ];
};
ingressNodes = [
"ekman.oceanbox.io"
];
fileserver = "mds1-0";
charts = {
acme_email = "innovasjon@itpartner.no";
# grafana_smtp_user = "utvikling";
# grafana_smtp_password = "S0m3rp0m@de#21!";
};
};
};
services.kubernetes.kubelet.extraSANs = mkSANs {
name = cfg.name;
address = cfg.address;
};
};
shosts = {
environment.etc."ssh/shosts.equiv" = {
mode = "0644";
@@ -217,8 +226,8 @@ let
gid = 0;
text = ''
10.255.241.80
10.255.241.81
'' + builtins.foldl' (a: x: a + "10.255.240.${toString x}\n") "" (builtins.genList (n: n + 100) 17);
10.255.241.90
'' + builtins.foldl' (a: x: a + "${x.address}\n") "" nodes;
};
programs.ssh.knownHosts = {
@@ -230,19 +239,19 @@ let
};
} // builtins.foldl' (a: x:
let
n = toString x;
n' = toString (x + 100);
n = toString x.idx;
addr = toString (x.idx + 100);
in a // {
"c0-${n}" = {
hostNames = [
"c0-${n}"
"c0-${n}.cluster.local"
"10.255.241.${n'}"
"10.255.243.${n'}"
"10.255.241.${addr}"
"10.255.243.${addr}"
];
publicKeyFile = ./pubkeys/c0-1.pub;
publicKeyFile = ./pubkeys/c0-${n}.pub;
};
}) {} (builtins.genList (n: n) 16);
}) {} nodes;
environment.systemPackages = [ openssh-shosts ];
@@ -261,49 +270,20 @@ let
doCheck = false; # the tests take hours
});
myvnc =
let
myvnc = pkgs.writeScriptBin "myvnc" ''
#!${pkgs.runtimeShell}
uid=`id -u`
port=$((9000+$uid))
shell=`getent passwd $(id -un) | awk -F : '{print $NF}'`
# vnc=${pkgs.tigervnc}/bin/vncserver
vnc=/nix/store/czp2b60dwk75widi8y287hr0xx1wgv2a-tigervnc-1.10.1/bin/vncserver
case $1 in
-p|--port) shift; port=$1 ;;
kill|stop)
display=$($vnc -list | sed -n 's/^\(:[0-9]\+\).*/\1/p'| head -1)
$vnc -kill $display
exit 0
;;
esac
ps ax | sed '/grep/d' | grep "Xvnc.*-rfbport $port" >/dev/null 2>&1
[ $? = 1 ] && $vnc -rfbport $port
echo "Xvnc server is running on port $port."
exec $shell -i
'';
buildCommand = ''
mkdir -p $out/bin
echo $src > $out/bin/myvnc
chmod 755 $out/bin/myvnc
'';
in {
environment.systemPackages = [ myvnc ];
};
in {
options.node = {
myvnc = mkEnableOption "Enable myvnc script";
options.cluster = {
compute = mkEnableOption "Enable compute node configs";
};
options.cluster = {
k8sNode = mkEnableOption "Enable k8s node";
};
config = mkMerge [
configuration
shosts
(mkIf config.node.myvnc myvnc)
(mkIf config.cluster.compute compute)
(mkIf config.cluster.k8sNode k8s-node)
];
imports = [