Persistent Volume and Persistent Volume Claims- Kubernetes

Joan Ngugi
3 min readMar 29, 2020

Volumes in Kubernetes can be thought of as a directory that is accessible to the containers in a pod. Volumes help you persist data even if your container restarts. There are different types of volumes in Kubernetes and the type defines how the volume is created and it’s content.

Persistent Volume

A persistent volume is a piece of storage in a Kubernetes cluster. PersistentVolumes are a cluster-level resource like nodes, which don’t belong to any namespace. It is provisioned by the administrator and has a particular file size. This way, a developer deploying their app on Kubernetes need not know the underlying infrastructure. When the developer needs a certain amount of persistent storage for their application, the system administrator configures the cluster so that they consume the PersistentVolume provisioned in an easy way.

Creating Persistent Volume

kind: PersistentVolume
apiVersion: v1
metadata:
name:pv01
spec:
capacity: # defines the capacity of PV we are creating
storage: 10Gi #the amount of storage we are tying to claim
accessModes: # defines the rights of the volume we are creating
- ReadWriteOnce
hostPath:
path: "/tmp/data01" # path to which we are creating the volume

--

--