<p>I know there is <code>kubectl</code> command to list containers in all the namespaces:</p>

<pre><code>kubectl get pods --all-namespaces -o jsonpath={.items[*].spec.containers[*].name}
</code></pre>

<p>is there a way to get all the containers in all namespaces using rest query?</p>

Mohammed
<p>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 <code>kubectl</code> example. </p>

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

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

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