<p>I have multiple volumes and one claim. How can I tell the claim to which volume to bind to?</p>

<p>How does a <code>PersistentVolumeClaim</code> know to which volume to bind? Can I controls this using some other parameters or metadata?</p>

<p>I have the following <code>PersistentVolumeClaim</code>:</p>

<pre><code>{                                                                                                                 
    "apiVersion": "v1",                                                                                           
    "kind": "PersistentVolumeClaim",                                                                              
    "metadata": {                                                                                                 
        "name": "default-drive-claim"                                                                             
    },                                                                                                            
    "spec": {                                                                                                     
        "accessModes": [                                                                                          
            "ReadWriteOnce"                                                                                       
        ],                                                                                                        
        "resources": {                                                                                            
            "requests": {                                                                                         
                "storage": "10Gi"                                                                                 
            }                                                                                                     
        }                                                                                                         
    }                                                                                                             
}

{                                                                                                                 
    "apiVersion": "v1",                                                                                           
    "kind": "PersistentVolume",
    "metadata": {                                                                                                 
        "name": "default-drive-disk",                                                                             
        "labels": {                                                                                               
             "name": "default-drive-disk"                                                                         
        }
    },      
    "spec": {                                                                                                     
        "capacity": {
            "storage": "10Gi"                                                                                     
        },      
        "accessModes": [                                                                                          
            "ReadWriteOnce"                                                                                       
        ],                                                                                                        
        "gcePersistentDisk": {                                                                                    
            "pdName": "a1-drive",
            "fsType": "ext4"
        }
    }
}
</code></pre>

<p>If I create the claim and the volume using:</p>

<pre><code>kubectl create -f pvc.json -f pv.json
</code></pre>

<p>I get the following listing of the volumes and claims:</p>

<pre><code>NAME                 LABELS                    CAPACITY   ACCESSMODES   STATUS    CLAIM                         REASON    AGE
default-drive-disk   name=default-drive-disk   10Gi       RWO           Bound     default/default-drive-claim             2s
NAME                  LABELS    STATUS    VOLUME               CAPACITY   ACCESSMODES   AGE
default-drive-claim   &lt;none&gt;    Bound     default-drive-disk   10Gi       RWO           2s
</code></pre>

<p>How does the claim know to which volume to bind?</p>

<p>The current implementation does not allow your PersistentVolumeClaim to target specific PersistentVolumes.  Claims bind to volumes based on its capabilities (access modes) and capacity.</p>

<p>In the works is the next iteration of PersistentVolumes, which includes a PersistentVolumeSelector on the claim.  This would work exactly like a NodeSelector on Pod works.  The volume would have to match the label selector in order to bind.  This is the targeting you are looking for.</p>

<p>Please see <a href="https://github.com/kubernetes/kubernetes/pull/17056" rel="noreferrer">https://github.com/kubernetes/kubernetes/pull/17056</a> for the proposal containing PersistentVolumeSelector.</p>
