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
Kubernetes Client libraries are the ones you need to look at https://kubernetes.io/docs/reference/using-api/client-libraries/#officially-supported-kubernetes-client-libraries
The following client libraries are officially maintained by Kubernetes SIG API Machinery.
Language Client Library
Go github.com/kubernetes/client-go/
Python github.com/kubernetes-client/python/
Java github.com/kubernetes-client/java
dotnet github.com/kubernetes-client/csharp
JavaScript github.com/kubernetes-client/javascript
Haskell github.com/kubernetes-client/haskell
Community-maintained client libraries
The following Kubernetes API client libraries are provided and maintained by their authors, not the Kubernetes team.
Language Client Library
Clojure github.com/yanatan16/clj-kubernetes-api
Go github.com/ericchiang/k8s
Java (OSGi) bitbucket.org/amdatulabs/amdatu-kubernetes
Java (Fabric8, OSGi) github.com/fabric8io/kubernetes-client
Lisp github.com/brendandburns/cl-k8s
Lisp github.com/xh4/cube
Node.js (TypeScript) github.com/Goyoo/node-k8s-client
Node.js github.com/tenxcloud/node-kubernetes-client
Node.js github.com/godaddy/kubernetes-client
Node.js github.com/ajpauwels/easy-k8s
Perl metacpan.org/pod/Net::Kubernetes
PHP github.com/maclof/kubernetes-client
PHP github.com/allansun/kubernetes-php-client
PHP github.com/travisghansen/kubernetes-client-php
Python github.com/eldarion-gondor/pykube
Python github.com/mnubo/kubernetes-py
Python github.com/tomplus/kubernetes_asyncio
Ruby github.com/Ch00k/kuber
Ruby github.com/abonas/kubeclient
Ruby github.com/kontena/k8s-client
Rust github.com/clux/kube-rs
Rust github.com/ynqa/kubernetes-rust
Scala github.com/doriordan/skuber
dotNet github.com/tonnyeremin/kubernetes_gen
DotNet (RestSharp) github.com/masroorhasan/Kubernetes.DotNet
Elixir github.com/obmarg/kazan
Elixir github.com/coryodaniel/k8s
Haskell github.com/kubernetes-client/haskell
There isn't any API call you could use to get kubectl describe nodes
this is because this command is generating all the output.
Kubectl
retrieves all relevant pods (every pod that isn't failed or succeeded) on a node and sums up all their resource definitions.
You can look into the code and find the function responsible for generating information about node here.
Same for collecting all requests and limits for pods, function is available here and it's called getPodsTotalRequestsAndLimits
Lastly the function what puts all that together can be seen here.
There is a really nice article about Kubernetes API: Allocatable Node Resources? The author is doing exactly what you are asking for but using Python.