Skip to content

Commit 318d17b

Browse files
cofycYecheng Fu
authored andcommitted
add pre-binding section
1 parent 8fab6b0 commit 318d17b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

content/en/docs/concepts/storage/persistent-volumes.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,45 @@ spec:
174174
175175
However, the particular path specified in the custom recycler Pod template in the `volumes` part is replaced with the particular path of the volume that is being recycled.
176176

177+
### Reserving a PersistentVolume
178+
179+
The control plane can [bind PersistentVolumeClaims to matching PersistentVolumes](#binding) in the
180+
cluster. However, if you want a PVC to bind to a specific PV, you need to pre-bind them.
181+
182+
By specifying a PersistentVolume in a PersistentVolumeClaim, you declare a binding between that specific PV and PVC.
183+
If the PersistentVolume exists and has not reserved PersistentVolumeClaims through its `claimRef` field, then the PersistentVolume and PersistentVolumeClaim will be bound.
184+
185+
The binding happens regardless of some volume matching criteria, including node affinity.
186+
The control plane still checks that [storage class](https://kubernetes.io/docs/concepts/storage/storage-classes/), access modes, and requested storage size are valid.
187+
188+
```
189+
apiVersion: v1
190+
kind: PersistentVolumeClaim
191+
metadata:
192+
name: foo-pvc
193+
namespace: foo
194+
spec:
195+
volumeName: foo-pv
196+
...
197+
```
198+
199+
This method does not guarantee any binding privileges to the PersistentVolume. If other PersistentVolumeClaims could use the PV that you specify, you first need to reserve that storage volume. Specify the relevant PersistentVolumeClaim in the `claimRef` field of the PV so that other PVCs can not bind to it.
200+
201+
```
202+
apiVersion: v1
203+
kind: PersistentVolume
204+
metadata:
205+
name: foo-pv
206+
spec:
207+
claimRef:
208+
name: foo-pvc
209+
namespace: foo
210+
...
211+
```
212+
213+
This is useful if you want to consume PersistentVolumes that have their `claimPolicy` set
214+
to `Retain`, including cases where you are reusing an existing PV.
215+
177216
### Expanding Persistent Volumes Claims
178217
179218
{{< feature-state for_k8s_version="v1.11" state="beta" >}}

0 commit comments

Comments
 (0)