<p>In this repository <a href="https://github.com/mappedinn/kubernetes-nfs-volume-on-gke" rel="nofollow noreferrer">https://github.com/mappedinn/kubernetes-nfs-volume-on-gke</a> I am trying to share a volume through NFS service on GKE. The NFS file sharing is successful if hard coded IP address is used. </p>

<p>But, in my point of view, it would be better to use DNS name in stead of hard coded IP address.</p>

<p>Below is the declaration of the NFS service being used for sharing a volume in Google Cloud Platform:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nfs-server
spec:
  ports:
    - name: nfs
      port: 2049
    - name: mountd
      port: 20048
    - name: rpcbind
      port: 111
  selector:
    role: nfs-server
</code></pre>

<p>Below is the definition of the PersistentVolume with hard coded IP address:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: wp01-pv-data
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 10.247.248.43 # with hard coded IP, it works
    path: "/"
</code></pre>

<p>Below is the definition of the PersistentVolume with DNS name:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: wp01-pv-data
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server:  nfs-service.default.svc.cluster.local # with DNS, it does not works
    path: "/"
</code></pre>

<p>I am using this <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a> for getting the DNS of the service. Is there any thing missed?</p>

<p>Thanks</p>

<p>The problem is in DNS resolution on node it self. Mounting of the NFS share to the pod is a job of kubelet that is launched on the node. Hence the DNS resolution happens according to /etc/resolv.conf on the node it self as well. What could suffice is adding a <code>nameserver &lt;your_kubedns_service_ip&gt;</code> to the nodes <code>/etc/resolv.conf</code>, but it can become somewhat chicken-and-egg problem in some corner cases</p>
