kubernetes go client used storage of nodes and cluster

回眸只為那壹抹淺笑 提交于 2019-12-25 02:59:21

问题


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:

  1. 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 cluster

  2. What are the requests I need to do to get node stats?
    a. Run kubectl describe node, it should show you resource information.
    b. Now run kubectl 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!