Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 71/ 160
04. Storage & Persistent Data

Volume Expansion & Resizing PVCs Online

Grow PVCs online when the StorageClass and CSI driver support expansion.

IntermediateExpansion · allowVolumeExpansion · Resize3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Volume expansion asks the warehouse for a larger unit before the on-site manager stretches the shelves to fill it. The simple Kubernetes rule is: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Think of it like…

Volume expansion asks the warehouse for a larger unit before the on-site manager stretches the shelves to fill it.

Where you’ve seen it

Before approving a data-path change, the storage owner runs kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w. Expected evidence: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds. If the run instead shows this symptom, stop and restore the last known state: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.

Words you’ll hear

Expansion
For this lesson, Expansion is the controlling idea: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.
allowVolumeExpansion
allowVolumeExpansion is the checkpoint; run kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w and inspect the owner chain. Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.
Resize
Resize is the outcome to preserve; the cost is explicit: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.
Verification evidence
The evidence command is kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w. It connects the declaration to this behavior: Grow PVCs online when the StorageClass and CSI driver support expansion.

Visual diagram

Loading interactive diagram

Theory & deep dive

How Expansion reaches the intended state

Grow PVCs online when the StorageClass and CSI driver support expansion. Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

The concrete checkpoint is kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w; compare the Expansion owner, allowVolumeExpansion state, and Resize outcome instead of treating YAML acceptance as proof.

Verify allowVolumeExpansion, not only object creation

Run kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w after the change and correlate the result with Events and the owning object. Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Key takeaway: Expansion is implemented only when this invariant remains observable: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

allowVolumeExpansion: failure boundary and production cost

Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path. The prerequisite contract is concrete: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible. A safe design limits blast radius, records the last good configuration, and uses kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w as a deterministic rollback checkpoint.

Recover from allowVolumeExpansion drift

Capture the current state with kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.

Key takeaway: Accept the trade-off consciously: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.

How it works, step by step

Step 1 of 4
Data owner

1. Declare the data contract

State capacity, topology, access, and ownership in the claim or class: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Expansion contract → owned state
Key numbers at this step
Goal
Grow PVCs online when the StorageClass and CSI driver support expansion.
Owner
Expansion

When to use it & trade-offs

What it is

Grow PVCs online when the StorageClass and CSI driver support expansion. Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Why it matters: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path. The invariant at risk is specific: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds. The quickest fact check before changing the design is kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w.

When to reach for it

  • Use Expansion to enforce this invariant: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.
  • Use allowVolumeExpansion evidence from kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w in reviews and incident timelines. Grow PVCs online when the StorageClass and CSI driver support expansion.
  • Choose the managed external data plane route only when this cost is justified by governance or scale: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.

When to avoid or be careful

  • Avoid assuming Expansion is complete after YAML submission; the required behavior is concrete: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.
  • Avoid treating the next symptom as random; check the owner and state with kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w first: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.
  • Avoid adopting a heavier platform wrapper before measuring its cost: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.

Native, manual, and managed paths for Expansion

Dynamically provisioned storage
Best for: Grow PVCs online when the StorageClass and CSI driver support expansion. A concrete incident check is kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w.

Strengths: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Watch out: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible. Recovery must also recognize this signal: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.

Manual pre-provisioning
Best for: Quickly testing the allowVolumeExpansion assumption with kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w; the expected invariant is: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Strengths: kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike Expansion, it does not make this symptom self-documenting: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.

Managed external data plane
Best for: Teams that need Resize integrated with guardrails; the evidence path is kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.

Watch out: The added platform ownership buys value at this cost: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.
  • Trace Expansion to Resize through allowVolumeExpansion; the invariant is: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.
  • Recognize the symptom: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.
  • Justify the cost: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.
  • Verify with kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w instead of only inspecting YAML.

Benchmarks & rules of thumb

1 -
resize direction is growth, not generic shrink
2 -
checks required: StorageClass permission and CSI driver support
0 -
guaranteed no-restart filesystem growth across drivers

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the Expansion owner contract: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds.
  • Ignoring this telltale condition leads to unrelated changes: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path.
  • Repeating kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w without an owner for remediation wastes retry cost. Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds?
  • Which owner object, logs, and Events would you inspect for this symptom-Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path-?
  • At what threshold would this cost become unacceptable: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible?
Interview tip: Interview sequence: state the invariant, run kubectl patch pvc data --type=merge -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'; kubectl get pvc data -w, name the failure, then justify the cost. Invariant: Online resize edits PVC requested storage upward, requires allowVolumeExpansion on the StorageClass and driver, and can finish only after filesystem or node-side resize succeeds. Failure: Claim size may change in the API while the filesystem remains old or the Pod must restart, and a driver cannot shrink an ordinary provisioned volume through this path. Cost: Online growth avoids migration but ties recovery to vendor implementation, consumes quota, and makes size increases effectively irreversible.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Volume Expansion & Resizing PVCs Online with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
StatefulSet volumeClaimTemplates & Per-Pod Storage
Next topic
Volume Snapshots, Cloning & Restoring Data