cant delete pod using kubctl delete pod <pod>

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.


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

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)