Reputation: 336
I want to use the Python Kubernetes Client to retrieve all CRs, because I want to delete them. The latter can easily be done with delete_namespaced_custom_object
from the CustomObjectsApi
. But first, I need a list containing all of them, so an equivalent to k get crd -A
, which cannot be found in the docu. Is there a trick? I do not want to call list_namespaced_custom_object
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 k get crd -A
, since this can lead to many problems (error handling etc).
Upvotes: 0
Views: 938
Reputation: 1140
Use the API method: list_cluster_custom_object
.
There are some concepts to clarify:
k get crd
is used to get all CRD
resource objects, -A
option is useless;application
. kubectl get application -A
gets all application
(custom resource) objects in all namespaces;kubectl get application -A --v 6
will show you the specific HTTP request it sends to apiserver, which is in the form GET /apis/{group}/{version}/{plural}
;Querying the api endpoints table, you can find that the corresponding API method is list_cluster_custom_object
.
Upvotes: 3