Skip to main content

Volume Expansion: Expanding Hotel Storage

Volume expansion is like expanding hotel storage. Need more space? Expand storage. No downtime. That's volume expansion.

🎯 The Big Picture​

Think of volume expansion like expanding hotel storage. Storage full? Need more? Expand storage facility. No downtime. That's volume expansion.

Volume expansion increases storage size. Online expansion. No downtime. Requires Storage Class support. Essential for growing data.

The Storage Expansion Analogy​

Think of volume expansion like storage expansion:

Storage full: Storage facility full

  • Need more space
  • Expansion needed
  • Growing data

Expand storage: Expand facility

  • Increase size
  • No downtime
  • Seamless

Online expansion: Expand while using

  • No interruption
  • Continuous operation
  • Smooth

Once you see it this way, volume expansion makes perfect sense.

What is Volume Expansion?​

Volume expansion:

  • Increase storage size
  • Online expansion
  • No downtime
  • Requires support

Think of it as: Storage expansion. Increase size. No downtime.

Why Volume Expansion?​

Problems without expansion:

  • Storage full
  • Need to recreate
  • Downtime
  • Data migration

Solutions with expansion:

  • Increase size
  • No downtime
  • No migration
  • Seamless

Real example: I once had storage full. Had to recreate. Downtime. Data migration. With expansion, just expand. No downtime. Never going back.

Volume expansion isn't optional. It's essential.

Enabling Volume Expansion​

Storage Class must support:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: expandable-storage
provisioner: ebs.csi.aws.com
parameters:
type: gp3
allowVolumeExpansion: true # Enable expansion

What this does:

  • Enables expansion
  • PVCs can be expanded
  • Online expansion

Think of it as: Enable expansion. Storage can grow. Flexible.

Expanding PVC​

Expand PVC:

# Edit PVC
kubectl edit pvc hotel-storage

# Change storage size
spec:
resources:
requests:
storage: 20Gi # Increased from 10Gi

Or patch:

kubectl patch pvc hotel-storage -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'

What happens:

  • PVC size updated
  • PV expanded
  • No downtime

Think of it as: Request more storage. Facility expands. No interruption.

Real-World Example: Complete Expansion​

Step 1: Check current size:

kubectl get pvc hotel-storage

Output:

NAME           STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
hotel-storage Bound pv-xxx 10Gi RWO standard 5d

Step 2: Expand:

kubectl patch pvc hotel-storage -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'

Step 3: Verify:

kubectl get pvc hotel-storage

Output:

NAME           STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
hotel-storage Bound pv-xxx 20Gi RWO standard 5d

Step 4: Check in pod:

kubectl exec app -- df -h /data
# Shows expanded size

That's complete expansion. No downtime. Seamless.

Expansion Limitations​

Not all storage supports:

  • Check Storage Class
  • Check provisioner
  • Some don't support

File system expansion:

  • May need to expand filesystem
  • Depends on filesystem
  • May require pod restart

Think of it as: Not all storage can expand. Check support. May need filesystem expansion.

My Take: Volume Expansion Strategy​

Here's what I do:

Always:

  • Enable expansion in Storage Class
  • Monitor storage usage
  • Expand before full
  • Test expansion

Production:

  • Enable expansion
  • Monitor closely
  • Expand proactively
  • Document process

The key: Enable expansion. Monitor. Expand proactively. Test.

Memory Tip: The Storage Expansion Analogy​

Volume expansion = Storage expansion

Storage full: Need more Expand storage: Increase size Online expansion: No downtime

Once you see it this way, volume expansion makes perfect sense.

Common Mistakes​

  1. Not enabling expansion: Can't expand
  2. Expanding too late: Storage full
  3. Not monitoring: Don't know when needed
  4. Not testing: Don't know if works
  5. Wrong Storage Class: Doesn't support

Key Takeaways​

  1. Enable expansion in Storage Class - allowVolumeExpansion: true
  2. Expand PVC - Edit or patch
  3. No downtime - Online expansion
  4. Monitor storage - Expand proactively
  5. Test expansion - Know it works

What's Next?​

Now that you understand volume expansion, you've completed the Persistent Volumes & Storage module. Next: Understanding StatefulSets.


Remember: Volume expansion is like storage expansion. Enable expansion. Monitor usage. Expand proactively. No downtime. Essential for growing data.