Rest Query to list all containers in all namespace in Kubernetes Rest Query to list all containers in all namespace in Kubernetes kubernetes kubernetes

Rest Query to list all containers in all namespace in Kubernetes


You cant query the REST API for containers directly, since the smallest unit you can manage is a Pod, as is the same in your kubectl example.

You could however query all Pods and filter using a tool like jq. So obviously, replacing your $TOKEN and $CLUSTER as appropriate, the following should work:

curl -XGET -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" https://$CLUSTER:8443/api/v1/pods?limit=500 | jq '.items[] .spec .containers[] .name'

Not sure how the above has any benefit over using the cli though. On a side note, if your using the oc tool, set the --loglevel=9 option and you will be able to see what request is being sent to the server.