Jonathan
Jonathan

Reputation: 1936

Busybox - How to delete looping creations of busybox containers

I created a namespace inside Kubernetes and tried to create a container using the following command:

kubectl run busybox -it ----image=busybox -- sh

But now, everytime I delete the pod using kubectl delete pods --all, it deletes the pod that was just created and it automatically recreates a new pod. I looked through the documentation but am unable to figure out what flag will stop this incessant creation of these containers.

Upvotes: 1

Views: 1465

Answers (1)

Grant David Bachman
Grant David Bachman

Reputation: 2248

The reason it does this is because kubectl run implicitly creates a deployment for the pod. Deployments are tasked with ensuring a certain number of pods are always running, so when Kubernetes detects a misalignment in the number of pods the deployment should be running vs the number that are actually running, it'll spin up a new one. You can remedy this by deleting the deployment: kubectl delete deployment busybox

Alternatively, you can temporarily kill the pods (but keep the deployment) by scaling down the deployment to run 0 pods: kubectl scale deployment busybox --replicas=0.

Documentation: https://kubernetes-v1-4.github.io/docs/user-guide/kubectl/kubectl_run/

Create and run a particular image, possibly replicated. Creates a deployment or job to manage the created container(s).

Upvotes: 3

Related Questions