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

<p>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.</p>

<pre><code>kubectl apply -f mydeployment.yaml -f myservice.yaml
...
kubectl delete -f mydeployment.yaml -f myservice.yaml
</code></pre>

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

<pre><code>kubectl kdelete pod mypod-ba97bc8ef-8rgaa --now
</code></pre>

<p>There is a <a href="https://github.com/kubernetes/kubernetes/issues/51835" rel="nofollow noreferrer">GitHub issue</a> that suggest outputting the logs to see the error, but no logs are available (note that "mycontainer" is the only container in "mypod" -</p>

<pre><code>kubectl logs mypod-ba97bc8ef-8rgaa
</code></pre>

<blockquote>
  <p>Error from server (BadRequest): container "mycontainer" in pod "mypod-ba97bc8ef-8rgaa" is terminated</p>
</blockquote>

<p>The aforementioned <a href="https://github.com/kubernetes/kubernetes/issues/51835" rel="nofollow noreferrer">GitHub issue</a> 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).</p>

<p>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 <code>Started</code> and <code>Finished</code> times below are exactly as they are in the output to the describe command.</p>

<pre><code>kubectl describe pod mypod-ba97bc8ef-8rgaa
</code></pre>

<p>></p>

<pre><code>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
</code></pre>

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

David Gard
<p>After searching Google for a while I came up blank, but a suggested <a href="https://stackoverflow.com/questions/51559111/ghost-kubernetes-pod-stuck-in-terminating">Stack Overflow question</a> which appeared when I added my title saved the day.</p>

<pre><code>kubectl delete pods mypod-ba97bc8ef-8rgaa --grace-period=0 --force
</code></pre>
