4

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 (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
  • What do you expect to be able to do with the ESB volume after the cluster is gone? – Ole Markus With Jan 21 '21 at 11:18
  • When I create my cluster again after few days or weeks to deploy my application (experimental purpose), I would use this volume again for my database pod by asigning its `volumeID` under `spec:` of `PersistentVolume` in kubernetes manifest. – HarishVijayamohan Jan 21 '21 at 11:41

1 Answers1

3

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
Ole Markus With
  • 1,017
  • 1
  • 8
  • 10
  • 1
    I executed the commands till step-4 as I mentioned in my question. And then I removed all tags from EBS volume as you suggested. And then I did `kops delete cluster ${NAME} --yes`. As a result, the cluster got successfully deleted, leaving behind the EBS volume. It worked perfectly as I wished. Thank you very much. :-) – HarishVijayamohan Jan 21 '21 at 15:27
  • I was able to remove the tags in AWS UI and delete the cluster as shown in [this video](https://www.youtube.com/watch?v=tQxkcmfRMp0). But it would be nice if there is way to remove the tags of EBS volume using any cli. Please write here, if anyone knows how to do it using any CLI. Thanks. – HarishVijayamohan Jan 25 '21 at 14:01