I have multiple volumes and one claim. How can I tell the claim to which volume to bind to?
How does a PersistentVolumeClaim
know to which volume to bind? Can I controls 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 the claim and the volume using:
kubectl create -f pvc.json -f pv.json
I get the following listing of the 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 claim know to which volume to bind?