nixos-servers/kubenix-modules/pihole.nix

100 lines
2.2 KiB
Nix
Raw Permalink 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-06-15 20:27:07 +00:00
secrets.pihole.stringData.webPassword = "ref+sops://secrets/kubernetes.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";
};
2024-05-23 18:11:04 +00:00
securityContext = {
fsGroup = 1000;
fsGroupChangePolicy = "OnRootMismatch";
};
};
};
};
};
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";
};
};
};
}