<p>I want to get log and describe of my pod in kubernetes by python client. In kubernetes cluster we can use </p>

<pre><code>kubectl logs &lt;NAME_OF_POD&gt;
kubectl describe pods &lt;NAME_OF_pod&gt;
</code></pre>

<p>But I want these command in python client of kubernetes.what should I do?</p>

check nova
<p>You can read the logs of a pod using the following code:</p>

<pre><code>from kubernetes.client.rest import ApiException
from kubernetes import client, config

config.load_kube_config()
pod_name = "counter"
try:
    api_instance = client.CoreV1Api()
    api_response = api_instance.read_namespaced_pod_log(name=pod_name, namespace='default')
    print(api_response)
except ApiException as e:
    print('Found exception in reading the logs')
</code></pre>

<p>The above code works perfectly fine for getting the logs of pod.</p>

<p>To get the output of <code>kubectl describe pod</code>, all the information provided is  in <code>read_namespaced_pod</code> function. It has all the information you require, and you can use that information in whatever way you require. You can edit the above code and use <code>read_namespaced_pod</code> in place of <code>read_namespaced_pod_log</code> to get the info.</p>
