summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2021-07-29 14:31:19 +0200
committerGitHub <noreply@github.com>2021-07-29 14:31:19 +0200
commit82272021e2a5dc3cf4431a4381de254c7715b917 (patch)
treecf1aa2d9deb6c866b3c6223816f1619ec20d1445 /nixos
parent4bdce59e5451d8716cfe3e684f4dc181b1b2faff (diff)
parented62c1c6631814274a3dc6e13254ad23c9d03e02 (diff)
downloadnixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.tar
nixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.tar.gz
nixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.tar.bz2
nixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.tar.lz
nixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.tar.xz
nixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.tar.zst
nixpkgs-82272021e2a5dc3cf4431a4381de254c7715b917.zip
Merge pull request #128886 from scvalex/coredns-configurable-corefile
kubernetes.addons.dns: make corefile configurable
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/cluster/kubernetes/addons/dns.nix54
1 files changed, 40 insertions, 14 deletions
diff --git a/nixos/modules/services/cluster/kubernetes/addons/dns.nix b/nixos/modules/services/cluster/kubernetes/addons/dns.nix
index 24d86628b21..8f937a13231 100644
--- a/nixos/modules/services/cluster/kubernetes/addons/dns.nix
+++ b/nixos/modules/services/cluster/kubernetes/addons/dns.nix
@@ -60,6 +60,45 @@ in {
         sha256 = "02r440xcdsgi137k5lmmvp0z5w5fmk8g9mysq5pnysq1wl8sj6mw";
       };
     };
+
+    corefile = mkOption {
+      description = ''
+        Custom coredns corefile configuration.
+
+        See: <link xlink:href="https://coredns.io/manual/toc/#configuration"/>.
+      '';
+      type = types.str;
+      default = ''
+        .:${toString ports.dns} {
+          errors
+          health :${toString ports.health}
+          kubernetes ${cfg.clusterDomain} in-addr.arpa ip6.arpa {
+            pods insecure
+            fallthrough in-addr.arpa ip6.arpa
+          }
+          prometheus :${toString ports.metrics}
+          forward . /etc/resolv.conf
+          cache 30
+          loop
+          reload
+          loadbalance
+        }'';
+      defaultText = ''
+        .:${toString ports.dns} {
+          errors
+          health :${toString ports.health}
+          kubernetes ''${config.services.kubernetes.addons.dns.clusterDomain} in-addr.arpa ip6.arpa {
+            pods insecure
+            fallthrough in-addr.arpa ip6.arpa
+          }
+          prometheus :${toString ports.metrics}
+          forward . /etc/resolv.conf
+          cache 30
+          loop
+          reload
+          loadbalance
+        }'';
+    };
   };
 
   config = mkIf cfg.enable {
@@ -151,20 +190,7 @@ in {
           namespace = "kube-system";
         };
         data = {
-          Corefile = ".:${toString ports.dns} {
-            errors
-            health :${toString ports.health}
-            kubernetes ${cfg.clusterDomain} in-addr.arpa ip6.arpa {
-              pods insecure
-              fallthrough in-addr.arpa ip6.arpa
-            }
-            prometheus :${toString ports.metrics}
-            forward . /etc/resolv.conf
-            cache 30
-            loop
-            reload
-            loadbalance
-          }";
+          Corefile = cfg.corefile;
         };
       };