我已经用命令启动了豆荚

$ 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 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 get sts --all-namespaces

删除命名空间中的所有有状态集

kubectl --namespace <yournamespace> delete sts --all

一个一个地删除它们

kubectl --namespace ag1 delete sts mssql1 
kubectl --namespace ag1 delete sts mssql2
kubectl --namespace ag1 delete sts mssql3

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

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

and

Kubectl删除作业<job-name>

你可以尝试删除replicaSet,而不是删除NS

kubectl get rs --all-namespaces

然后删除replicaSet

kubectl delete rs your_app_name

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

kubectl delete deployments DEPLOYMENT_NAME

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

kubectl get rs

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

kubectl edit rs REPICASET_NAME

这将提供关于所有pod、部署、服务和作业的信息 在命名空间中。

kubectl get pods,services,deployments,jobs

pod既可以由部署创建,也可以由作业创建

kubectl delete job [job_name]
kubectl delete deployment [deployment_name]

如果您删除了部署或作业,那么可以停止重新启动pods。