kubernetes: Failure in creating service & deployment still creates deployment

While testing out kubectl run, I ran into a non-obvious behavior:

$ kubectl run hello-node --image=aronchick/hello-node:2.0 --port=8080 --expose=true
Error from server: services "hello-node" already exists
$ kubectl delete svc hello-node
service "hello-node" deleted
$ kubectl run hello-node --image=aronchick/hello-node:2.0 --port=8080 --expose=true
Error from server: deployments.extensions "hello-node" already exists

It appears that the first deployment was actually created, though I wasn’t given any indication and, when the service deployment failed, it wasn’t rolled back. Either would be acceptable.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (16 by maintainers)

Commits related to this issue

Most upvoted comments

You should use the following command to delete hello-node: kubectl delete deployment hello-node It is described here: https://github.com/kubernetes/kubernetes/issues/23406

@shahidhk I don’t think we should automatically delete the deployment if creating the service fails. We should update the error message when creating a service fails (as part of run) to say the deployment was created, but the service creation failed.

I am running into this problem too. I am running qinikube and running couple of deployments. Now I can’t do kubectl delete deployment to remove them. I have tried stopping and starting minikube and the pods come back again (they are persistent). I have tried rebooting and still persistent.

Is there a way to clean up all the deployments and start fresh ?

Hi @nagarjung - did the steps in the initial bug not repro for you?