<p>I am trying to delete/remove all the pods running in my environment. When I issue </p>

<blockquote>
  <p>docker ps</p>
</blockquote>

<p>I get the below output. This is a sample screenshot. As you can see that they are all K8s. I would like to delete all of the pods/remove them. </p>

<p><a href="https://i.stack.imgur.com/apVaT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/apVaT.png" alt="enter image description here"></a></p>

<p>I tried all the below approaches but they keep appearing again and again</p>

<pre><code>sudo kubectl delete --all pods --namespace=default/kube-public #returns "no resources found" for both default and kube-public namespaces
sudo kubectl delete --all pods --namespace=kube-system # shows "pod xxx deleted"
</code></pre>

<p><a href="https://i.stack.imgur.com/x6rht.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x6rht.png" alt="enter image description here"></a></p>

<pre><code>sudo kubectl get deployments # returns no resources found
</code></pre>

<p>Apart from the above, I also tried using <code>docker stop</code> and <code>docker rm</code> with the container ids but they either respawn. I want to clear all of them. I would like to start from the beginning</p>

<p>I have logged out and logged back in multiple times but still I see those items.</p>

<p>Can you help me to delete all the pods and I expect the output of "docker ps" to not have any kubernetes related items like shown above?</p>

<blockquote>
  <p><code>sudo kubectl get deployments # returns no resources found</code></p>
</blockquote>

<p><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="noreferrer"><code>Deployments</code></a> are not the only Controllers in Kubernetes which may manage your Pods. There are many: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="noreferrer"><code>StatefulSet</code></a>, <a href="https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/" rel="noreferrer"><code>ReplicaSet</code></a>, etc. (check the <a href="https://kubernetes.io/docs/concepts/workloads/controllers" rel="noreferrer">Controllers doc</a> for details)</p>

<p>In short, a Controller is responsible of ensuring all Pods it manages are running, and create them if necessary - when you delete all Pods, the associated Controller will realise they are missing and simply re-create them to ensure it matchs its specifications.</p>

<p>If you want to effectively delete all Pods, you should delete all the related Controllers (or update them to set their replica to 0), such as:</p>

<pre><code># do NOT run this in the kube-system namespace, it may corrupt your cluster
# You can also specify --namespace xxx to delete in a specific namespace
kubectl delete deployment --all # configures ReplicaSets, deleting Deployments should delete ReplicaSet as well as associated Pods
kubectl delete statefulset --all
kubectl delete daemonset --all 
kubectl delete job --all
kubectl delete cronjob --all 
kubectl delete replicationcontroller --all # their should not be any ReplicationController as Deployment should be used
# Then delete what you find
</code></pre>

<p>EDIT: as mentionned by <a href="https://stackoverflow.com/a/56868072/5465973">P Emkambaram</a> answer's you can also delete the entire namespace with <code>kubectl delete namespace mynamespace</code> (don't delete <code>kube-system</code> of course) but it may also delete other components in the namespace such as Services</p>

<hr>

<p>Important notes:</p>

<ul>
<li>You should also take care when deleting Pods or object in the <code>kube-system</code> namespace which are related to the internal plumbing of the cluster itself.</li>
<li>You should not delete directly Kubernetes components by deleting their underlying containers with <code>docker</code> commands, this may have unexpected effects, use <code>kubectl</code> instead. </li>
</ul>
