nixos-servers/kubenix-modules/pihole.nix

131 lines
2.9 KiB
Nix
Raw Normal View History

{ myLib, ... }: {
kubernetes.resources = {
configMaps.pihole.data = {
TZ = "Europe/Amsterdam";
2024-04-13 11:23:12 +00:00
PIHOLE_DNS_ = "192.168.30.1";
};
2024-04-14 12:48:27 +00:00
secrets.pihole.stringData.webPassword = "ref+sops://secrets/sops.yaml#/pihole/password";
deployments.pihole = {
metadata.labels.app = "pihole";
spec = {
selector.matchLabels.app = "pihole";
template = {
metadata.labels.app = "pihole";
spec = {
containers.pihole = {
image = "pihole/pihole:latest";
envFrom = [{ configMapRef.name = "pihole"; }];
2024-04-14 19:43:31 +00:00
ports = {
web.containerPort = 80;
dns = {
containerPort = 53;
protocol = "UDP";
2024-04-14 19:43:31 +00:00
};
};
2024-04-14 19:00:15 +00:00
env.WEBPASSWORD.valueFrom.secretKeyRef = {
name = "pihole";
key = "webPassword";
};
volumeMounts = [
{
name = "data";
mountPath = "/etc/pihole";
}
{
name = "dnsmasq";
mountPath = "/etc/dnsmasq.d";
}
];
};
2024-04-14 19:00:15 +00:00
volumes = {
data.persistentVolumeClaim.claimName = "pihole-data";
dnsmasq.persistentVolumeClaim.claimName = "pihole-dnsmasq";
};
};
};
};
};
persistentVolumes = {
pihole-data.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
2024-04-12 21:31:10 +00:00
server = "lewis.dmz";
path = "/mnt/data/nfs/pihole/data";
};
};
pihole-dnsmasq.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
2024-04-12 21:31:10 +00:00
server = "lewis.dmz";
path = "/mnt/data/nfs/pihole/dnsmasq";
};
};
};
persistentVolumeClaims = {
pihole-data.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "pihole-data";
};
pihole-dnsmasq.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "pihole-dnsmasq";
};
};
services = {
pihole-web.spec = {
selector.app = "pihole";
2024-04-14 19:43:31 +00:00
ports.web = {
port = 80;
2024-04-14 19:43:31 +00:00
targetPort = "web";
};
};
pihole-dns.spec = {
type = "LoadBalancer";
loadBalancerIP = myLib.globals.piholeIPv4;
selector.app = "pihole";
2024-04-14 19:43:31 +00:00
ports.dns = {
protocol = "UDP";
port = 53;
2024-04-14 19:43:31 +00:00
targetPort = "dns";
};
};
};
};
lab.ingresses.pihole = {
host = "pihole.kun.is";
entrypoint = "localsecure";
service = {
name = "pihole-web";
portName = "web";
};
};
}