Understanding Kubernetes PV and PVC

Filed Under: Random
Persistent Volume And Persistent Volume Claim

Hello, readers! In this article, we will be focusing on Kubernetes PV and PVC – Way to access Volumes in detail.

So, let us begin! 馃檪

What is Kubernetes Volume?

Volumes define the data storage space. That is, when we have data moving to cloud or any space we mean to say that we are provisioning space to store the data at runtime efficiently.

Kubernetes Volumes help us solve the problem of managing storage across the platform. When we have applications or units moving to cloud, the most prior and important provisioning resource that comes into picture is the storage. Because, when we have data in any form being uplifted and managed by any cloud platform or orchestrating tool, we too need to make sure that the underlying data being static or run-time needs to be in place intact.

In the course of this topic, we will be having a look at Kubernetes Persistent Volume (PV) and Persistent Volume Claim (PVC) to get space for the data being orchestrated through k8.

Let us go ahead with it.

1. Kubernetes Persistent Volumes (PV)

Kubernetes Persistent Volumes (PV) is actually a portion of storage that is available within the cluster. Yes, it is a storage block within the cluster and therefore it is a cluster level resource. The PV can be either provisioned to the user by the k8 administrator or can dynamically be provisioned through Storage Classes available in k8. These are independent of the pods and remain persistent even after the deletion of pod.

Going ahead, let us now look at the YAML structure that will enable us to provision a Persistent Volume for a user-

pv.yaml file

apiVersion: v1
kind: PersistentVolume
  name: demo-pv
  storageClassName: ""
    storage: 10Gi
     - ReadWriteOnce
    name: demo-pvc
    namespace: demo
  • As we are creating a PV, the kind would be PersistentVolume.
  • Under the .metadata.name, we would place the name for the volume.
  • The capacity, includes the storage space we need (10Gi in our case) and the accessModes which can be read and write once, read and write many, etc.
  • We would then provide claimRef as it’s name and namespace name so that no other namespace or PVC can claim the above created PV. [Will be having a look at the concept of PVC in the next section]

Thus, we will now apply the PV to our desired namespace.

kubectl apply -f pv.yaml -n demo

Let us now describe the created Persistent volume.

kubectl describe pv demo-pv -n demo
Name:            demo-pv
Labels:          <none>
Annotations:     <none>
StorageClass:    ""
Status:          Active
Claim:           Bound
Events:            <none>

2. Accessing PV with Kubernetes PVC

Having understood PV in Kubernetes, let us understand how to access or claim it. Unless and until we do not claim it, a PV is just a piece of storage block in the cluster that is open for claims.

For the same, we need to bind the PV to our application.

By applying PV, we request the resource (PV) storage as a user. This can be assumed as a Pod because like a Pod, even a PVC consumes resources of PV.

Let us now have a look at the PVC YAML structure-


apiVersion: v1
kind: PersistentVolumeClaim
  name: demo-claim
  namespace: demo
  storageClassName: "" 
  volumeName: demo-pv

With this YAML structure, one can understand that in PVC, we refer the Persistent Volume name as well as the namespace to set the boundaries and bind it to each other.

Let us now describe the PVC–

kubectl describe pvc demo-pvc
Name:          demo-pvc
Namespace:     demo
StorageClass:  ""
Labels:        <none>


By this, we have come to the end of this topic. Feel free to comment below, in case you come across any question.

For more such posts related to Kubernetes, Stay tuned with us.

Till then, Happy Learning! 馃檪

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors