From 342ba2baeb00cc0c9e41faa7035f95c439768d5b Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Wed, 17 Jul 2024 10:25:23 +0200 Subject: [PATCH] feat(dnsmasq): Move to dns k8s namespace refactor(pihole): Move to dns k8s namespace --- README.md | 1 + flake-parts/kubenix.nix | 4 +++- kubenix-modules/all.nix | 1 - kubenix-modules/base.nix | 2 +- kubenix-modules/dnsmasq.nix | 39 ++++++++++++++++--------------------- kubenix-modules/pihole.nix | 14 ++++++------- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index bbfccb6..836d3a4 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Currently, the applications being deployed like this are: - `immich` - `attic` - `inbucket` +- `dnsmasq` ## Known bugs diff --git a/flake-parts/kubenix.nix b/flake-parts/kubenix.nix index 4a197cc..d6f45ca 100644 --- a/flake-parts/kubenix.nix +++ b/flake-parts/kubenix.nix @@ -89,11 +89,13 @@ kubenix.syncthing = mkDeployScriptAndManifest "${self}/kubenix-modules/syncthing.nix" "syncthing" "syncthing"; kubenix.pihole = mkDeployScriptAndManifest - "${self}/kubenix-modules/pihole.nix" "pihole" "pihole"; + "${self}/kubenix-modules/pihole.nix" "pihole" "dns"; kubenix.immich = mkDeployScriptAndManifest "${self}/kubenix-modules/immich.nix" "immich" "immich"; kubenix.attic = mkDeployScriptAndManifest "${self}/kubenix-modules/attic.nix" "attic" "attic"; kubenix.inbucket = mkDeployScriptAndManifest "${self}/kubenix-modules/inbucket.nix" "inbucket" "inbucket"; + kubenix.dnsmasq = mkDeployScriptAndManifest + "${self}/kubenix-modules/dnsmasq.nix" "dnsmasq" "dns"; }) diff --git a/kubenix-modules/all.nix b/kubenix-modules/all.nix index fd78044..95eaf8e 100644 --- a/kubenix-modules/all.nix +++ b/kubenix-modules/all.nix @@ -2,7 +2,6 @@ let applications = [ ./media.nix ./bind9 - ./dnsmasq.nix # ./argo.nix # ./minecraft.nix ]; diff --git a/kubenix-modules/base.nix b/kubenix-modules/base.nix index 8cf6974..ebef733 100644 --- a/kubenix-modules/base.nix +++ b/kubenix-modules/base.nix @@ -72,10 +72,10 @@ forgejo = { }; paperless = { }; syncthing = { }; - pihole = { }; immich = { }; attic = { }; inbucket = { }; + dns = { }; }; nodes = diff --git a/kubenix-modules/dnsmasq.nix b/kubenix-modules/dnsmasq.nix index 27b761b..bc29d61 100644 --- a/kubenix-modules/dnsmasq.nix +++ b/kubenix-modules/dnsmasq.nix @@ -1,6 +1,5 @@ { myLib, ... }: { kubernetes.resources = { - # TODO: generate this with nix? configMaps.dnsmasq-config.data.config = '' address=/kms.kun.is/${myLib.globals.kmsIPv4} address=/ssh.git.kun.is/${myLib.globals.gitIPv4} @@ -16,33 +15,29 @@ server=/kun.is/${myLib.globals.bind9IPv4} ''; - deployments.dnsmasq = { - metadata.labels.app = "dnsmasq"; + deployments.dnsmasq.spec = { + selector.matchLabels.app = "dnsmasq"; - spec = { - selector.matchLabels.app = "dnsmasq"; + template = { + metadata.labels.app = "dnsmasq"; - template = { - metadata.labels.app = "dnsmasq"; + spec = { + containers.dnsmasq = { + image = "dockurr/dnsmasq:2.90"; - spec = { - containers.dnsmasq = { - image = "dockurr/dnsmasq:2.90"; - - ports.dns = { - containerPort = 53; - protocol = "UDP"; - }; - - volumeMounts = [{ - name = "config"; - mountPath = "/etc/dnsmasq.conf"; - subPath = "config"; - }]; + ports.dns = { + containerPort = 53; + protocol = "UDP"; }; - volumes.config.configMap.name = "dnsmasq-config"; + volumeMounts = [{ + name = "config"; + mountPath = "/etc/dnsmasq.conf"; + subPath = "config"; + }]; }; + + volumes.config.configMap.name = "dnsmasq-config"; }; }; }; diff --git a/kubenix-modules/pihole.nix b/kubenix-modules/pihole.nix index 52f4ec7..b5540b9 100644 --- a/kubenix-modules/pihole.nix +++ b/kubenix-modules/pihole.nix @@ -44,8 +44,8 @@ }; volumes = { - data.persistentVolumeClaim.claimName = "data"; - dnsmasq.persistentVolumeClaim.claimName = "dnsmasq"; + data.persistentVolumeClaim.claimName = "pihole-data"; + dnsmasq.persistentVolumeClaim.claimName = "pihole-dnsmasq"; }; securityContext = { @@ -57,7 +57,7 @@ }; services = { - web.spec = { + pihole-web.spec = { selector.app = "pihole"; ports.web = { @@ -66,7 +66,7 @@ }; }; - dns.spec = { + pihole-dns.spec = { type = "LoadBalancer"; loadBalancerIP = myLib.globals.piholeIPv4; selector.app = "pihole"; @@ -86,18 +86,18 @@ entrypoint = "localsecure"; service = { - name = "web"; + name = "pihole-web"; portName = "web"; }; }; longhorn.persistentVolumeClaim = { - data = { + pihole-data = { volumeName = "pihole-data"; storage = "750Mi"; }; - dnsmasq = { + pihole-dnsmasq = { volumeName = "pihole-dnsmasq"; storage = "16Mi"; };