How can I control the PersistentVolumeClaim kubernet to bind to a specific PersistentVolume?

I have several volumes and one requirement. How can I make a claim for how much you need to bind?

How does PersistentVolumeClaim know what volume is being bound? Can I manage this using some other parameters or metadata?

I have the following PersistentVolumeClaim :

 { "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" } } } 

If I create a ticket and volume using:

 kubectl create -f pvc.json -f pv.json 

I get the following list of volumes and claims:

 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 <none> Bound default-drive-disk 10Gi RWO 2s 

How does the application know to what volume it is necessary to bind?

+9
kubernetes persistent-storage
source share
2 answers

The current implementation does not allow your PersistentVolumeClaim to target specific PersistentVolumes. Claims are tied to volumes based on its capabilities (access modes) and capacity.

The work has the following iteration of PersistentVolumes, which includes the PersistentVolumeSelector in the claim. This will work just like NodeSelector on Pod works. To bind, this volume would have to match the label selector. This is the targeting you are looking for.

Please see https://github.com/kubernetes/kubernetes/pull/17056 for a proposal containing PersistentVolumeSelector.

+6
source share

I made this work an annotation of "requestRef" .. as explained in

Is it possible to associate PVC with a specific PV?

thanks

-one
source share

All Articles