<p>I have <a href="https://containers.cloud.ibm.com/global/swagger-global-api" rel="nofollow noreferrer">https://containers.cloud.ibm.com/global/swagger-global-api</a> - Kubernetes API swagger to drill upto each clusters details till namespaces.Using IAM token to access these API’s.
Further, i want to get all the pods of that specific namespace and in turn image version of each pod.</p>

<p>I have tried using <a href="https://github.com/kubernetes-client/javascript" rel="nofollow noreferrer">https://github.com/kubernetes-client/javascript</a> client libraries to fetch all pods,But how will i get the pods of namespaces from my cluster of my account programatically? </p>

<p>This i want to achieve either by using REST API's or some client libraries.How to use these libraries?</p>

<pre><code>var k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
    kc.loadFromDefault();
 const k8sApi = kc.makeApiClient(k8s.CoreV1Api);

    const listFn = () =&gt; k8sApi.listPodForAllNamespaces()
    console.log(listFn);
</code></pre>

<p>I get nothing from the above code.</p>

<p>The code that you have is not capturing errors. Hence you are not seeing any error even if it's not working.</p>

<p>First setup kubeconfig following this <a href="https://cloud.ibm.com/docs/containers?topic=containers-cs_cli_install#kubectl" rel="nofollow noreferrer">guide</a> and use below code to get all pods of a specific namespace for example <code>default</code></p>

<pre><code>k8sApi.listNamespacedPod('default')
    .then((res) =&gt; {
    console.log(res.body);
    })
    .catch((err) =&gt; {
        console.log(err);
    });
</code></pre>
