Kubernetes Pod处于“终止"状态 [英] Kubernetes Pods stuck with in 'Terminating' state

查看:710
本文介绍了Kubernetes Pod处于“终止"状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kubernetes Pod的状态为Terminating.目前他们已经处于这种状态约3个小时.

Kubernetes Pods are stuck with a STATUS of Terminating after the Deployment (and Service) related to the Pods were deleted. Currently they have been in this state for around 3 hours.

Deployment and Service是从文件创建的,然后有时通过引用相同的文件将其删除.在此期间,文件没有任何更改.

The Deployment and Service were created from files, and then sometime later deleted by referencing the same files. The files were not changed in any way during this time.

kubectl apply -f mydeployment.yaml -f myservice.yaml
...
kubectl delete -f mydeployment.yaml -f myservice.yaml

尝试手动删除任何Pod都会导致终端挂起,直到按 Ctrl + c 为止.

Attempting to manually delete any of the Pods results in my terminal hanging until I press Ctrl+c.

kubectl kdelete pod mypod-ba97bc8ef-8rgaa --now

GitHub问题,建议输出日志以查看错误,但没有可用的日志(请注意,"mycontainer"是"mypod"中唯一的容器-

There is a GitHub issue that suggest outputting the logs to see the error, but no logs are available (note that "mycontainer" is the only container in "mypod" -

kubectl logs mypod-ba97bc8ef-8rgaa

来自服务器的错误(BadRequest):容器"mypod-ba97bc8ef-8rgaa"中的容器"mycontainer"已终止

Error from server (BadRequest): container "mycontainer" in pod "mypod-ba97bc8ef-8rgaa" is terminated

前面提到的 GitHub问题建议将卷清理作为问题. "mycontainer"具有两个卷,但是在创建和删除部署之间无论如何都没有更改(用于存储Azure存储帐户名称和访问密钥的Secret [generic]也没有更改).

The aforementioned GitHub issue suggests that volume cleanup my be the issue. There are two volumes attached to the "mycontainer", but neither changed in anyway between creation and deletion of the Deployment (and neither did the Secret [generic] used to store the Azure Storage Account name and access key).

尽管没有可用于Pod的日志,但是可以对其进行描述.但是,那里似乎没有太多有用的信息.请注意,下面的StartedFinished时间与describe命令的输出中的时间完全相同.

Although there are no logs available for the Pods, it is possible to describe them. However, there doesn't seem to be much useful information in there. Note that the Started and Finished times below are exactly as they are in the output to the describe command.

kubectl describe pod mypod-ba97bc8ef-8rgaa

>

Containers:
  mycontainer:
    ...
    State:          Terminated
      Exit Code:    0
      Started:      Mon, 01 Jan 0001 00:00:00 +0000
      Finished:     Mon, 01 Jan 0001 00:00:00 +0000

我如何发现导致Pod卡住的原因,以便最终摆脱它们?

How can I discover what is causing the Pods to become stuck so that I can finally get rid of them?

推荐答案

在搜索了一段时间之后,我空白了,但是建议使用

After searching Google for a while I came up blank, but a suggested Stack Overflow question which appeared when I added my title saved the day.

kubectl delete pods mypod-ba97bc8ef-8rgaa --grace-period=0 --force

这篇关于Kubernetes Pod处于“终止"状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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