Kubernetes Pods stuck with in 'Terminating' state

为君一笑 提交于 2020-01-16 08:12:25

问题


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.

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

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

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

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

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).

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

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


回答1:


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


来源:https://stackoverflow.com/questions/55935173/kubernetes-pods-stuck-with-in-terminating-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!