cant delete pod using kubctl delete pod <pod>

jack miao picture jack miao · Apr 4, 2017 · Viewed 9.5k times · Source

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

Answer

Pawan Kumar picture Pawan Kumar · Apr 4, 2017

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