<p>I am trying to create both a PersistentVolume and a PersistentVolumeClaim on Google Kubernetes Engine. </p>

<p>The way to link them is via labelSelector.
I am creating the objects with this definition:</p>

<p>volume.yml</p>

<pre><code>---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-test
  namespace: mynamespace
  labels:
    pv-owner: owner
    pv-usage: pv-test
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: /data/test/
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pv-test
  namespace: mynamespace
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  selector:
    matchLabels:
      pv-usage: pv-test
</code></pre>

<p>and running:</p>

<pre><code>kubectl apply -f volume.yml
</code></pre>

<p>Both objects are successfully created, however, VolumeClaim apparently keeps pending forever awaiting a Volume that matches its requirements.</p>

<p>Could you please help me?</p>

<p>Thanks!</p>

user2798792
<p>Thanks for your help @konstantin-vustin</p>

<p>I found the solution. I had to specify <strong>storageClassName: manual</strong> attribute in the spec of both objects.</p>

<p><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class</a></p>

<p>According to the doc</p>

<blockquote>
  <p>A PV with no storageClassName has no class and can only be bound to PVCs that request no particular class.</p>
</blockquote>

<p>So IMO it should have worked before, so I am not sure if I clearly understood it.</p>

<p>This was the status before</p>

<pre><code>kubectl get pv pv-test-vol &amp;&amp; kubectl get pvc pv-test --namespace openwhisk
NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM     STORAGECLASS   REASON    AGE
pv-test-vol   2Gi        RWO            Retain           Available             manual                   26s
NAME      STATUS    VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pv-test   Pending                                       standard       26s
</code></pre>

<p>The updated definitions</p>

<pre><code>---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-test
  namespace: mynamespace
  labels:
    pv-owner: owner
    pv-usage: pv-test
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: /data/test/
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pv-test
  namespace: mynamespace
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  selector:
    matchLabels:
      pv-usage: pv-test
</code></pre>

<p>This is the status after</p>

<pre><code>kubectl get pv pv-test-vol &amp;&amp; kubectl get pvc pv-test --namespace openwhisk
NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM               STORAGECLASS   REASON    AGE
pv-test-vol   2Gi        RWO            Retain           Bound     openwhisk/pv-test   manual                   4s
NAME      STATUS    VOLUME        CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pv-test   Bound     pv-test-vol   2Gi        RWO            manual         4s
</code></pre>
