<p>I am trying to mount a NFS share (outside of k8s cluster) in my container via DNS lookup, my config is as below     </p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: service-a
spec:
  containers:
  - name: service-a
    image: dockerregistry:5000/centOSservice-a
    command: ["/bin/bash"]
    args: ["/etc/init.d/jboss","start"]
    volumeMounts:
      - name: service-a-vol
        mountPath: /myservice/por/data
  volumes:
    - name: service-a-vol
      nfs:
        server: nfs.service.domain
        path: "/myservice/data"
  restartPolicy: OnFailure 
</code></pre>

<p>nslookup of <code>nfs.service.domin</code> works fine from my container. This is achiveded via <code>StubDomain</code> . However when creating the container it fails to resolve the nfs server. Error:</p>

<pre><code>Warning  FailedMount  &lt;invalid&gt;  kubelet, worker-node-1  MountVolume.SetUp failed for volume "service-a-vol" : mount failed: exit status 32
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/44aabfb8-2767-11e8-bcf9-fa163ece9426/volumes/kubernetes.io~nfs/service-a-vol --scope -- mount -t nfs nfs.service.domain:/myservice/data /var/lib/kubelet/pods/44aabfb8-2767-11e8-bcf9-fa163ece9426/volumes/kubernetes.io~nfs/service-a-vol
Output: Running scope as unit run-27293.scope.
mount.nfs: Failed to resolve server nfs.service.domain: Name or service not known
mount.nfs: Operation already in progress
</code></pre>

<p>If i modify <code>server: nfs.service.domain</code> to <code>server: 10.10.1.11</code> this works fine! So to summarise</p>

<ol>
<li>DNS resolution of the service works fine</li>
<li>Mounting via DNS resolution does not</li>
<li>Mounting via specific IP address works</li>
<li>I have tried <code>Headless Service</code> instead of StubDomain but the same issue exists</li>
</ol>

<p>Any help much appreciated</p>

<p><em>Update 1</em>: If i add an entry in the /etc/hosts files of worker/master nodes <code>10.10.1.11 nfs.service.domain</code> then my configuration above <code>server: nfs.service.domain</code> works. This is obviously not a desired workaround...</p>

<p>As pointed out by @Giorgio Cerruti and as referenced in <a href="https://github.com/kubernetes/kubernetes/issues/44528/" rel="nofollow noreferrer">this github ticket</a> among others this is currently not possible as the node needs to be able to resolve the DNS entry and it does not resolve kube-dns. Two possible solutions are:</p>

<ol>
<li>Update <code>/etc/hosts</code> of each kubernetes node to resolve the NFS endpoint (as per update above). This is a primitive solution.</li>
<li><p>A more robust fix that would work for this NFS service and any other remote service in the same domain (as NFS) is to add the remote DNS server to the kubernetes nodes <code>resolv.conf</code> </p>

<p><code>someolddomain.org service.domain xx.xxx.xx
nameserver 10.10.0.12
nameserver 192.168.20.22
nameserver 8.8.4.4</code></p></li>
</ol>
