我已经用命令启动了豆荚

$ kubectl run busybox \
--image=busybox \
--restart=Never \
--tty \
-i \
--generator=run-pod/v1

出了点问题,现在我没法删除这个Pod了。

我尝试使用下面描述的方法,但Pod不断被重新创建。

$ 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

当前回答

这已经发生在我与一些破碎的“头盔”安装。你的部署可能有点混乱。如果前面的建议都不起作用,那么寻找一个守护进程并删除它。

如 Kubectl get daemonset——namespace

然后删除daemonset

kubectl delete daemonset --namespace <NAMESPACE> --all --force

然后尝试删除豆荚。

kubectl delete pod --namespace  <NAMESPACE> --all --force

检查吊舱是否消失了。

kubectl get pods --all-namespaces

其他回答

在我的例子中,我使用下面这些

kubectl get all --all-namespaces 
kubectl delete deployment statefulset-deploymentnament(choose your deployment name)
kubectl delete sts -n default(choose your namespace) --all 
kubectl get pods --all-namespaces

问题得到了解决

我也遇到过这个问题,我已经用下面的命令删除部署了。

kubectl delete deployments DEPLOYMENT_NAME

但是仍然在重新创建豆荚,所以我使用下面的命令交叉检查副本集

kubectl get rs

然后将复制集编辑为1到0

kubectl edit rs REPICASET_NAME

如果存在继续运行的作业,则需要搜索并删除该作业:

Kubectl get job—所有命名空间| grep <name>

and

Kubectl删除作业<job-name>

我遇到了类似的问题:删除部署(kubectl delete deploy <name>)后,pod保持“Running”,删除后自动重新创建(kubectl delete po <name>)。

事实证明,由于某些原因,相关的副本集没有被自动删除,删除后(kubectl delete rs <name>),可以删除pods。

如果你的pod有一个像name-xxx-yyy这样的名字,它可以被一个replicasets控制。名为name-xxx的应用程序,在删除pod之前,你应该先删除该副本集:

kubectl delete replicasets.apps name-xxx