Search code examples
kubernetesheapster

using web API from Heapster in kubernetes


I have installed Heapster in my Kubernetes cluster.I can give resource usage from command line, for example kubectl top pods, and Kubernetes web panel.

I'm trying to get resource usage via web API from Heapster. Actually I'd like to get resource usage (e.g: ram and cpu) a node, pod or namespace from Web API.

There is a web api http://localhost:8001/swagger-2.0.0.json in Kubernetes but there isn't any API for resource usage or Heapster data.

Is there any way to get resource usage via web API in Kubernetes ?

thanks


Solution

  • Question has been answered in the above comment section.

    In order to access the Node as well as Pod Metrics, It's better to use Metrics_server which is the successor of heapster.

    The metrics server collects CPU and memory usage for nodes and pods by pooling data from Kubelet.

    View nodes and pods metrics:

    kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"

    kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods"