<p>I'm trying to use the Python Kubernetes Client to get the run-time of each container for all my pods. Using the K8s CLI this information is available by using <code>kubectl describe pods</code>. </p>

<p>I can get the output for a single pod by using </p>

<pre class="lang-py prettyprint-override"><code>api_response = api_instance.read_namespaced_pod(name='pod-name',namespace='namespace-name')
</code></pre>

<p>However, I need this information for all the pods. </p>

<p>What is the equivalent of <code>kubectl get pods</code>for Python K8s library? I'm thinking I can use this to create a list of pods and use the mentioned command above to loop through them by their pod-name and get the required information. </p>

aideen
<p>You are right about using this command to get all pod names:</p>
<pre><code>api_response = api_instance.read_namespaced_pod(name='pod-name',namespace='namespace-name')
</code></pre>
<p>But to get specifically the name of those, use something like this:</p>
<pre><code>for i in api_response.items:
    print(&quot;%s&quot; %(i.metadata.name))
</code></pre>
<p>That should work for you :)</p>
