<p>We have a docker image repository on GitLab which is hosted on the internal network ( repo.mycomapanydomain.io).</p>
<p>My K8 deployment is failing with Name not resolved error for repo.mycomapanydomain.io</p>
<p>I tried updating the kube-dns config as below. But I still have the same error.</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-dns
  namespace: kube-system
data:
 stubDomains: |
   {“mycomapanydomain”: [“10.131.0.4”]}
 upstreamNameservers: |
   [“10.131.0.4”]
</code></pre>
<p>How can I make my resolv.conf to have the Internal nameservers by default or K8 to resolve with my internal  DNS IPs?</p>

<p>Editing <code>/etc/resolv.conf</code> either manually or automatically is discouraged as for:</p>
<blockquote>
<h3>Internal DNS and resolv.conf</h3>
<p>By default, most Linux distributions store DHCP information in <a href="http://man7.org/linux/man-pages/man5/resolv.conf.5.html" rel="nofollow noreferrer"><code>resolv.conf</code></a>. Compute Engine instances are configured to renew DHCP leases every 24 hours. For instances that are enabled for zonal DNS, the DHCP lease expires every hour. <strong>DHCP renewal overwrites this file, undoing any changes that you might have made.</strong> Instances using <a href="https://cloud.google.com/compute/docs/internal-dns#zonal-dns" rel="nofollow noreferrer">zonal DNS</a> have both zonal and global entries in the <code>resolv.conf</code> file.</p>
<p>-- <em><a href="https://cloud.google.com/compute/docs/internal-dns#resolv.conf" rel="nofollow noreferrer">Cloud.google.com: Compute: Docs: Internal DNS: resolv.conf</a></em></p>
</blockquote>
<p>Also:</p>
<blockquote>
<p><strong>Modifications on the boot disk of a node VM do not persist across node re-creations</strong>. Nodes are re-created during <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/upgrading-a-cluster#upgrade_nodes" rel="nofollow noreferrer">manual upgrade</a>, <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-upgrades" rel="nofollow noreferrer">auto-upgrade</a>, <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-repair" rel="nofollow noreferrer">auto-repair</a>, and <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-autoscaler" rel="nofollow noreferrer">auto-scaling</a>. In addition, nodes are re-created when you enable a feature that requires node re-creation, such as <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/sandbox-pods" rel="nofollow noreferrer">GKE sandbox</a>, <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/intranode-visibility" rel="nofollow noreferrer">intranode visibility</a>, and <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/shielded-gke-nodes" rel="nofollow noreferrer">shielded nodes</a>.</p>
<p>-- <em><a href="https://cloud.google.com/kubernetes-engine/docs/concepts/node-images#modifications" rel="nofollow noreferrer">Cloud.google.com: Kubernetes Engine: Docs: Concepts: Node images: Modifications</a></em></p>
</blockquote>
<hr />
<p>As for:</p>
<blockquote>
<p>How can I make my <code>resolv.conf</code> to have the Internal nameservers by default or K8 to resolve with my internal DNS IPs?</p>
</blockquote>
<p>From the <code>GCP</code> and <code>GKE</code> perspective, you can use the <a href="https://cloud.google.com/dns" rel="nofollow noreferrer">Cloud DNS</a> to configure your <code>DNS</code> resolution in either way that:</p>
<ul>
<li>your whole <code>DOMAIN</code> is residing in <code>GCP</code> infrastructure (and you specify all the records).</li>
<li>your <code>DOMAIN</code> queries are forwarded to the DNS server of your choosing.</li>
</ul>
<p>You can create your <code>DNS</code> zone by following:</p>
<ul>
<li><code>GCP Cloud Console</code> (Web UI) -&gt; <code>Network Services</code> -&gt; <code>Cloud DNS</code> -&gt; <code>Create zone</code>:</li>
</ul>
<p>Assuming that you want to forward your <code>DNS</code> queries to your internal <code>DNS</code> server residing in <code>GCP</code> your configuration should look similar to the one below:</p>
<p><a href="https://i.stack.imgur.com/Pycq1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pycq1.png" alt="DNS" /></a></p>
<blockquote>
<p>A side note!</p>
<ol>
<li>Remember to follow the &quot;Destination DNS Servers&quot; steps to allow the <code>DNS</code> queries to your <code>DNS</code> server.</li>
<li>Put the internal IP address of your <code>DNS</code> server where the black rectangle is placed.</li>
</ol>
</blockquote>
<p>After that your <code>GKE</code> cluster should be able to resolve the <code>DNS</code> queries of your <code>DOMAIN.NAME</code>.</p>
<hr />
<h3>Additional resources:</h3>
<p>I found an article that shows how you can create a <code>DNS</code> forwarding for your <code>GCP</code> instances:</p>
<ul>
<li><em><a href="https://medium.com/faun/dns-forwarding-zone-forwarding-and-dns-policy-in-gcp-640a34b15bca" rel="nofollow noreferrer">Medium.com: Faun: DNS forwarding zone and dns policy in GCP</a></em></li>
</ul>
