How to find available resources in a Kubernetes Cluster level?

12/6/2019

Do we have a simple command through which we can find the available resources at cluster level?

Available CPU and Memory requests.

-- karthikeayan
kubernetes

2 Answers

12/6/2019

There are couple of ways to achieve this. You didn't mention what environment are you using, however you probably already have metric server in your cluster.

1. Top command

kubeclt top pods or kubectl top nodes. This way you will be able to check current usage of pods/nodes. You can also narrow it to namespace.

2. Describe node

If you will execute kubeclt describe node, in output you will be able to see Capacity of that node and how much allocated resources left. Similar with Pods.

...
Capacity:
 attachable-volumes-gce-pd:  127
 cpu:                        1
 ephemeral-storage:          98868448Ki
 hugepages-2Mi:              0
 memory:                     3786684Ki
 pods:                       110
Allocatable:
 attachable-volumes-gce-pd:  127
 cpu:                        940m
 ephemeral-storage:          47093746742
 hugepages-2Mi:              0
 memory:                     2701244Ki
 pods:                       110
 ...

3. Prometheus

If you need more detailed inforamtion with statistics, I would recommend you to use Prometheus. It will allow you to creat stistics of nodes/pods, generate alerts and many more. It also might provide metrics not only CPU and Memory but also custom.metrics which can create statistics of all Kubernetes objects.

Many useful information can be found here.

-- PjoterS
Source: StackOverflow

12/6/2019

this is very useful script to monitor kubernetes resources

https://www.jeffgeerling.com/blog/2019/monitoring-kubernetes-cluster-utilization-and-capacity-poor-mans-way

i would suggest to use prometheus to get such metrics

-- shubham_asati
Source: StackOverflow