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
(to terminate all the services&deployments including database pod)DELETE
to RETAIN
kubectl delete pvc db-pvc
(deleted persistent volume claim)kubectl delete pv db-pv
(deleted persistent volume)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. Then you can add this to your PV in your new cluster in order to reuse it:
awsElasticBlockStore:
volumeID: <vol-123>
fsType: ext4