本文介绍了如何使用kops删除kubernetes集群而不删除我用于数据库的EBS持久卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试删除在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.

  1. Kubectl delete -f my-applicaton.yml(终止包括数据库pod在内的所有服务和部署)
  2. 将持久性卷的回收策略从DELETE更改为RETAIN
  3. kubectl delete pvc db-pvc(已删除的永久批量声明)
  4. kubectl delete pv db-pv(已删除的永久卷)
  5. kops delete cluster --name ${NAME} --yes
  1. Kubectl delete -f my-applicaton.yml (to terminate all the services&deployments including database pod)
  2. Changed reclaim policy of persistent volume from DELETE to RETAIN
  3. kubectl delete pvc db-pvc (deleted persistent volume claim)
  4. kubectl delete pv db-pv (deleted persistent volume)
  5. 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持久卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 13:17