Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cant delete pod using kubctl delete pod <pod>

I want to delete a pod permanently so I can create the deployment.yaml and derveice.yaml again from fresh, so I tried:

 kubctl delete pod <pod>

and the pod is still there, also tried:

kubectl delete pods <pod> --grace-period=0

and didnt work.

the only thing that worked is when I set the deployment replicas: 0 and then apply it, but the when i try to create new deployment i get:

Error from server: error when creating "myService/deployment.yaml": deployments.extensions "myService" already exists

like image 960
jack miao Avatar asked Apr 04 '17 19:04

jack miao


2 Answers

Pods are created by Deployment, so when you delete a Pod then Deployment automatically create it base on replicas value, you have to delete Deployment and then create it again,

You can use:

kubectl create -f deployment.yml
kubectl delete -f deployment.yml
like image 53
Pawan Kumar Avatar answered Sep 30 '22 04:09

Pawan Kumar


Deleting Deployment specific to the pods will terminate the pods automatically

kubectl get deployments

kubectl delete deployment deployment_name_to_delete --namespace=default  
(e.g., kubectl delete deployment ngnix --namespace=default)
like image 34
Prashanth Sams Avatar answered Sep 30 '22 04:09

Prashanth Sams