Junior — Middle
Explain what volume and persistent volume are in container orchestrators and how they are used for data storage.
sobes.tech AI
Answer from AI
In container orchestrators like Kubernetes, a volume is an abstraction for data storage that allows containers to save and share data outside their temporary filesystem.
Persistent Volume (PV) is a cluster resource representing physical or network storage that exists independently of the lifecycle of pods. PV provides persistent storage that can be used to retain data so that it is not lost when containers are restarted or deleted.
Usage:
- Volume is mounted into a container and provides temporary or permanent data storage.
- Persistent Volume is created by an administrator and linked to a Persistent Volume Claim (PVC), which requests the required amount and type of storage.
Thus, PV and PVC enable applications to preserve state and data despite dynamic container management.
Example of a PVC manifest in Kubernetes:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
This PVC can be attached to a pod for permanent data storage.