Kubernetes Pods stuck with in 'Terminating' state


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


    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?

-- David Gard

1 Answer


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
-- David Gard
Source: StackOverflow