Reputation: 544
Using command-line utility kubectl
we can list a custom resource instances as follows
kubectl get <customresource_kind>
In a similar fashion, do we have a REST API to achieve the same? i.e. the API takes the Kind of the CustomResource and lists all the instances created?
I am referring to this API Reference : https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/
Upvotes: 0
Views: 1241
Reputation: 6567
You can list crds like every other API resources using Kubernetes REST API.
The final URL path will differ, depending on object's scope: Cluster
or Namespaced
.
The general rule for constructing the URL path is described here in official documentation.
Just to give you an example based on calico's clusterinformations.crd.projectcalico.org (v1):
kubectl proxy --port=8080 &
curl http://localhost:8080/apis/crd.projectcalico.org/v1/clusterinformations | jq '.items[].metadata.name
"default" <- I have only one instance of this type of custom resource
Upvotes: 1