<p>As I am new to kubernetes and its DNS service, it would be great if someone helps to clarify the question below. I understand from the kubernetes documentation that kube-dns supports 'services' and 'pods' records and uses to resolve domain names of services or pods.</p>
<p>In a pod, few containers are running. I need those containers to resolve few external domains using kube-dns. Now, how can I use kube-dns to make containers to resolve such external domain names? Do the kubernetes provides dns server only for the resolution of domains within kubernetes? Or is there a way to customize kubernetes provided dns to resolve external domains? If so how to customize it?</p>
<p>It could be really helpful if someone helps to unblock my queries. Thanks in advance!!!</p>

anonymous user
<p>You should take a look first pod's DNS Policy. From the <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">documentation</a>, I shared below.</p>
<blockquote>
<p>DNS policies can be set on a per-pod basis. Currently Kubernetes supports the following pod-specific DNS policies. These policies are specified in the dnsPolicy field of a Pod Spec.</p>
<ul>
<li>&quot;<strong>Default</strong>&quot;: The Pod inherits the name resolution configuration from the node that the pods run on. See related discussion for more details.</li>
<li>&quot;<strong>ClusterFirst</strong>&quot;: Any DNS query that does not match the configured cluster domain suffix, such as &quot;www.kubernetes.io&quot;, is forwarded to the upstream nameserver inherited from the node. Cluster administrators may have extra stub-domain and upstream DNS servers configured. See related discussion for details on how DNS queries are handled in those cases.</li>
<li>&quot;<strong>ClusterFirstWithHostNet</strong>&quot;: For Pods running with hostNetwork, you should explicitly set its DNS policy &quot;ClusterFirstWithHostNet&quot;.
&quot;None&quot;: It allows a Pod to ignore DNS settings from the Kubernetes environment. All DNS settings are supposed to be provided using the dnsConfig field in the Pod Spec. See Pod's DNS config subsection below.</li>
<li><strong>Note</strong>: &quot;Default&quot; is not the default DNS policy. If dnsPolicy is not explicitly specified, then &quot;ClusterFirst&quot; is used.</li>
</ul>
</blockquote>
<p>Then you can configure CoreDNS configmap <em><strong>forward</strong></em> option according to your needs. This <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/" rel="nofollow noreferrer">documentation</a> will help you to understand.</p>
<blockquote>
<p><strong>forward</strong>: Any queries that are not within the cluster domain of Kubernetes will be forwarded to predefined resolvers (/etc/resolv.conf).</p>
</blockquote>
