问题
I am newbie in Go. I want to get the storage statistics of nodes and cluster in kubernetes using Go code. How i can get the free and used storage of Kubernetes nodes and cluster using Go.
回答1:
This is actually 2 problems:
How do I perform http requests to the kubernets master?
See [1] for more details. Tl;dr you can access the apiserver in at least 3 ways:
a.kubectl get nodes
(not go)
b.kubectl proxy
, followed by a go http client to this url
c. Running a pod in a kubernetes clusterWhat are the requests I need to do to get node stats?
a. Runkubectl describe node
, it should show you resource information.
b. Now runkubectl describe node --v=7
, it should show you the REST calls.
I also think you should reformat the title of your question per https://stackoverflow.com/help/how-to-ask, so it reflects what you're really asking.
[1] https://github.com/kubernetes/kubernetes/blob/release-1.0/docs/user-guide/accessing-the-cluster.md
来源:https://stackoverflow.com/questions/33167023/kubernetes-go-client-used-storage-of-nodes-and-cluster