<p>Using kubectl describe nodes, i am able to get the capacity of resources(memory,cpu) of a node. I want to get the same via go client or kube API (if available). Can anyone help me out?
i am using minikube version: v1.7.2
kubectl version : 
Client :  GitVersion:"v1.16.3"
Server :  GitVersion:"v1.16.2"
I am using metric-server to access the kubernetes resource.
Expected result:
Capacity of resources should be accessible through go program or kube API</p>

<p>There isn't any API call you could use to get <code>kubectl describe nodes</code> this is because this command is generating all the output.</p>

<p><code>Kubectl</code> retrieves all relevant pods (every pod that isn't failed or succeeded) on a node and sums up all their resource definitions.</p>

<p>You can look into the code and find the function responsible for generating information about node <a href="https://github.com/kubernetes/kubernetes/blob/85f1205efa89008e6e94a92d66a9dd691cb59825/pkg/kubectl/describe/versioned/describe.go#L2807" rel="nofollow noreferrer">here</a>.</p>

<p>Same for collecting all requests and limits for pods, function is available <a href="https://github.com/kubernetes/kubernetes/blob/85f1205efa89008e6e94a92d66a9dd691cb59825/pkg/kubectl/describe/versioned/describe.go#L3241-L3263" rel="nofollow noreferrer">here</a> and it's called <code>getPodsTotalRequestsAndLimits</code></p>

<p>Lastly the function what puts all that together can be seen <a href="https://github.com/kubernetes/kubernetes/blob/85f1205efa89008e6e94a92d66a9dd691cb59825/pkg/kubectl/describe/versioned/describe.go#L3177" rel="nofollow noreferrer">here</a>.</p>

<p>There is a really nice article about <a href="https://medium.com/@gorenje/kubernetes-api-allocatable-node-resources-6ea88f828f0" rel="nofollow noreferrer">Kubernetes API: Allocatable Node Resources?</a> The author is doing exactly what you are asking for but using Python.</p>
