WEBVTT

00:01.020 --> 00:07.830
Hello and welcome to this lecture on Persistent Volumes in Kubernetes. In the previous lecture.

00:07.830 --> 00:10.210
We created a persistent volume.

00:10.290 --> 00:18.000
Now we will create a Persistent Volume Claim to make the storage available to a node. Persistent

00:18.000 --> 00:24.450
Volumes and Persistent Volume Claims are two separate objects in the Kubernetes namespace.

00:24.450 --> 00:31.050
An Administrator creates a set of Persistent Volumes and a user creates Persistent Volume Claims to

00:31.050 --> 00:32.230
use to storage.

00:32.910 --> 00:40.110
Once the Persistent Volume Claims are created, Kubernetes binds the Persistent Volumes to Claims based

00:40.110 --> 00:49.360
on the request and properties set on the volume. Every Persistent Volume Claims is bound to single Persistent

00:49.360 --> 00:56.500
volume during the binding process Kubernetes tries to find a persistent volume that has sufficient

00:56.500 --> 01:03.940
capacity as requested by the claim and any other request properties such as access modes volume modes

01:04.000 --> 01:11.950
storage class etc. However if there are multiple possible matches for a single claim and you would like

01:11.950 --> 01:18.700
to specifically use a particular volume you could still use labels and selectors to bind to the right

01:18.700 --> 01:20.140
volumes.

01:20.140 --> 01:27.610
Finally note that a smaller claim may get bound to a larger volume if all the other criteria matches

01:28.030 --> 01:30.230
and there are no better options.

01:30.310 --> 01:37.450
There is a one to one relationship between claims and volumes so no other claims can utilize the remaining

01:37.450 --> 01:39.720
capacity in the volume.

01:39.970 --> 01:46.970
If there are no volumes available the persistent volume claim will remain in a pending state until newer

01:46.980 --> 01:51.880
volumes are made available to the cluster once newer volumes are available.

01:51.880 --> 01:59.000
The claim would automatically be bound to the newly available volume let us now create a persistent

01:59.000 --> 02:00.270
volume claim.

02:00.290 --> 02:07.050
We start with a blank template said the API version to V1 and kind to persistent volume claim.

02:07.400 --> 02:15.170
We will name it myclaim. Under specification set the accessModes to ReadWriteOnce. And set resources

02:15.260 --> 02:23.180
to request a storage of 500 mega bytes. Create the claim using kubectl create command.  To view the

02:23.180 --> 02:30.860
created claim run the kubectl get persistentvolumeclaim command. We see the claim in a pending state.

02:31.700 --> 02:38.210
When the claim is created, kubernetes looks at the volume created previously. The access Modes match.

02:38.720 --> 02:45.950
The capacity requested is 500 Megabytes but the volume is configured with 1 GB of storage. Since there

02:45.950 --> 02:48.440
are no other volumes available.

02:48.440 --> 02:55.910
The persistent volume claim is bound to persistent volume when we run to get volumes command again.

02:55.940 --> 03:04.360
We see the claim is bound to the persistent volume we created perfect. To delete a PVC run the kubectl

03:04.430 --> 03:11.060
delete persistent volume claim command but what happens to the underlying persistent volume when the

03:11.060 --> 03:12.560
claim is deleted.

03:12.740 --> 03:16.910
You can choose what is to happen to the volume by default.

03:17.000 --> 03:25.760
It is set to retain meaning the persistent volume will remain until it is manually deleted by the administrator.

03:25.760 --> 03:32.560
It is not available for reuse by any other claims or it can be deleted automatically.

03:32.600 --> 03:38.900
This way as soon as the claim is deleted the volume will be deleted as well thus freeing up storage

03:39.380 --> 03:44.810
on the end storage device or a third option is to recycle.

03:44.890 --> 03:51.950
In this case the data in the data volume will be scrubbed before making it available to other claims

03:53.000 --> 03:55.250
well that's it for this lecture.

03:55.250 --> 04:01.730
Head over to the coding exercises section and practice configuring and troubleshooting persistent volumes

04:01.850 --> 04:04.350
and volume claims in Kubernetes.

