I have started pods with command
$ kubectl run busybox --image=busybox --restart=Never --tty -i --generator=run-pod/v1
Something went wrong, and now I can't delete this Pod
.
I tried using the methods described below but the Pod
keeps being recreated.
$ kubectl delete pods busybox-na3tm
pod "busybox-na3tm" deleted
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox-vlzh3 0/1 ContainerCreating 0 14s
$ kubectl delete pod busybox-vlzh3 --grace-period=0
$ kubectl delete pods --all
pod "busybox-131cq" deleted
pod "busybox-136x9" deleted
pod "busybox-13f8a" deleted
pod "busybox-13svg" deleted
pod "busybox-1465m" deleted
pod "busybox-14uz1" deleted
pod "busybox-15raj" deleted
pod "busybox-160to" deleted
pod "busybox-16191" deleted
$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default busybox-c9rnx 0/1 RunContainerError 0 23s
if your pod has name like
name-xxx-yyy
, it could be controlled by a replicasets.apps namedname-xxx
, you should delete that replicaset first before deleting the podkubectl delete replicasets.apps name-xxx
This will provide information about all the pods,deployments, services and jobs in the namespace.
pods can either be created by deployments or jobs
If you delete the deployment or job then restart of the pods can be stopped.
You can do
kubectl get replicasets
check for old deployment based on age or timeDelete old deployment based on time if you want to delete same current running pod of application
I also faced the issue, I have used below command to delete deployment.
but still pods was recreating, So I crossed check the Replica Set by using below command
then edit the replicaset to 1 to 0
In my case I deployed via a YAML file like
kubectl apply -f deployment.yaml
and the solution appears to be to delete viakubectl delete -f deployment.yaml
Instead of removing NS you can try removing replicaSet
Then delete the replicaSet