<p>I was wondering if there is a possibility to continuously print logs from HTTP request to Kubernetes API. I am using python for querying K8S API sth like</p>

<p><code>r = requests.get(self.url + "namespaces/" + namespace + "/pods/" + pod_name + "/log", cert=(self.cert, self.key), verify=False)</code></p>

<p>and i would like to use <code>follow=true</code> parameter probably together with <code>tailLines=100</code> to make it more like <code>tail</code> command.</p>

<p>When I am using <code>follow</code> parameter the request is collecting response but i don't know how to forward it's output to console.
Is it possible?</p>

<p>What i was missing is <code>stream=True</code> in <code>request.get</code> parameter which allows to iterate through the response content so my code looks like this:</p>

<pre><code>import requests

class Logs():
    def __init__(self, url='https://192.168.0.1:6443/api/v1/',
                 cert='./client.crt',
                 key='./client.key'):
        self.url = url
        self.cert = cert
        self.key = key
        requests.packages.urllib3.disable_warnings()

    def get_pod_logs(self, namespace, pod_name):

        params = dict(
            follow="true",
            tailLines="100"
        )

        r = requests.get(self.url + "namespaces/" + namespace + "/pods/" + pod_name + "/log", params=params,
                         cert=(self.cert, self.key), verify=False, stream=True)

        for chunk in r.iter_content(chunk_size=256):
            if chunk:
                print(chunk)

logs = Logs()

logs.get_pod_logs(namespace="my-ns",pod_name="my-pod")
</code></pre>
