2024-07-17 04:40:44 +00:00
|
|
|
{config, numbers, pkgs, lib, ...}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
hasIface = iface: elem iface (numbers.api.hostIfaces config.networking.hostName);
|
|
|
|
strIfHasIface = iface: s: if hasIface iface then s else "";
|
|
|
|
attrsetIfHasIface = iface: as: if hasIface iface then as else {};
|
|
|
|
eltIfHasIface = iface: elt: if hasIface iface then [ elt ] else [];
|
|
|
|
|
2024-07-26 19:29:08 +00:00
|
|
|
nameservers = filter (x: x != "") [
|
|
|
|
"127.0.0.1"
|
|
|
|
(if config.networking.hostName != "snorlax" then (numbers.api.hostIface "snorlax" "sec0").ip else "")
|
|
|
|
(if config.networking.hostName != "sobble" then (numbers.api.hostIface "sobble" "sec0").ip else "")
|
|
|
|
(if config.networking.hostName != "rowlet" then (numbers.api.hostIface "rowlet" "sec0").ip else "")
|
|
|
|
];
|
|
|
|
|
2024-07-17 04:40:44 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
#./pgpool.nix
|
|
|
|
./udp514.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
services.udp514-journal.enable = true;
|
|
|
|
services.coredns = {
|
|
|
|
enable = true;
|
|
|
|
config = ''
|
|
|
|
. {
|
2024-07-26 19:29:08 +00:00
|
|
|
${strIfHasIface "sxxxxec0" "bind sec0"}
|
|
|
|
${strIfHasIface "xxxxlan0" "bind lan0"}
|
2025-02-19 01:09:15 +00:00
|
|
|
nsid ${config.networking.hostName}
|
2024-07-25 18:24:16 +00:00
|
|
|
forward . 172.16.1.8
|
2025-02-19 01:09:15 +00:00
|
|
|
template IN A server.dns {
|
|
|
|
answer "{{ .Name }} 0 IN A ${(numbers.api.hostIface config.networking.hostName "sec0").ip}"
|
|
|
|
}
|
2024-07-17 04:40:44 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
2024-07-26 19:29:08 +00:00
|
|
|
services.resolved.enable = false;
|
|
|
|
#networking.resolvconf.enable = false;
|
2024-07-17 04:40:44 +00:00
|
|
|
|
2024-07-26 19:29:08 +00:00
|
|
|
environment.etc."resolv.conf".text = foldl'
|
|
|
|
(a: s: if s == "" then a else "${a}nameserver ${s}\n")
|
|
|
|
"" nameservers;
|
|
|
|
networking.nameservers = nameservers;
|
2024-07-17 04:40:44 +00:00
|
|
|
|
|
|
|
|
2024-07-26 19:29:08 +00:00
|
|
|
system.activationScripts."corenet-flux" = mkIf true ''
|
|
|
|
ln -sf ${./corenet-flux.yaml} /var/lib/rancher/k3s/server/manifests/corenet-flux.yaml
|
|
|
|
'';
|
2024-07-17 04:40:44 +00:00
|
|
|
|
|
|
|
services.k3s = {
|
|
|
|
enable = true;
|
2024-07-26 19:29:08 +00:00
|
|
|
tokenFile = mkIf (config.networking.hostName != "snorlax") "/etc/k3s.token";
|
|
|
|
serverAddr =
|
|
|
|
mkIf (config.networking.hostName != "snorlax")
|
|
|
|
"https://${(numbers.api.hostIface "snorlax" "sec0").ip}:6443";
|
|
|
|
clusterInit = config.networking.hostName == "snorlax";
|
2024-07-17 04:40:44 +00:00
|
|
|
extraFlags = (
|
2024-07-26 19:29:08 +00:00
|
|
|
#" --datastore-endpoint=nats://localhost:4222?noEmbed=true&bucket=k0-kine&replicas=2"+
|
2024-07-17 04:40:44 +00:00
|
|
|
" --disable=traefik"+
|
|
|
|
" --disable=local-storage"+
|
|
|
|
" --cluster-cidr=10.128.0.0/16"+
|
2024-07-26 19:29:08 +00:00
|
|
|
" --service-cidr=10.129.0.0/16"+
|
|
|
|
" --flannel-backend=vxlan"+
|
|
|
|
" --embedded-registry"+
|
2024-07-17 04:40:44 +00:00
|
|
|
(strIfHasIface "sec0" " --node-ip=${(numbers.api.hostIface config.networking.hostName "sec0").ip}")+
|
2024-07-26 19:29:08 +00:00
|
|
|
#(strIfHasIface "lan0" " --tls-san=${(numbers.api.hostIface config.networking.hostName "lan0").ip}")+
|
2024-07-17 04:40:44 +00:00
|
|
|
"");
|
|
|
|
};
|
|
|
|
|
2024-07-26 19:29:08 +00:00
|
|
|
environment.etc."rancher/k3s/registries.yaml".text = ''
|
|
|
|
mirrors:
|
|
|
|
"*":
|
|
|
|
'';
|
2024-07-17 04:40:44 +00:00
|
|
|
|
2024-07-26 19:29:08 +00:00
|
|
|
networking.firewall.allowedUDPPorts = [
|
|
|
|
53 80 443 5432 5001 9898 9999 6443 4222 6222 8222 2379 2380 8472 10250
|
|
|
|
];
|
|
|
|
networking.firewall.allowedUDPPortRanges = [
|
2025-02-19 01:09:15 +00:00
|
|
|
{ from = 5000; to = 32767; }
|
2024-07-26 19:29:08 +00:00
|
|
|
];
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
53 80 443 5432 5001 9898 9999 6443 4222 6222 8222 2379 2380 10250
|
|
|
|
];
|
|
|
|
networking.firewall.allowedTCPPortRanges = [
|
2025-02-19 01:09:15 +00:00
|
|
|
{ from = 5000; to = 32767; }
|
2024-07-26 19:29:08 +00:00
|
|
|
];
|
2024-07-17 04:40:44 +00:00
|
|
|
}
|