<p>I would like to get the container status and restarts of a pod, using <a href="https://github.com/kubernetes-client/python" rel="noreferrer">python kubernetes</a>. I am currently using <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#list_namespaced_pod" rel="noreferrer">list_namespaced_pod</a> to get the pods and the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1ContainerStatus.md" rel="noreferrer">container status</a>, which I interpret as the status of the pod. This works, but is far from an ideal solution. I am looking for something that gives me similar information to <code>kubectl -n $NAMESPACE get pods</code>.</p>

<p>You can do the following for example, to get all the pods and their status:</p>

<pre><code>api_response = api_instance.list_namespaced_pod(namespace, pretty=pretty, timeout_seconds=timeout_seconds, watch=watch)

for i in api_response.items:
    print(i.metadata.name + " " + i.status.phase)
</code></pre>
