<p>I have a VPN tunnel from gcloud to our local site.
The local site has 2 nameservers running on <code>172.16.248.32</code> and <code>172.16.248.32</code></p>

<p>These nameservers resolve our local domain names such as mycompany.local</p>

<p>How can I use these nameservers from gcloud, so the pods in my Kubernetes cluster do resolve mycompany.local as well?</p>

<p>You'll have to configure your upstream DNS servers to be <code>172.16.248.32</code> and the other IP.</p>

<p>You can do it on a <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-config" rel="nofollow noreferrer">per pod basis</a> like this:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  namespace: default
  name: dns-example
spec:
  containers:
    - name: test
      image: nginx
  dnsPolicy: "None"
  dnsConfig:
    nameservers:
      - 172.16.248.32
    searches:
      - ns1.svc.cluster.local
      - mycompany.local
    options:
      - name: ndots
        value: "2"
      - name: edns0
</code></pre>

<p>So when the pods are created they include an <code>/etc/resolv.conf</code> like this:</p>

<pre><code>nameserver 172.16.248.32
search ns1.svc.cluster.local my.dns.search.suffix
options ndots:2 edns0
</code></pre>

<p>The other option will vary whether you are using coredns or kube-dns, and that is configuring stub-domains (these configs will also propagate to the <code>/etc/resolv.conf</code> file in your pods, all documented <a href="https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/" rel="nofollow noreferrer">here</a>:</p>

<p><strong>coredns</strong></p>

<pre><code># coredns in the coredns ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           upstream 172.16.0.1
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        proxy . 172.16.0.1
        cache 30
        loop
        reload
        loadbalance
    }
    mycompany.local:53 {
        errors
        cache 30
        proxy . 172.16.248.32
    }
</code></pre>

<p><strong>kube-dns</strong></p>

<pre><code># kube-dns in the kube-dns ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-dns
  namespace: kube-system
data:
  stubDomains: |
    {"mycompany.local": ["172.16.248.32"]}
  upstreamNameservers: |
    ["8.8.8.8", "8.8.4.4"]
</code></pre>
