{"id":3187,"date":"2020-06-16T13:41:15","date_gmt":"2020-06-16T08:11:15","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/?p=3187"},"modified":"2020-06-16T20:34:28","modified_gmt":"2020-06-16T15:04:28","slug":"a-closer-look-at-coredns","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2020\/06\/16\/a-closer-look-at-coredns\/","title":{"rendered":"A Closer Look at coreDNS"},"content":{"rendered":"<figure id=\"attachment_3219\" aria-describedby=\"caption-attachment-3219\" style=\"width: 654px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3219\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2020\/05\/cover1-1.jpg?w=619\" alt=\"\" width=\"654\" height=\"403\" \/><figcaption id=\"caption-attachment-3219\" class=\"wp-caption-text\">fig 1<\/figcaption><\/figure>\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\">\r\n<figure class=\"wp-block-image size-large is-resized\"><strong style=\"font-size:28px;\">Introduction:<\/strong><\/figure>\r\n<!-- \/wp:image -->\r\n\r\n<!-- wp:paragraph --><\/div>\r\n<\/div>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>The purpose of this blog is not to go deep into coreDNS rather explain how DNS works in kubernetes, what coreDNS contains and how the corefile uses plugins. So let&#8217;s get started.<\/p>\r\n<p><!--more--><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Pods communication<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Before talking about coreDNS, I want everyone to know how kubernetes implements DNS in clusters. Let\u2019s say one pod i.e. <em>test<\/em> wants to communicate with another pod, <em>db<\/em>. So, we can do that by putting an entry in \/etc\/hosts file as shown in <em>figure 1a.<\/em><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:image {\"id\":3197,\"width\":606,\"height\":288,\"sizeSlug\":\"large\"} -->\r\n<figure class=\"wp-block-image size-large is-resized\">\r\n<figure id=\"attachment_3197\" aria-describedby=\"caption-attachment-3197\" style=\"width: 606px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3197\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2020\/05\/fig1a.png?w=853\" alt=\"\" width=\"606\" height=\"288\" \/><figcaption id=\"caption-attachment-3197\" class=\"wp-caption-text\">fig 1(a)<\/figcaption><\/figure>\r\n<figcaption><\/figcaption>\r\n<\/figure>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<p>But, what if we are dealing with hundreds of pods that are being created and deleted every minute and need communication?\u00a0<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>In this case, instead of making entries in <em>\/etc\/hosts which<\/em> is not a suitable solution, we move these entries to a centralised DNS server i.e. <em>10.96.0.10 <\/em>as shown in <em>figure 1b<\/em>. Now, we need to specify this IP in the pods at a certain location which happens to be inside the \/etc\/resolv.conf file as nameserver.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:image {\"id\":3222,\"width\":615,\"height\":392,\"sizeSlug\":\"large\"} -->\r\n<figure class=\"wp-block-image size-large is-resized\">\r\n<figure id=\"attachment_3222\" aria-describedby=\"caption-attachment-3222\" style=\"width: 615px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3222\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2020\/05\/fig1b-1.png?w=1024\" alt=\"\" width=\"615\" height=\"392\" \/><figcaption id=\"caption-attachment-3222\" class=\"wp-caption-text\">fig 1(b)<\/figcaption><\/figure>\r\n<figcaption><\/figcaption>\r\n<\/figure>\r\n<p>Every time a new pod gets created, k8s do an entry of the new pod in the DNS server and a corresponding entry in \/etc\/resolv.conf file of the new pod as well, of course, pointing to the IP address of the DNS server as shown in <em>figure 1c.<\/em><\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:image {\"id\":3196,\"width\":627,\"height\":392,\"sizeSlug\":\"large\"} -->\r\n<figure class=\"wp-block-image size-large is-resized\">\r\n<figure id=\"attachment_3196\" aria-describedby=\"caption-attachment-3196\" style=\"width: 627px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3196\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2020\/05\/fig1c.png?w=1024\" alt=\"\" width=\"627\" height=\"392\" \/><figcaption id=\"caption-attachment-3196\" class=\"wp-caption-text\">fig 1(c)<\/figcaption><\/figure>\r\n<figcaption><\/figcaption>\r\n<\/figure>\r\n<p>Like I said above that we change the entry of \/etc\/hosts to centralised DNS server. Well, it is right but partially. DNS does not do the entry of pods as we do by editing \/etc\/hosts file in pods (Format: &lt;pod_name&gt; &lt;IP&gt;). Instead, it creates a new hostname by replacing dots into dashes in the IP address of pods like <em>hostname<\/em>\u00a010-244-2-5 (Format: &lt;<em>hostname<\/em>&gt; \u00a0 &lt;IP&gt;). R<em>efer figure 1d<\/em> and look at the entry of DNS.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:image {\"id\":3195,\"width\":623,\"height\":344,\"sizeSlug\":\"large\"} -->\r\n<figure class=\"wp-block-image size-large is-resized\">\r\n<figure id=\"attachment_3195\" aria-describedby=\"caption-attachment-3195\" style=\"width: 623px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3195\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2020\/05\/fig1d.png?w=925\" alt=\"\" width=\"623\" height=\"344\" \/><figcaption id=\"caption-attachment-3195\" class=\"wp-caption-text\">fig 1(d)<\/figcaption><\/figure>\r\n<figcaption><\/figcaption>\r\n<\/figure>\r\n<!-- \/wp:image --><\/div>\r\n<\/div>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Introducing coreDNS<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Well, the above discussion was for understanding. Actually, pods communicate via services in a k8s cluster and coreDNS sets record for these services (by default, pods entries are disabled but you can enable them in corefile of coreDNS).<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Although CoreDNS and Kube-dns ultimately perform the same task, there are some key differences in implementation that affect resource consumption and performance. You can read about this thoroughly in coreDNS official <a href=\"https:\/\/coredns.io\/2018\/11\/27\/cluster-dns-coredns-vs-kube-dns\/\" target=\"_blank\" rel=\"noopener\">docs.<\/a><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>CoreDNS has been available in kubernetes since v1.9. It is a fast and flexible DNS server. The keyword <em>flexible<\/em> here means you are given a lot of freedom with your DNS data which you can exercise using a range of plugins. If some functionality is not provided out of the box you can add it by <a href=\"https:\/\/coredns.io\/explugins\" target=\"_blank\" rel=\"noopener\">writing a plugin<\/a>. <em>It is written in the Go language.<\/em><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>We deploy CoreDNS as a deployment object in the kube-system namespace in a cluster with a service named \u201ckube-dns\u201d. It requires a configuration file that we call corefile located at \/etc\/coredns\/Corefile.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4>Corefile and plugins:<\/h4>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Corefile consists of a number of plugins, plugins are configured for error handling, reporting health, monitoring metrics, cache etc.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>The plugin that makes coreDNS to work with kubernetes is <strong>kubernetes plugin.<\/strong> In kubernetes plugin, top level domain of kubernetes cluster is set (cluster.local)<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Also, it watches for new services by default. For pods, you have to enable &#8216;pod mode&#8217; in Corefile under kubernetes plugin by making an entry as \u2018pods POD MODE\u2019 in the cluster. If a new object gets created, it adds the record of service or pods in coreDNS server.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>The next step for the pods is to point to coreDNS IP address for DNS resolution by specifying nameserver in resolv.conf file. But, what address should it be?<br \/>Well, you don\u2019t need to care about this because DNS entries have been handled by the kubelet component.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>When we install coreDNS in a cluster, we expose it as a service, so the IP address of that service is configured as a nameserver in pods by kubelet.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>Again, my question is how does kubelet know this?<\/strong><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>You can see the entry of coreDNS server in the kubelet configuration file as shown in figure 2a<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>You can also configure kubelet and run as service and pass clusterDns IP in that service file.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading {\"level\":4} -->\r\n<h4><strong>in minikube:\u00a0<\/strong><\/h4>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:syntaxhighlighter\/code {\"language\":\"bash\"} -->\r\n<pre class=\"wp-block-syntaxhighlighter-code\">minikube ssh\r\ncat \/var\/lib\/kubelet\/config.yaml<\/pre>\r\n<!-- \/wp:syntaxhighlighter\/code -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:image {\"width\":621,\"height\":758} -->\r\n<figure class=\"wp-block-image is-resized\">\r\n<figure style=\"width: 621px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/2XRKhzyyB8r_0C5uQFJXEXJ5iNuYHruVjnlNDzCBt6xREf6Z1dBlJM1SdndKNmRgkTOTCyUxJYe3O3o9Gg8gDNeBICnKaQB2Y6kT7XTg0cdrVAx1myGFvK3AAtAPJV_z56wR_0Nh\" alt=\"\" width=\"621\" height=\"758\" \/><figcaption class=\"wp-caption-text\">fig 2(a)<\/figcaption><\/figure>\r\n<figcaption><\/figcaption>\r\n<\/figure>\r\n<!-- \/wp:image --><\/div>\r\n<\/div>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><span style=\"font-size:19px;font-weight:900;letter-spacing:.13333em;text-transform:uppercase;\">Self hosted k8s:<\/span><\/p>\r\n<\/div>\r\n<\/div>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>In our project we are not using managed kubernetes service, hence I&#8217;ll talk about self-hosted kubernetes cluster. You can check the clusterDns entry in kubelet service by doing ssh to any of the k8s node. Below is the service file we are using in our k8s cluster.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\">[Unit]\r\nDescription=Kubernetes Kubelet\r\nDocumentation=https:\/\/github.com\/GoogleCloudPlatform\/kubernetes\r\nAfter=docker.service\r\nRequires=docker.service\r\n\r\n[Service]\r\nExecStart=\/usr\/bin\/kubelet \\\r\n\u00a0\u00a0--allow-privileged=true \\\r\n\u00a0\u00a0--cloud-provider= \\\r\n\u00a0\u00a0--cluster-dns=10.96.0.10\u00a0 \\\r\n\u00a0\u00a0--cluster-domain=cluster.local \\\r\n\u00a0\u00a0--container-runtime=docker \\\r\n\u00a0\u00a0--docker-endpoint=unix:\/\/\/var\/run\/docker.sock \\\r\n\u00a0\u00a0--network-plugin=cni \\\r\n\u00a0\u00a0--cni-bin-dir=\/opt\/cni\/bin \\\r\n\u00a0\u00a0--cni-conf-dir=\/etc\/cni\/net.d \\\r\n\u00a0\u00a0--kubeconfig=\/var\/lib\/kubelet\/kubeconfig \\\r\n\u00a0\u00a0--serialize-image-pulls=true \\\r\n\u00a0\u00a0--tls-cert-file=\/var\/lib\/kubernetes\/kubernetes.pem \\\r\n\u00a0\u00a0--tls-private-key-file=\/var\/lib\/kubernetes\/kubernetes-key.pem \\\r\n\u00a0\u00a0--system-reserved=memory=19227Mi \\\r\n\u00a0\u00a0--fail-swap-on=true \\\r\n\u00a0\u00a0--runtime-cgroups=\/systemd\/system.slice \\\r\n\u00a0\u00a0--kubelet-cgroups=\/systemd\/system.slice \\\r\n\u00a0\u00a0--pod-infra-container-image=&lt;dockerregistry\/imagename:tag \\\r\n\u00a0\u00a0--log-dir=\/var\/log\/kubernetes \\\r\n\u00a0\u00a0--logtostderr=false \\\r\n\u00a0\u00a0--v=2\r\n\r\nRestart=always\r\nRestartSec=5\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\r\n<!-- \/wp:preformatted --><\/div>\r\n<\/div>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:paragraph --><!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Kubernetes DNS Records<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>Format:\u00a0<\/strong><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>For services: svcname.namespace.type.rootDomain<br \/>For pods: hostname.namespace.type.rootDomain<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>Example:\u00a0\u00a0<\/strong><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>For services: test-service.default.svc.cluster.local<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>For pods: 10-244-2-5.default.pod.cluster.local<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Inside the Corefile:<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>We pass Corefile as a config map in the cluster so that it remains decoupled from the deployment object of coreDNS. It has the plugins already configured. You can get the list of plugin chains <a href=\"https:\/\/coredns.io\/plugins\/kubernetes\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\">.:53 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>errors<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>log<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>health<\/strong> {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0lameduck 5s\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>ready<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>kubernetes<\/strong> cluster.local in-addr.arpa ip6.arpa {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0pods insecure\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fallthrough in-addr.arpa ip6.arpa\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ttl 30\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0prometheus :9153\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0forward . \/etc\/resolv.conf\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>cache<\/strong> 30\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>loop<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>reload<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<strong>loadbalance<\/strong>\r\n\u00a0\u00a0\u00a0\u00a0}\r\n<\/pre>\r\n<!-- \/wp:preformatted --><\/div>\r\n<\/div>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Let&#8217;s talk about kubernetes plugin, Using the <strong><em>kubernetes<\/em> plugin<\/strong>, CoreDNS will read zone data from a Kubernetes cluster. It implements the <a href=\"https:\/\/github.com\/kubernetes\/dns\/blob\/master\/docs\/specification.md\" target=\"_blank\" rel=\"noopener\">spec<\/a> defined for Kubernetes DNS-Based service discovery<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>Format: <\/strong><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\">Kubernetes ZONE {\r\npods POD-MODE\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fallthrough ZONE\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ttl time_in_sec\r\n<\/pre>\r\n<!-- \/wp:preformatted --><\/div>\r\n<\/div>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>kubernetes plugin block:<\/strong><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:group -->\r\n<div class=\"wp-block-group\">\r\n<div class=\"wp-block-group__inner-container\"><!-- wp:preformatted -->\r\n<pre class=\"wp-block-preformatted\">kubernetes cluster.local in-addr.arpa ip6.arpa {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0pods insecure\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fallthrough in-addr.arpa ip6.arpa\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ttl 30\r\n<\/pre>\r\n<!-- \/wp:preformatted --><\/div>\r\n<\/div>\r\n<!-- \/wp:group -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Inside the <em>kubernetes<\/em> plugin block:<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Inside the kubernetes plugin, there are a lot of options that you can go through <a href=\"https:\/\/coredns.io\/plugins\/kubernetes\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Let\u2019s discuss the option we are using in the above Corefile.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>pods<\/strong> POD-MODE sets the mode for handling IP-based pod A records, e.g.10-244-2-5.default.pod.cluster.local. in A 10.244.2.5. This option is provided to facilitate the use of SSL certs when connecting directly to pods.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>Value for POD-MODE that we have used:<\/strong><\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><em><strong><span style=\"text-decoration:underline;\">insecure<\/span><\/strong>: Always return an A record<\/em> of pods.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>fallthrough [ZONES\u2026] <\/strong>If a query in the zones for which the plugin is authoritative it either returns a result, or it returns NXDOMAIN for the query. NXDOMAIN responses are created when a DNS has no listing for the domain requested. When <em>fallthrough<\/em>\u00a0is enabled, instead of returning NXDOMAIN when a record is not found, the plugin will pass the request down the plugin chain which can include another plugin to handle the query.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p><strong>ttl<\/strong> allows you to set a custom TTL for responses. The default is 5 seconds. The minimum TTL allowed is 0 seconds, and the maximum is capped at 3600 seconds. Setting TTL to 0 will prevent records from being cached.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Conclusion:<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>In this blog, we got to know how DNS plays an important role in kubernetes. coreDNS works with kubernetes by utilizing kubernetes plugin. It consists of various plugins that you can customize as per your use case. We got to know the format of kubernetes DNS records for services and pods. We explored kubelet configuration through which we learned how the kubelet component configures resolv.conf file. I hope this blog gives you some exposure to coreDNS which might help you to start off with the topic.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Happy learning!<\/p>\r\n<p>Image Sources &#8211;\u00a0<a href=\"https:\/\/3s81si1s5ygj3mzby34dq6qf-wpengine.netdna-ssl.com\/wp-content\/uploads\/2018\/07\/kubernetes-logo-bw-619x381.jpg\" target=\"_blank\" rel=\"noopener\">fig 1<\/a>, <a href=\"https:\/\/www.udemy.com\/course\/certified-kubernetes-administrator-with-practice-tests\/learn\/lecture\/14296166#overview\" target=\"_blank\" rel=\"noopener\">fig 1(a), 1(b), 1(c), and<\/a>\u00a0<a href=\"https:\/\/www.udemy.com\/course\/certified-kubernetes-administrator-with-practice-tests\/learn\/lecture\/14296166#overview\" target=\"_blank\" rel=\"noopener\">fig 1(d)<\/a><\/p>\r\n<p>Opstree is an End to End DevOps solution provider<\/p>\r\n<p><!-- \/wp:paragraph -->\r\n\r\n<!-- wp:buttons --><\/p>\r\n<div class=\"wp-block-buttons\"><!-- wp:button -->\r\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" title=\"https:\/\/www.opstree.com\/contact-us\" href=\"https:\/\/www.opstree.com\/contact-us\" target=\"_blank\" rel=\"noopener\">contact us<\/a><\/div>\r\n<\/div>\r\n<!-- \/wp:paragraph --><!-- \/wp:group -->","protected":false},"excerpt":{"rendered":"<p>Introduction: The purpose of this blog is not to go deep into coreDNS rather explain how DNS works in kubernetes, what coreDNS contains and how the corefile uses plugins. So let&#8217;s get started.<\/p>\n","protected":false},"author":175681501,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[28070474],"tags":[670489941,17846,768739309,71753,30351],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-Pp","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/3187"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/175681501"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=3187"}],"version-history":[{"count":25,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/3187\/revisions"}],"predecessor-version":[{"id":3566,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/3187\/revisions\/3566"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=3187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=3187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=3187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}