summary refs log tree commit diff
path: root/nixos/modules/services/cluster
diff options
context:
space:
mode:
authorAlexandru Scvortov <code@scvalex.net>2021-07-28 19:42:45 +0100
committerAlexandru Scvortov <code@scvalex.net>2021-07-28 20:15:57 +0100
commited62c1c6631814274a3dc6e13254ad23c9d03e02 (patch)
treeef49007f0f5dd5ee4be64df6532db9e65f9c52c5 /nixos/modules/services/cluster
parent042180c8a08aa169d204a0a7ff5095c5d687b15a (diff)
downloadnixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.tar
nixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.tar.gz
nixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.tar.bz2
nixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.tar.lz
nixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.tar.xz
nixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.tar.zst
nixpkgs-ed62c1c6631814274a3dc6e13254ad23c9d03e02.zip
kubernetes: make corefile configurable
Diffstat (limited to 'nixos/modules/services/cluster')
-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;
         };
       };