2

Is there a way to obtain hardware information (e.g. number of CPU cores, capacity of RAM) of an OpenShift 3.0 node programmatically? I could not find anything useful in the API references for OpenShift or Kubernetes (except for NodeSystemInfo in the Kubernetes API, which does not contain most of the hardware-level specs).

Janaka Bandara
  • 1,024
  • 1
  • 12
  • 27

2 Answers2

1

The Kubernetes NodeStatus has a field called Capacity, which is a list of resources with their corresponding amounts.

You can also see the Capacity in the output of kubectl describe nodes

e.g.

$ kubectl describe nodes my-node-1
Name:           my-node-1
...
Capacity:
 cpu:       1
 memory:    3801020Ki
 pods:      110
CJ Cullen
  • 5,452
  • 1
  • 26
  • 34
  • Thanks! Is it also possible to obtain the current resource usage (e.g. amount of used/free memory) via the API? – Janaka Bandara May 13 '16 at 05:58
  • I don't think there is a way to get the allocated requests/limits directly from the node object. `kubectl describe` lists all pods scheduled to the node, and sums their associated resource requests: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/describe.go#L1582 – CJ Cullen May 13 '16 at 16:24
1

There is a readonly stat endpoint exposed on both Openshift and Kubernetes. Normally it is exposed as https://api-host:10250/stats

Dimuthu
  • 7,946
  • 6
  • 22
  • 37