How to remove a pod and delete everything related to it

Asked

Viewed 358 times

0

I have some pods, and I noticed that I just erase the pod in itself not yet liberated necessary computational resources, because I have a cluster with little resource.

Using the command:

kubectl delete pod xxxxx

It’s removed, but it still has the service, so I delete it too:

kubectl delete svc xxxxx

My question is, what else can I erase related to this pod servant?

2 answers

1

Features that may be associated with the pod:

  • service Accounts: kubectl get sa xxxx
  • Deployments: kubectl get Deployment xxxx

If you created these pods using Deployment, also check for replica sets:

  • replica sets: kubectl get rs xxxx

-1

There are several ways to create resources within Kubernetes, depending on the form used it can be simpler or complicated to delete the dependencies created.

If you created each item manually, they would have a very low correlation and Kubernetes has dozens of possible features, some criteria can be raised as a name but to avoid improper deletions it would be good to delete in the created order.

To avoid these setbacks in the future, follow some suggestions:

  1. Use yaml manifests to control all created resources, from which it will be possible to delete from a command:
kubectl delete -f template.yml
  1. Use namespaces because in this scenario it will be easier to delete everything inside the same namespace:
kubectl delete all --all -n NOME_DO_NAMESPACE

Browser other questions tagged

You are not signed in. Login or sign up in order to post.