<p>I am running mac OSX Catalina using the docker application with the Kubernetes option turned on. I create a PersistentVolume with the following yaml and command.</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs-data
spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 10Gi
  persistentVolumeReclaimPolicy: Retain
  nfs:
    server: 192.168.1.250
    path: "/volume1/docker"
</code></pre>

<blockquote>
  <p>kubectl apply -f pv.yml</p>
</blockquote>

<p>This create and PersistentVolume with name pv-nfs-data. Next I then create a PersistentVolumeClaim with the following yaml and command</p>

<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-nfs-data
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
</code></pre>

<blockquote>
  <p>kubectl apply -f pvc.yml</p>
</blockquote>

<p>This create a PersistentVolumeClaim with the name pvc-nfs-data however it doen't bind it to the available PersistentVolume (pv-nfs-data). Instead it creates an new one and binds it to that. How do I make the PersistentVolumeClaim bind to the available PersistentVolume</p>

<p>The Docker for Mac <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#defaultstorageclass" rel="nofollow noreferrer">default storage class</a> is the <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#dynamic" rel="nofollow noreferrer">dynamic provisioning type</a>, like you would get on AKS/GKE, where it allocates the physical storage as well.</p>

<pre><code>→ kubectl get StorageClass
NAME                 PROVISIONER          AGE
hostpath (default)   docker.io/hostpath   191d
</code></pre>

<p>For a PVC to use an existing PV, you can disable the storage class and specify in the PV which PVC can use it with a <code>claimRef</code>.</p>

<h3>Claim Ref</h3>

<p>The PV includes a <code>claimRef</code> for the PVC you will create</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs-data
spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: 10Gi
  claimRef:
    namespace: insert-your-namespace-here
    name: pv-nfs-data-claim
  persistentVolumeReclaimPolicy: Retain
  nfs:
    server: 192.168.1.250
    path: "/volume1/docker"
</code></pre>

<p>The PVC sets <code>storageClassName</code> to <code>''</code></p>

<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv-nfs-data-claim
  namespace: insert-your-namespace-here
spec:
  storageClassName: ''
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
</code></pre>

<h3>Dynamic</h3>

<p>You can go the dynamic route with NFS by adding an <a href="https://github.com/kubernetes-incubator/external-storage/tree/master/nfs" rel="nofollow noreferrer">NFS dynamic provisioner</a>,   create a <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">storage class</a> for it and let kubernetes work the rest out. More recent version of Kubernetes (1.13+) can use the <a href="https://github.com/kubernetes-csi/csi-driver-nfs" rel="nofollow noreferrer">CSI NFS driver</a></p>
