<p>When listing all the API resources in K8s you get:</p>

<pre><code>$ kubectl api-resources -owide
NAME                              SHORTNAMES   APIGROUP                       NAMESPACED   KIND                             VERBS
bindings                                                                      true         Binding                          [create]
componentstatuses                 cs                                          false        ComponentStatus                  [get list]
configmaps                        cm                                          true         ConfigMap                        [create delete deletecollection get list patch update watch]
endpoints                         ep                                          true         Endpoints                        [create delete deletecollection get list patch update watch]
events                            ev                                          true         Event                            [create delete deletecollection get list patch update watch]
limitranges                       limits                                      true         LimitRange                       [create delete deletecollection get list patch update watch]
namespaces                        ns                                          false        Namespace                        [create delete get list patch update watch]
nodes                             no                                          false        Node                             [create delete deletecollection get list patch update watch]
persistentvolumeclaims            pvc                                         true         PersistentVolumeClaim            [create delete deletecollection get list patch update watch]
persistentvolumes                 pv                                          false        PersistentVolume                 [create delete deletecollection get list patch update watch]
pods                              po                                          true         Pod                              [create delete deletecollection get list patch update watch]
podtemplates                                                                  true         PodTemplate                      [create delete deletecollection get list patch update watch]
replicationcontrollers            rc                                          true         ReplicationController            [create delete deletecollection get list patch update watch]
resourcequotas                    quota                                       true         ResourceQuota                    [create delete deletecollection get list patch update watch]
secrets                                                                       true         Secret                           [create delete deletecollection get list patch update watch]
serviceaccounts                   sa                                          true         ServiceAccount                   [create delete deletecollection get list patch update watch]
services                          svc                                         true         Service                          [create delete get list patch update watch]
mutatingwebhookconfigurations                  admissionregistration.k8s.io   false        MutatingWebhookConfiguration     [create delete deletecollection get list patch update watch]
... etc ...
</code></pre>

<p>Many list the verb <code>deletecollection</code> which sounds useful, but I can't run it e.g. </p>

<pre><code>$ kubectl deletecollection
Error: unknown command "deletecollection" for "kubectl"
Run 'kubectl --help' for usage.
unknown command "deletecollection" for "kubectl"
</code></pre>

<p>Nor can I find it in the docs except where it appears in the api-resources output above or mentioned as a verb.</p>

<p><strong>Is there a way to deletecollection?</strong></p>

<p>It sounds like it would be better than the sequence of grep/awk/xargs that I normally end up doing if it does do what I think it should do. i.e. delete all the pods of a certain type.</p>

<p>The <code>delete</code> verb refers to deleting a single resource, for example a single Pod. The <code>deletecollection</code> verb refers to deleting multiple resources at the same time, for example multiple Pods using a label or field selector or all Pods in a namespace.</p>

<p>To give some examples from the API documentation:</p>

<ol>
<li>To <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#delete-pod-v1-core" rel="noreferrer">delete a single Pod</a>: <code>DELETE /api/v1/namespaces/{namespace}/pods/{name}</code></li>
<li>To <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#delete-collection-pod-v1-core" rel="noreferrer">delete multiple Pods</a> (or, <code>deletecollection</code>):

<ol>
<li>All pods in a namespace <code>DELETE /api/v1/namespaces/{namespace}/pods</code></li>
<li>All pods in a namespace matching a given label selector: <code>DELETE /api/v1/namespaces/{namespace}/pods?labelSelector=someLabel%3dsomeValue</code></li>
</ol></li>
</ol>

<p>Regarding kubectl: You cannot invoke <code>deletecollection</code> explicitly with <code>kubectl</code>. </p>

<p>Instead, <code>kubectl</code> will infer on its own whether to use <code>delete</code> or <code>deletecollection</code> depending on how you invoke <code>kubectl delete</code>. When deleting a single source (<code>kubectl delete pod $POD_NAME</code>), kubectl will use a <code>delete</code> call and when using a label selector or simply deleting all Pods (<code>kubectl delete pods -l $LABEL=$VALUE</code> or <code>kubectl delete pods --all</code>), it will use the <code>deletecollection</code> verb.</p>
