1. Home
  2. Knowledge Base
  3. Persistent Volume Expansion in Kubernetes (CloudPE)-Kubernetes

Persistent Volume Expansion in Kubernetes (CloudPE)-Kubernetes


1. Executive Summary

Kubernetes supports in-place volume expansion, allowing you to increase the size of an existing Persistent Volume without data loss.

  • The block storage is expanded at the infrastructure layer (CloudPE).
  • The filesystem is then resized to utilize the new capacity.
  • βœ… Existing data remains intact β€” no deletion, movement, or modification occurs.

2. Prerequisites

Before starting the expansion process, ensure the following:

πŸ”§ Storage Configuration

The StorageClass must have:

allowVolumeExpansion: true

πŸ“ˆ Expansion Direction

  • Only volume expansion is supported
    • Example: 5Gi β†’ 10Gi βœ…
    • Shrinking volumes ❌ (not supported and will fail validation)

πŸš€ Driver Status

  • Ensure the CSI driver is running:
kubectl get pods -n kube-system | grep cinder
  • All cinder.csi.openstack.org pods should be in Running state

3. Expansion Procedure (Declarative Method)

This method follows Infrastructure as Code (IaC) best practices using YAML manifests.


πŸ”Ή Phase A: Update the PVC Request

  1. Open your PersistentVolumeClaim file (e.g., pvc.yaml)
  2. Update the storage size:
spec:
resources:
requests:
storage: 10Gi # Updated from 5Gi
  1. Apply the changes:
kubectl apply -f pvc.yaml

πŸ”Ή Phase B: Resize the Filesystem

After expanding the volume, the filesystem must be resized.

⚠️ In this environment (ext4/xfs), this requires a pod restart

If using a Deployment:

kubectl rollout restart deployment <deployment-name>

If using a Standalone Pod:

kubectl apply -f pod.yml

Kubernetes will:

  • Re-attach the expanded volume
  • Automatically grow the filesystem during mount

4. Post-Expansion Validation

Verify that the expansion was successful:

βœ… Check PVC Status

kubectl get pvc <pvc-name>
  • Status should be Bound
  • New size should be reflected

βœ… Verify Inside the Pod

kubectl exec <pod-name> -- df -h /data
  • Confirm the updated storage size in the Size column

5. Safety & Recovery

πŸ”’ Data Integrity

  • Expansion occurs at the end of the partition
  • Existing data remains untouched and safe

⚠️ Failure Handling

  • If expansion fails (e.g., insufficient quota):
    • PVC status will remain: Expanding
    • Pod continues operating with the original size
  • Once the issue is resolved, expansion resumes automatically

πŸ•’ Best Practice

  • Perform volume expansion during low-traffic periods
  • This minimizes impact from required pod restarts

βœ… Summary

  • Safe, in-place volume expansion is supported
  • Requires:
    • StorageClass configuration
    • YAML update
    • Pod restart
  • Always validate after expansion

Was this article helpful?
This is a staging environment