use dns.nix for kun.is zone again

parameterize k8s' service IPs
This commit is contained in:
Pim Kunis 2024-04-13 23:25:48 +02:00
parent 76bd5c9276
commit 6e608e6ca8
13 changed files with 95 additions and 99 deletions
kubenix-modules/bind9

View file

@ -0,0 +1,98 @@
{ myLib, dns, ... }:
let
kunisZone = dns.lib.toString "kun.is" (import ./kun.is.zone.nix myLib dns);
in
{
kubernetes.resources = {
configMaps = {
bind9-env.data.TZ = "Europe/Amsterdam";
bind9-config.data = {
# TODO: this was copied from nix's generated bind config
# Is there a way to generate this without actually running the nixos module?
config = ''
acl cachenetworks { 127.0.0.0/24; };
acl badnetworks { };
options {
listen-on { any; };
listen-on-v6 { any; };
allow-query { cachenetworks; };
blackhole { badnetworks; };
forward first;
forwarders { };
directory "/run/named";
pid-file "/run/named/named.pid";
allow-transfer { none; };
allow-recursion { none; };
version none;
notify no;
};
zone "kun.is" {
type master;
file "/etc/bind/kun.is.zone";
allow-transfer { };
allow-query { any; };
};
'';
kunis-zone = kunisZone;
};
};
deployments.bind9 = {
metadata.labels.app = "bind9";
spec = {
selector.matchLabels.app = "bind9";
template = {
metadata.labels.app = "bind9";
spec = {
containers.bind9 = {
image = "ubuntu/bind9:9.18-22.04_beta";
envFrom = [{ configMapRef.name = "bind9-env"; }];
ports = [{
containerPort = 53;
protocol = "UDP";
}];
volumeMounts = [
{
name = "config";
mountPath = "/etc/bind/named.conf";
subPath = "config";
}
{
name = "config";
mountPath = "/etc/bind/kun.is.zone";
subPath = "kunis-zone";
}
];
};
volumes = [{
name = "config";
configMap.name = "bind9-config";
}];
};
};
};
};
services.bind9.spec = {
type = "LoadBalancer";
loadBalancerIP = myLib.globals.bind9IPv4;
selector.app = "bind9";
ports = [{
port = 53;
targetPort = 53;
protocol = "UDP";
}];
};
};
}

View file

@ -0,0 +1,45 @@
myLib: dns: with dns.lib.combinators; {
CAA = letsEncrypt "caa@kun.is";
SOA = {
nameServer = "ns1";
adminEmail = "webmaster@kun.is";
serial = 2024041300;
};
NS = [
"ns1.kun.is."
"ns2.kun.is."
];
MX = [
(mx.mx 10 "mail.kun.is.")
];
TXT = [
(with spf; soft [ "include:spf.glasnet.nl" ])
];
subdomains = rec {
"*".A = [ myLib.globals.routerPublicIPv4 ];
ns.A = [ myLib.globals.routerPublicIPv4 ];
ns1 = ns;
ns2 = ns;
wg = host myLib.globals.routerPublicIPv4 myLib.globals.routerPublicIPv6;
#for SMTP2GO to be able send emails from kun.is domain
em670271 = {
CNAME = [ "return.smtp2go.net." ];
};
"s670271._domainkey" = {
CNAME = [ "dkim.smtp2go.net." ];
};
link = {
CNAME = [ "track.smtp2go.net." ];
};
};
}