0
0
Kubernetesdevops~10 mins

PersistentVolumeClaim (PVC) definition in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - PersistentVolumeClaim (PVC) definition
Write PVC YAML
kubectl apply PVC
Kubernetes API Server receives
PVC stored in etcd
PVC status: Pending
Controller finds matching PV
Bind PV to PVC
PVC status: Bound
Pod uses PVC to mount storage
This flow shows how a PVC is defined, applied, matched to a PV, and then bound for use by a pod.
Execution Sample
Kubernetes
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
This YAML defines a PVC requesting 1Gi storage with ReadWriteOnce access mode.
Process Table
StepActionEvaluationResult
1Write PVC YAML fileYAML validPVC definition ready
2Run 'kubectl apply -f pvc.yaml'kubectl sends requestPVC object created in cluster
3API Server stores PVCPVC stored in etcdPVC status is Pending
4Controller checks for matching PVFind PV with >=1Gi and ReadWriteOncePV found and bound to PVC
5PVC status updatedPVC status changes to BoundPVC ready for pod use
6Pod mounts PVC volumePod uses PVC namePod has persistent storage mounted
7EndPVC bound and usableProcess complete
💡 PVC is bound to a matching PV and ready for pod usage
Status Tracker
VariableStartAfter Step 3After Step 5Final
PVC.status.phaseNonePendingBoundBound
PVC.spec.resources.requests.storageNone1Gi1Gi1Gi
PVC.spec.accessModes[0]NoneReadWriteOnceReadWriteOnceReadWriteOnce
Key Moments - 3 Insights
Why does the PVC status start as Pending?
At step 3 in the execution_table, the PVC is created but not yet matched to a PersistentVolume, so its status is Pending until a suitable PV is found and bound.
What does 'Bound' status mean for a PVC?
As shown in step 5, 'Bound' means the PVC has been successfully matched and linked to a PersistentVolume, making the storage ready for use by pods.
Can a pod use a PVC before it is Bound?
No, according to step 6, the pod can only mount the PVC after its status is Bound, ensuring the storage is allocated and available.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the PVC status after step 3?
AReleased
BBound
CPending
DLost
💡 Hint
Check the 'Result' column at step 3 in the execution_table.
At which step does the PVC become ready for pod use?
AStep 5
BStep 3
CStep 2
DStep 1
💡 Hint
Look for when PVC status changes to Bound in the execution_table.
If the requested storage was increased to 5Gi, what would change in the execution_table?
AStep 6 would be skipped
BStep 4 would look for PV with >=5Gi
CStep 3 PVC status would be Bound immediately
DNo changes at all
💡 Hint
Refer to step 4 where the controller finds a matching PV based on requested storage.
Concept Snapshot
PersistentVolumeClaim (PVC) is a request for storage in Kubernetes.
Define PVC in YAML with accessModes and storage size.
Apply with kubectl to create PVC object.
PVC status starts Pending until matched to a PersistentVolume (PV).
Once Bound, pods can mount the PVC for persistent storage.
Full Transcript
This visual execution traces the lifecycle of a PersistentVolumeClaim (PVC) in Kubernetes. First, a PVC YAML is written specifying storage size and access mode. When applied with kubectl, the PVC object is created and stored in the cluster with status Pending. The controller then searches for a matching PersistentVolume (PV) that meets the requested size and access mode. Once found, the PV is bound to the PVC, updating its status to Bound. Finally, pods can mount the PVC to use the persistent storage. Key moments include understanding the Pending and Bound statuses and knowing that pods can only use PVCs after they are Bound.