<p>The kubernetes go client has tons of methods and I can't find how I can get the current CPU &amp; RAM usage of a specific (or all pods).</p>

<p>Can someone tell me what methods I need to call to get the current usage for pods &amp; nodes?</p>

<p><strong>My NodeList:</strong></p>

<pre><code>nodes, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{})
</code></pre>

<p>Kubernetes Go Client: <a href="https://github.com/kubernetes/client-go" rel="noreferrer">https://github.com/kubernetes/client-go</a></p>

<p>Metrics package: <a href="https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/metrics" rel="noreferrer">https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/metrics</a></p>

<p>As far as I got the metrics server implements the Kubernetes metrics package in order to fetch the resource usage from pods and nodes, but I couldn't figure out where &amp; how they do it: <a href="https://github.com/kubernetes-incubator/metrics-server" rel="noreferrer">https://github.com/kubernetes-incubator/metrics-server</a></p>

<p>It is correct that go-client does not have support for metrics type, but in the metrics package there is a pregenerated <a href="https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/metrics/pkg/client/clientset/versioned" rel="noreferrer">client</a> that can be used for fetching metrics objects and assign them right away to the appropriate structure. The only thing you need to do first is to generate a config and pass it to metrics client. So a simple client for metrics would look like this:</p>

<pre><code>package main


import (
    "k8s.io/client-go/tools/clientcmd"
    metrics "k8s.io/metrics/pkg/client/clientset/versioned"
    metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)



func main() {
    var kubeconfig, master string //empty, assuming inClusterConfig
    config, err := clientcmd.BuildConfigFromFlags(master, kubeconfig)
    if err != nil{
        panic(err)
    }

    mc, err := metrics.NewForConfig(config)
    if err != nil {
        panic(err)
    }

    mc.MetricsV1beta1().NodeMetricses().Get("your node name", metav1.GetOptions{})
    mc.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{})
    mc.MetricsV1beta1().PodMetricses(metav1.NamespaceAll).List(metav1.ListOptions{})
    mc.MetricsV1beta1().PodMetricses(metav1.NamespaceAll).Get("your pod name", metav1.GetOptions{})
}
</code></pre>

<p>Each of the above methods from metric client returns an appropriate structure (you can check those <a href="https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1/types.go" rel="noreferrer">here</a>) and an error (if any) which you should process according to your requirements. </p>
