Can Trident with Kubernetes or Openshift reduce the size of a deployed, persistent volume (PV) ?
Applies to
- Trident for Kubernetes/Openshift 19.07 and higher
- Kubernetes (K8s) 1.16 and higher
- Openshift 4.5 and higher
Answer
The option allowVolumeExpansion was added for storage classes in Kubernetes 1.16 and equivalent Openshift version 4.5, and is supported by Trident 19.07 and higher to easily increase the size of the persistent volume after its deployment.
However, a reduction/decrease in volume size has currently not been implemented, and the size parameter is checked against current size to make sure you are only increasing the size compared to the existing volume size. See also the second point under iSCSI expansion.A possible usage, apart from creating a replacement PV and migrating the data, would be to reduce usage of space from the aggregate on ONTAP storage, by generally not using space reservations and leave it on thin provisioning. This can be checked on the backend definition or the storage class, and is the default.
Additional Information
Although it seems reasonable when free space in the volume is plenty, that a volume should be able to decrease in size as well, for iSCSI PV's this is not possible, since the data location on the virtual disk can be at the end of the virtualized file, meaning that reducing the size could loose data.
For NFS volumes, this could theoretically be implemented, but would require a similar setting from Kubernetes itself (e.g. allowVolumeReduction).