<p>I am using the Minikube environment and I have defined the max memory using</p>

<pre><code>$] minikube config set memory 2048
</code></pre>

<p>Now I want to get this memory value using the Kubernetes API call in GO.
I have tried the following,</p>

<pre><code>import (
    "k8s.io/client-go/kubernetes"
    "k8s.io/client-go/rest"
)

availableMem := kubernetes.Interface.StorageV1beta1().RESTClient().Get().Name("config")
</code></pre>

<p>But the output is not in readable manner.</p>

<p>This code will fetch the available memory of the first cluster</p>

<pre><code>nodeList, err := f.KubeClient.CoreV1().Nodes().List(metav1.ListOptions{})

if err == nil {
   if len(nodeList.Items) &gt; 0 {
        node := &amp;nodeList.Items[0]
        memQuantity := node.Status.Allocatable[v1.ResourceMemory]
        totalMemAvail = int(memQuantity.Value() &gt;&gt; 20)
    } else {
        t.Fatal("Unable to read node list")
        return
    }
} else {
    t.Fatalf("Error while reading node list data: %v", err)
}
</code></pre>
