删除时会重新创建Kubernetes Pod [英] Kubernetes pod gets recreated when deleted

查看:80
本文介绍了删除时会重新创建Kubernetes Pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用命令启动了pods

I have started pods with command

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

出了点问题,现在我无法删除此Pod.

Something went wrong, and now I can't delete this Pod.

我尝试使用下面介绍的方法,但是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

推荐答案

您需要删除部署,这又应删除pod和副本集

You need to delete the deployment, which should in turn delete the pods and the replica sets https://github.com/kubernetes/kubernetes/issues/24137

要列出所有部署,请执行以下操作:

To list all deployments:

kubectl get deployments --all-namespaces

然后删除部署:

kubectl delete -n NAMESPACE deployment DEPLOYMENT

NAMESPACE是其中的名称空间,而DEPLOYMENT是部署的name.

Where NAMESPACE is the namespace it's in, and DEPLOYMENT is the name of the deployment.

在某些情况下,由于作业或守护程序集,它也可能正在运行. 检查以下内容,然后运行其相应的删除命令.

In some cases it could also be running due to a job or daemonset. Check the following and run their appropriate delete command.

kubectl get jobs

kubectl get daemonsets.app --all-namespaces

kubectl get daemonsets.extensions --all-namespaces

这篇关于删除时会重新创建Kubernetes Pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆