Resizing Persistent Volumes in Thalassa Cloud Kubernetes
If you need more storage for your application, you can easily increase the size of your persistent volumes in Thalassa Cloud Kubernetes. This can be done without downtime, and your app can keep running while the resize happens.
How Volume Resizing Works
To resize a persistent volume, just edit the PersistentVolumeClaim (PVC) and change the storage size to a higher value. Kubernetes and Thalassa Cloud’s storage will handle the rest—expanding the volume and the filesystem as needed.
Thalassa Cloud’s block storage allows volume expansion while the volume is still in use. In most cases, no downtime is needed, but sometimes you might need to restart your pods or expand the filesystem from inside your app.
Prerequisites
Before resizing a volume, ensure a few things are in place. First, verify that your storage class supports volume expansion. Thalassa Cloud’s default storage class (tc-block) supports expansion, but if you’re using a custom storage class, verify its configuration.
Check your storage class:
kubectl get storageclass tc-block -o yamlLook for allowVolumeExpansion: true in the storage class definition. If this is set to false or missing, volume expansion isn’t enabled for that storage class. Make sure you have permission to edit PVCs in the correct namespace. It’s usually best to resize a volume while the pod using it is running, as the filesystem for most CSI plugins supports live expansion (as is the case for Thalassa CSI).
Resizing the volume
Checking Current Volume Size
Before resizing, check the current size of your persistent volume. This helps you determine how much to increase the size and verify that the resize operation was successful.
List PVCs to see their current sizes:
kubectl get pvcThis shows all PVCs with their requested sizes, actual sizes, and status. The output includes columns for requested storage and the actual capacity.
Get detailed information about a specific PVC:
kubectl get pvc my-volume -o yamlThis shows the full PVC definition, including the current storage request and the actual volume capacity. Look for the status.capacity.storage field to see the actual size.
You can also check the size from within a pod that’s using the volume:
kubectl exec -it <pod-name> -- df -h /path/to/mountThis shows the filesystem size and usage from inside the pod, which helps you understand how much space is available and how much is being used.
Resizing a Persistent Volume
To resize a persistent volume, you need to edit the PVC to request a larger size. The process is straightforward, but there are a few considerations to keep in mind.
First, identify the PVC you want to resize. Get its current configuration:
kubectl get pvc my-volume -o yaml > pvc-backup.yamlThis creates a backup of the current PVC configuration, which is useful if you need to reference the original settings.
Edit the PVC to increase the storage request. You can do this by editing the PVC directly:
kubectl edit pvc my-volumeIn the editor, find the spec.resources.requests.storage field and increase the value. For example, to increase from 10Gi to 20Gi:
spec:
resources:
requests:
storage: 20GiSave and close the editor. Kubernetes will immediately start the resize process.
Alternatively, you can use a patch command:
kubectl patch pvc my-volume -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'This updates the PVC without opening an editor, which is useful for automation or when you know exactly what size you want.
Monitoring the Resize Process
After updating the PVC, monitor the resize process to ensure it completes successfully. The resize happens in stages, and you can track progress through the PVC status.
Check the PVC status:
kubectl get pvc my-volumeThe status shows whether the resize is in progress or complete. Look for conditions that indicate the resize status:
kubectl describe pvc my-volumeThe describe output shows detailed information about the PVC, including any conditions related to resizing. You might see conditions like Resizing or FileSystemResizePending that indicate the current stage of the resize operation.
Watch the PVC to see status changes in real-time:
kubectl get pvc my-volume -wThis watches the PVC and shows updates as they occur, making it easy to see when the resize completes.
Expanding the Filesystem
After resizing the volume, the filesystem often expands automatically. If it doesn’t expand on its own, try restarting the pods or run a manual filesystem expansion command.
For ext4 or xfs filesystems, you can expand the filesystem from within a pod:
kubectl exec -it <pod-name> -- resize2fs /dev/<device>Or for xfs:
kubectl exec -it <pod-name> -- xfs_growfs /path/to/mountThe exact command depends on your filesystem type and how the volume is presented to the pod.
Verifying the Resize
After the resize completes, verify that the volume has been resized successfully. Check the PVC status to confirm the new size:
kubectl get pvc my-volumeThe output should show the new size in the capacity column. Compare this with the requested size to ensure they match.
Check the actual filesystem size from within a pod:
kubectl exec -it <pod-name> -- df -h /path/to/mountThis shows the filesystem size and confirms that the filesystem has been expanded to use the new volume capacity.
You can also check the underlying PersistentVolume:
kubectl get pv
kubectl describe pv <volume-name>The PersistentVolume should show the updated capacity, confirming that the resize was applied at the storage level.
Considerations and Limitations
While volume resizing is generally straightforward, there are some considerations and limitations to keep in mind.
Volume Size Limitations
You can only increase volume size, not decrease it. Kubernetes and most storage providers don’t support shrinking volumes. If you need to reduce storage, you’ll need to create a new smaller volume and migrate data.
- The new size must be larger than the current size. If you try to set a smaller size, the resize will be rejected. Ensure you’re increasing the size when editing the PVC.
- Some applications may need to be restarted to recognize the new volume size. While the volume resize happens online, applications that cache volume information or have specific storage requirements might need a restart.
- Filesystem expansion may require pod restarts. While Kubernetes can often expand filesystems automatically, some configurations require pods to be restarted for the expansion to take effect.
- Consider application impact. While resizing is generally non-disruptive, very large resizes or resizes during high I/O periods might temporarily impact performance. Plan resizes during maintenance windows if possible.
Further Reading
For more information and deeper technical details, see:
- Kubernetes: Expanding Persistent Volumes
- Kubernetes Persistent Volumes
- Kubernetes Storage Classes
- Thalassa Cloud Persistent Volumes Documentation
- Thalassa Cloud Storage Classes Documentation
- Deploying Applications with Persistent Volumes in Thalassa Cloud
For more about Thalassa Cloud’s block storage technology, visit the Thalassa Cloud Storage documentation.