<p>We currently have pods in a kubernetes cluster (AKS) that need to resolve two different domains. </p>

<p>The first domain beeing the cluster domain default.svc.cluster.local and the second one beeing mydns.local </p>

<p>how can this be achieved?</p>

<p>I found the solution myself. </p>

<p>There are two ways to achieve the desired name resolution:</p>

<ol>
<li>If your AKS Cluster is within an Azure VNET you can set the DNS settings in the VNET to the custom DNS Server that is able to resolve your custom domain. If your Pods have no specified dns settings then the resolution will work this way:</li>
</ol>

<p>First the Pods try to resolve the DNS request within CoreDNS, if they can't then they take the DNS settings of the host and ask the DNS Server configured in the host. Since in azure the DNS settings of the VNET are applied to the Virtual Machines it will ask the correct DNS server.</p>

<ol start="2">
<li><p>Modify the coreDNS settings in your AKS cluster with the following json :</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  yourdns.server: |
    yourdns.com:53 {
      errors
      cache 1
      proxy . 10.1.0.40
    }
</code></pre></li>
</ol>

<p>Important to know is, that in AKS you can't overwrite the coredns ConfigMap. The Kubernetes master will always reset it to the default after a couple of seconds. If you want to edit the ConfigMap in AKS you have to name the configmap "coredns-custom".</p>

<p><code>yourdns.server</code> is actually not the server. It is the <code>domain.server</code>. The DNS server IP is behind the proxy setting.</p>
