Cluster CPU & Memory Inspections

Quickly get the summary of total CPU

$ kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.cpu}{"\n"}{end}' | awk '{sum += $2} END {print "Total CPUs across all nodes: " sum}'

Quickly get the summary of total Memory

$ kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.memory}{"\n"}{end}' | awk '{print $1 "\t" $2 / (1024 * 1024) " MB"}'

Inspect Current Utilization

Ensure that Metrics Server is installed in your Kubernetes cluster. If it's installed, you can query it to get CPU and memory usage information.

$ kubectl top nodes

Run below command to convert from Mebibytes (Mi) to Megabytes (MB)

$ kubectl top nodes | awk '{print $1, $2, $3, $4, ($5/1024/1024)"MB", $6}'

Using Kubernetes Dashboard

If you have Kubernetes Dashboard installed, you can also use it to view resource usage across your cluster.

Last updated