<p>I have the following pods:</p>

<pre><code>NAME                                                 READY     STATUS        RESTARTS   AGE
xxx-myactivities-79f49cdfb4-nwg22                      1/1       Terminating   0          10h
xxx-mysearch-55864b5c59-6bnwl                          1/1       Terminating   0          1d
xxx-mysearch-55864b5c59-rpn48                          1/1       Terminating   0          13h
xxx-mysearch-6ff9bbb7cb-9qgbb                          1/1       Terminating   0          3d
</code></pre>

<p>I am running the following code to forcefully delete those pods:</p>

<pre><code>#
# Clean up dying pods
#
pods=$( kubectl get pods | grep -v Running | tail -n +2 | awk -F " " '{print $1}' )
for pod in $pods;
do
    kubectl delete pod $pod --force
done
</code></pre>

<p>Here is the output:</p>

<pre><code>pod "xxx-myactivities-79f49cdfb4-nwg22" deleted
pod "xxx-mysearch-55864b5c59-6bnwl" deleted
pod "xxx-mysearch-55864b5c59-rpn48" deleted
pod "xxx-mysearch-6ff9bbb7cb-9qgbb" deleted
</code></pre>

<p>After cleaning up, those pods still hang around.</p>

<pre><code>NAME                                                 READY     STATUS        RESTARTS   AGE
xxx-myactivities-79f49cdfb4-nwg22                      1/1       Terminating   0          10h
xxx-mysearch-55864b5c59-6bnwl                          1/1       Terminating   0          1d
xxx-mysearch-55864b5c59-rpn48                          1/1       Terminating   0          13h
xxx-mysearch-6ff9bbb7cb-9qgbb                          1/1       Terminating   0          3d
</code></pre>

<p>How do I clean up those pods?</p>

user9524761
<blockquote>
  <p>To clean the pods you need to delete their <strong>deployments namespace</strong>.</p>
</blockquote>

<p>First discover that deployments existed:</p>

<pre><code>$ kubectl get deployments --all-namespaces
NAME                               READY     STATUS        RESTARTS   AGE
chetabahana-web-584b95d576-62ccj   1/1       Running       0          20m
tutorial-web-56fbccc56b-wbwjq      1/1       Running       0          1m
</code></pre>

<p>Delete the deployment <code>&lt;NAME&gt;-xxxx</code> like this:</p>

<pre><code>$ kubectl delete deployment &lt;NAME&gt;
</code></pre>

<p>For example to delete <code>tutorial-web-56fbccc56b-wbwjq</code> run:</p>

<pre><code>$ kubectl delete deployment tutorial
</code></pre>

<p>Then all corresponded pods of <code>tutorial-xxxx</code> will terminate by itself.</p>

<pre><code>NAME                               READY     STATUS        RESTARTS   AGE
chetabahana-web-584b95d576-62ccj   1/1       Running       0          20m
tutorial-web-56fbccc56b-wbwjq      0/1       Terminating   0          1m
</code></pre>
