<p>I want to use the Python Kubernetes Client to retrieve <em>all</em> CRs, because I want to delete them. The latter can easily be done with <code>delete_namespaced_custom_object</code> from the <code>CustomObjectsApi</code>. But first, I need a list containing all of them, so an equivalent to <code>k get crd -A</code>, which cannot be found in the docu. Is there a trick? I do not want to call <code>list_namespaced_custom_object</code> for all of them, or better said: I do not even know all of them beforehand, so this needs to be a solution that gets all CRs. I really want to use the Python Client and not do a subprocess <code>k get crd -A</code>, since this can lead to many problems (error handling etc).</p>

harrisonfooord
<p>Use the API method: <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CustomObjectsApi.md#list_cluster_custom_object" rel="nofollow noreferrer"><code>list_cluster_custom_object</code></a>.</p>
<p>There are some concepts to clarify:</p>
<ol>
<li><code>k get crd</code> is used to get all <code>CRD</code> resource objects, <code>-A</code> option is useless;</li>
<li>Say, you have a custom resource type called <code>application</code>. <code>kubectl get application -A</code> gets all <code>application</code>(custom resource) objects in all namespaces;</li>
<li><code>kubectl get application -A --v 6</code> will show you the specific <strong>HTTP request</strong> it sends to apiserver, which is in the form <code>GET /apis/{group}/{version}/{plural}</code>;</li>
</ol>
<p>Querying the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md#documentation-for-api-endpoints" rel="nofollow noreferrer">api endpoints</a> table, you can find that the corresponding API method is <code>list_cluster_custom_object</code>.</p>
