<p>I'm trying to setup a volume to use with Mongo on k8s.</p>

<p>I use <code>kubectl create -f pv.yaml</code> to create the volume.</p>

<p><strong>pv.yaml:</strong></p>

<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: pvvolume
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/nfs"
  claimRef:
    kind: PersistentVolumeClaim
    namespace: default
    name: pvvolume
</code></pre>

<p>I then deploy <a href="https://github.com/cvallance/mongo-k8s-sidecar/blob/master/example/StatefulSet/mongo-statefulset.yaml" rel="noreferrer">this StatefulSet</a> that has pods making PVCs to this volume.</p>

<p>My volume seems to have been created without problem, I'm expecting it to just use the storage of the host node.</p>

<p>When I try to deploy I get the following error:</p>

<blockquote>
  <p>Unable to mount volumes for pod
  "mongo-0_default(2735bc71-5201-11e8-804f-02dffec55fd2)": timeout
  expired waiting for volumes to attach/mount for pod
  "default"/"mongo-0". list of unattached/unmounted
  volumes=[mongo-persistent-storage]</p>
</blockquote>

<p>Have a missed a step in setting up my persistent volume?</p>

<p>A persistent volume is just the declaration of availability of some storage inside your kubernetes cluster. There is no binding with your pod at this stage. </p>

<p>Since your pod is deployed through a <code>StatefulSet</code>, there should be in your cluster one or more <code>PersistentVolumeClaims</code> which are the objects that connect a pod with a PersistentVolume.</p>

<p>In order to manually bind a PV with a PVC you need to edit your PVC by adding the following in its spec section:</p>

<pre><code>volumeName: "&lt;your persistent volume name&gt;"
</code></pre>

<p>Here an explanation on how this process works: <a href="https://docs.openshift.org/latest/dev_guide/persistent_volumes.html#persistent-volumes-volumes-and-claim-prebinding" rel="noreferrer">https://docs.openshift.org/latest/dev_guide/persistent_volumes.html#persistent-volumes-volumes-and-claim-prebinding</a></p>
