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

查看:60
本文介绍了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 和副本集 https://github.com/kubernetes/kubernetes/issues/24137

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

要列出所有部署:

kubectl get deployments --all-namespaces

然后删除部署:

kubectl delete -n NAMESPACE deployment DEPLOYMENT

其中 NAMESPACE 是它所在的命名空间,而 DEPLOYMENT 是部署的名称.如果 NAMESPACE 是 default,则完全不要使用 -n 选项.

Where NAMESPACE is the namespace it's in, and DEPLOYMENT is the name of the deployment. If NAMESPACE is default, leave off the -n option altogether.

在某些情况下,它也可能由于作业或守护进程而运行.检查以下内容并运行相应的删除命令.

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天全站免登陆