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)- 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