[英]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.
我已经发现 Kubernetes 不提供这样的选项。 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
).我还尝试将卷从快照克隆或还原到新的较小卷 - 结果相同(
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.集群使用 Rancher 部署,卷挂载到 Ceph 集群。 Everything is provided by an external hoster.
一切都由外部主机提供。
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.我不熟悉 Ceph 支持的卷,但如果您能够在 Ceph 中创建新卷,请直接在 Ceph 中从较大的卷复制到新卷,然后手动创建 PV,但配置为使用较小的卷(所以它创建 PV 时不配置 Ceph 存储),这可能是最简单的选择。
Finally I achieved what needed with the following steps (still tricky and manual work):最后,我通过以下步骤实现了所需(仍然很棘手和手动工作):
job-template.yaml
set the source and destination volumejob-template.yaml
的规范中。yaml 设置源卷和目标卷
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.