问题描述
当我尝试删除在AWS中运行的kubernetes集群时,它删除了所有相关资源,例如应用程序的负载均衡器,自动伸缩组,EC2实例及其EBS卷.但是,它也删除了用作永久卷的EBS卷.幸运的是,我有一个快照可以用来创建一个EBS卷.当我想在不影响用于数据库的EBS卷的情况下删除群集时,如何在将来避免这种情况?
When I tried to delete a kubernetes cluster running in AWS, it removed all the associated resources like loadbalancers of my application, autoscaling groups, EC2 instances and its EBS volumes as expected. However, it also removed EBS volume that I used as a persistent volume. Luckily, I had a snapshot to create an EBS volume out of it. How to avoid this in future when I want to delete my cluster without disturbing EBS volume that I used for my database?
我按照以下步骤删除了我的集群.
I followed the steps below for deleting my cluster.
-
Kubectl delete -f my-applicaton.yml
(终止包括数据库pod在内的所有服务和部署) - 将持久性卷的回收策略从
DELETE
更改为RETAIN
-
kubectl delete pvc db-pvc
(已删除的永久批量声明) -
kubectl delete pv db-pv
(已删除的永久卷) -
kops delete cluster --name ${NAME} --yes
Kubectl delete -f my-applicaton.yml
(to terminate all the services&deployments including database pod)- Changed reclaim policy of persistent volume from
DELETE
toRETAIN
kubectl delete pvc db-pvc
(deleted persistent volume claim)kubectl delete pv db-pv
(deleted persistent volume)kops delete cluster --name ${NAME} --yes
推荐答案
要防止kOps删除EBS(弹性块存储)卷,您需要删除EBS卷上的所有标签.然后,您可以将其添加到新集群中的PV中以重新使用它:
To prevent kOps from deleting the EBS(Elastic Block Store) volume you need to remove all the tags on the EBS volume. Then you can add this to your PV in your new cluster in order to reuse it:
awsElasticBlockStore:
volumeID: <vol-123>
fsType: ext4
这篇关于如何使用kops删除kubernetes集群而不删除我用于数据库的EBS持久卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!