Junior — Middle
How is data volume management carried out within Kubernetes, and how are they integrated with pods?
sobes.tech AI
Answer from AI
In Kubernetes, data volumes are managed using Volume objects, which provide pods access to persistent or temporary storage.
Key points:
- Volume — an abstraction for data storage that exists within the lifecycle of a pod.
- PersistentVolume (PV) — a cluster resource representing physical storage (e.g., a cloud disk, NFS).
- PersistentVolumeClaim (PVC) — a user request for a specific amount and type of storage.
Integration with pods occurs through specifying in the pod or deployment manifest:
- The pod specifies PVC in the volumes section.
- Containers mount this volume at the desired filesystem path.
Example manifest with PVC and mounting in a pod:
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: app
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: example-pvc
Thus, data is stored outside the pod's lifecycle and can be reused or shared.