<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>First of all, <code>PersistentVolume</code> resources don’t belong to any namespace. They’re cluster-level resources like nodes, but <code>PersistentVolumeClaim</code> objects can only be created in a specific namespace.</p>

<p>Seems like when you created the claim earlier, it was immediately bound to the <code>PersistentVolume</code>. Can you show output of the commands:</p>

<pre><code>$ kubectl get pv
$ kubectl get pvc
</code></pre>

<p>Highly likely your <code>persistentVolumeReclaimPolicy</code> was set to <code>Retain</code>, so your <code>PersistentVolume</code> is in <code>Released</code> status now. Since there is no another <code>PersistenVolume</code> resource matches your claim's requirements your <code>PersistentVolumeClaim</code> is in <code>Pending</code> status.</p>
