Volume – Volume in Kubernetes can be thought of as a directory that can be accessed by containers in the pod. Volume helps persists the data even if the pod restarts.
- PV
- A Persistent Volume (PV) is a piece of storage in the cluster.
- It is a cluster-level resource like a pod and doesn’t have any namespace.
- It is been manually provisioned by an administrator, or dynamically provisioned by Kubernetes using a StorageClass.
- PVC
- A PersistentVolumeClaim (PVC) is a request for storage by a user that can be fulfilled by a PV.
- Persistent Volumes and PersistentVolumeClaim are independent of Pod lifecycles and preserve data through restarting, rescheduling, and even deleting Pods.
- Access Modes
- ReadWriteOnce – It is used when we allow only one node to read & write on the volume. Multiple pods running on the same node can access the volume.
- ReadOnlyMany – It is used when we allow read access to many pods.
- ReadWriteMany – It is used when we allow read & write access to many nodes.
- ReadWriteOncePod – It is used when we allow only one pod in a node for reading & writing.