Member-only story

K8s Storage class, PV, and PVC

Park Sehun
3 min readSep 6, 2023

Kubernetes provides several mechanisms for managing storage in a cluster, including volumes, persistent volumes (PVs), and storage classes.

  • Persistent Volume: Kubernetes has storage devices used in the cluster — SSD, NVMe disks, NAS, NFS servers.
  • Volume: At its core, a volume is a directory, possibly with some data in it, accessible to the containers in a pod. A process in a container sees a filesystem view composed from the initial contents of the container image, plus volumes (if defined) mounted inside the container.
  • Storage Class: Dynamic provisioning of persistent volumes
  • Projected Volumes: secret, downwardAPI, configMap, serviceAccountToken (multiple source of data into a single volume within a pod)
  • Ephemeral Volumes: emptyDir, configMap, downwardAPI, secret, CSI ephemeral volumes, generic ephemeral volumes (This is typically non-persistent data like deleted when the pod is terminated or rescheduled)

Sample YAML files

(1) Persistent Volume

apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: my-storage-class
hostPath:
path: /data/my-pv

---
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: nginx
volumeMounts:
- name: my-volume
mountPath…

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response