When we created volumes in the previous section, we configured volumes within the pod definition file, so every configuration information required to configure storage for the volume goes within the pod definition file.

Now, when you have a large environment with a lot of users deploying a lot of pods, the users would have to configure storage every time for each pod.

Whatever storage solution is used, the users who deploys the pods would have to configure that on all pod definition files in his environment.

Every time there are changes to be made the user would have to make them on all of his pods.

Instead, you would like to manage storage more centrally. You would like it to be configured in a way that an administrator can create a large pool of storage and then have users carve out pieces from it as required.

That is where persistent volumes can help us.

A persistent volume is a cluster-wide pool

of storage volumes configured by an administrator

to be used by users deploying applications on the cluster. The users can now select storage from this pool

using persistent volume claims.

Let us now create a persistent volume.

We start with the base template and update the API version. Set the kind to persistent volume and name it PV-Vol 1.

Under the spec section, specify the access modes. Access mode defines how a volume should be mounted on the hosts,

whether in a read-only mode or read/write mode, et cetera.

The supported values are ReadOnlyMany, ReadWriteOnce, or ReadWriteMany mode. Next is the capacity.

Specify the amount of storage to be reserved for this persistent volume, which is set to 1 GB here.

Next comes the volume type. We will start with the hostPath option that uses storage from the node’s local directory.

Remember, this option is not to be used in a production environment. To create the volume, run Kube Control, create command,

and to list the created volume, run the Kube Control, get persistent volume command.

Replace the host path option

with one of the supported storage solutions

as we saw in the previous lecture,

like AWS Elastic Block Store, et cetera.

Well, that’s it on persistent volumes in this lecture.

In the next lecture,

we will look at how we use persistent volume claims

to claim the volume configured with persistent volumes.