'Shrink Kubernetes persistent volumes
I do have multiple persistent volumes which need to be shrinked to reduce the hosting costs. I already figured out that Kubernetes does not provide such an option. I also tried to clone or the restore the volumes from an snapshot to a new smaller volume - with the same result (requested volume size XXX is less than the size XXX for the source snapshot).
Nevertheless I need a solution or workaround to get this done.
The cluster is deployed with Rancher and the volumes are mounted to a Ceph Cluster. Everything is provided by an external hoster.
Solution 1:[1]
It is a bit tricky, but I would try to create the volumes manually with the proper size, fill them with the data from the bigger volumes and then redeploy having the application attach to the new volumes.
I know that the answer is pretty generic but how to do it will depend on what capabilities and access to the underlying infrastructure you have.
I'm not familiar with Ceph backed volumes but if you are able to create the new ones in Ceph, copy from the bigger volumes to the new ones directly within Ceph and then create the PV manually but configured to use the smaller volumes (so it does not provision the Ceph storage when creating the PV) that would probably be the easiest option.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gerard Garcia |
