<p>Could not find how can I obtain information about memory consumption on kubernetes node with kubernetes-client library in Python. I know how to obtain this information with <code>kubectl</code> command.</p>

<p>Could you provide me with a piece of code how can I do this via the lib?</p>

<p>Thank you.</p>

Stanislav Hordiyenko
<h1>Getting started</h1>
<p><a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md" rel="nofollow noreferrer">kubernetes-client</a> contains pieces of code that you need:</p>
<pre class="lang-py prettyprint-override"><code>from kubernetes import client, config


def main():
    # Configs can be set in Configuration class directly or using helper
    # utility. If no argument provided, the config will be loaded from
    # default location.
    config.load_kube_config()

    v1 = client.CoreV1Api()
    print(&quot;Listing pods with their IPs:&quot;)
    ret = v1.list_pod_for_all_namespaces(watch=False)
    for i in ret.items:

        print(&quot;%s\t%s\t%s&quot; %
              (i.status.pod_ip, i.metadata.namespace, i.metadata.name))


if __name__ == '__main__':
    main()
</code></pre>
<h1>Method</h1>
<p>For get pod metrics, try this <strong>beta</strong> class:
<a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V2beta2PodsMetricStatus.md" rel="nofollow noreferrer">V2beta2PodsMetricStatus</a></p>
<h1>Metrics</h1>
<p>According to <a href="https://github.com/kubernetes/kube-state-metrics/blob/master/docs/pod-metrics.md" rel="nofollow noreferrer"><code>k8s</code> documentation</a> Your metrics supposed to be:</p>
<ul>
<li><p><code>kube_pod_container_resource_limits_memory_bytes</code></p>
</li>
<li><p><code>kube_pod_container_resource_requests_memory_bytes</code></p>
</li>
</ul>
