cant delete pod using kubctl delete pod <pod>

4/4/2017

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

-- jack miao
deployment
google-cloud-endpoints
kubernetes
kubernetes-health-check

4 Answers

4/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
-- Pawan Kumar
Source: StackOverflow

1/31/2019

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)
-- Prashanth Sams
Source: StackOverflow

5/12/2017

1).Note that every pod is generated based on its deployment file. Hence, every time you delete a pod, it comes up again because you defined the value 'replicas: 1' in the deployment file. And in such a case using the command 'kubectl delete pods --grace-period=0', too will not work since the pod will be again generated based on the deployment file.

2). The reason why you get the error you mentioned in the question is because the deployment still exists, all you did was setting 'replicas: 0' which made the no. of pods that should come up or run on the cluster, equal to zero.

3).To delete a Pod/s permanently, You will have to first delete the deployment file of that pod and then delete the pod(optional). This will delete the pod permanently. And of course, the deployment itself will be deleted permanently. The command to do that is :- kubectl delete -f deployment_file_name.yml And sure you can alternatively, delete the deployment file from Kubernetes's UI as well.

-- Suhas Chikkanna
Source: StackOverflow

9/27/2018
kubectl delete --grace-period=0  --force --namespace=system pod mysql-84fbb8bfc6-lhlnh
-- jamlee
Source: StackOverflow