简体   繁体   English

如何使用 kops 删除 kubernetes 集群而不删除我用于数据库的 EBS 持久卷?

[英]How to delete a kubernetes cluster using kops without deleting EBS persistent volume that I used for my database?

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.当我尝试删除在 AWS 中运行的 kubernetes 集群时,它按预期删除了所有相关资源,例如我的应用程序的负载均衡器、自动扩展组、EC2 实例及其 EBS 卷。 However, it also removed EBS volume that I used as a persistent volume.但是,它也删除了我用作持久卷的 EBS 卷。 Luckily, I had a snapshot to create an EBS volume out of it.幸运的是,我有一个快照可以从中创建一个 EBS 卷。 How to avoid this in future when I want to delete my cluster without disturbing EBS volume that I used for my database?当我想在不影响用于数据库的 EBS 卷的情况下删除集群时,如何避免这种情况?

I followed the steps below for deleting my cluster.我按照以下步骤删除了我的集群。

  1. Kubectl delete -f my-applicaton.yml (to terminate all the services&deployments including database pod) Kubectl delete -f my-applicaton.yml (终止所有服务和部署,包括数据库 pod)
  2. Changed reclaim policy of persistent volume from DELETE to RETAIN将持久卷的回收策略从DELETE更改为RETAIN
  3. kubectl delete pvc db-pvc (deleted persistent volume claim) kubectl delete pvc db-pvc (已删除持久卷声明)
  4. kubectl delete pv db-pv (deleted persistent volume) kubectl delete pv db-pv (删除的持久卷)
  5. kops delete cluster --name ${NAME} --yes

To prevent kOps from deleting the EBS(Elastic Block Store) volume you need to remove all the tags on the EBS volume.要防止 kOps 删除 EBS(弹性块存储)卷,您需要删除 EBS 卷上的所有标签。 Then you can add this to your PV in your new cluster in order to reuse it:然后,您可以将其添加到新集群中的 PV 以重用它:

awsElasticBlockStore:
  volumeID: <vol-123>
  fsType: ext4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Kubernetes持续卷声明与Amazon EBS的难度 - Difficulty using Kubernetes Persistent Volume Claims with Amazon EBS 如何使用 KOPS 恢复 Kubernetes 集群? - How to recover Kubernetes cluster with KOPS? 如何将 EFS 卷挂载到在 AWS ubuntu18 实例上运行的 kubernetes 集群作为持久卷? - How can I mount an EFS volume to a kubernetes cluster running on AWS ubuntu18 instances as Persistent Volume? 如何使用 kops 为 Kubernetes 集群启用匿名身份验证? - How to enable anonymous authentication for Kubernetes cluster using kops? 无法使用 Kops 验证 Kube.netes 集群 - Unable to validate Kubernetes cluster using Kops 问题:使用 Kops 在 AWS 上创建 kubernetes 集群 - Problem : creating a kubernetes cluster on AWS using Kops 如何使用AWS Data Pipeline将EBS卷附加到EMR集群? - How can I attach an EBS Volume to an EMR Cluster using the AWS Data Pipeline? Kubernetes / kops:将EBS卷附加到实例时出错。 您无权执行此操作。 错误403 - Kubernetes/kops: error attaching EBS volume to instance. You are not authorized to perform this operation. Error 403 无法删除在 AWS 上使用 Kops 部署的 Kubernetes 集群 - Can't delete Kubernetes cluster deployed with Kops at AWS 使用kops时如何指定群集CIDR? - How can I specify a cluster CIDR when using kops?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM