January
21st,
2020
Here are a few handy commands to check and see how much cpu and memory your Openshift cluster is using.
Node Utilisation
$ oc adm top node
will show how much memory and cpu your nodes are using.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host ~]# oc adm top node | |
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% | |
master0 408m 11% 3377Mi 21% | |
master1 546m 15% 2772Mi 17% | |
master2 448m 12% 3325Mi 21% | |
worker0 238m 6% 2151Mi 13% | |
worker1 257m 7% 2188Mi 14% | |
worker2 128m 3% 1367Mi 11% |
$ oc describe node/$nodeName
will give details about the allocated resources:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host ~]# oc describe node/master0 | |
Name: master0 | |
Roles: master | |
Labels: beta.kubernetes.io/arch=amd64 | |
beta.kubernetes.io/os=linux | |
#REDACTED | |
Allocated resources: | |
(Total limits may be over 100 percent, i.e., overcommitted.) | |
Resource Requests Limits | |
-------- -------- ------ | |
cpu 1520m (43%) 0 (0%) | |
memory 4389Mi (28%) 512Mi (3%) | |
ephemeral-storage 0 (0%) 0 (0%) | |
Events: <none> |
This can be shortened to the following command:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NodeName, cpu requests, cpu limits, memory requests, memory limits | |
[root@host ~]# oc get node --no-headers | while read node stat role age ver; do echo -ne "$node\t"; oc describe node $node | egrep '^ (cpu|memory)' | sed -r 's/\(|\)//g' | while read lbl x p1 y p2; do echo -n \ $p1 $p2 ; done; echo ""; done | |
master0 43% 0% 28% 3% | |
master1 40% 0% 23% 3% | |
master2 44% 0% 27% 3% | |
worker0 33% 8% 17% 3% | |
worker1 35% 8% 19% 3% | |
worker2 22% 2% 15% 4% |
Pod Utilisation
$ oc adm top pod
will give an idea of which pods are the most hungry. Omnomnom.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@host ~]# oc adm top pod --all-namespaces | |
NAMESPACE NAME CPU(cores) MEMORY(bytes) | |
openshift-apiserver apiserver-729wn 4m 111Mi | |
openshift-apiserver apiserver-bjgqh 7m 113Mi | |
openshift-apiserver apiserver-cv94b 5m 115Mi | |
openshift-apiserver-operator openshift-apiserver-operator-7bcd69678-9r8fl 3m 31Mi | |
openshift-authentication oauth-openshift-7469964dbb-7h6w2 1m 20Mi | |
openshift-authentication oauth-openshift-7469964dbb-r65bj 1m 20Mi | |
openshift-authentication-operator authentication-operator-55f4b64744-9csk9 4m 48Mi | |
openshift-cloud-credential-operator cloud-credential-operator-75f696fdf7-fwggh 1m 60Mi | |
openshift-cluster-machine-approver machine-approver-854544ff4d-h9wbm 0m 13Mi | |
openshift-cluster-node-tuning-operator cluster-node-tuning-operator-56485dcbb4-5gg7p 0m 28Mi | |
#REDACTED |
We can also break this down to a node level by extracting the information from oc describe node
with the following:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NodeName, CPU Requests CPU Limits Memory Requests Memory Limits AGE (from oc describe node) | |
[root@host ~]# oc get node --no-headers | while read node stat role age ver; do oc describe node $node | egrep '.+(%.+){3}' | sed -r 's/\(|\)//g' | while read line; do echo $node $line; done; echo ""; done | column -t | |
master0 openshift-apiserver-operator openshift-apiserver-operator-7bcd69678-9r8fl 10m 0% 0 0% 50Mi 0% 0 0% 45h | |
master0 openshift-apiserver apiserver-bjgqh 150m 4% 0 0% 200Mi 1% 0 0% 45h | |
master0 openshift-cloud-credential-operator cloud-credential-operator-75f696fdf7-fwggh 10m 0% 0 0% 150Mi 0% 0 0% 45h | |
master0 openshift-cluster-machine-approver machine-approver-854544ff4d-h9wbm 10m 0% 0 0% 50Mi 0% 0 0% 45h | |
master0 openshift-cluster-node-tuning-operator tuned-pxp9v 10m 0% 0 0% 50Mi 0% 0 0% 45h | |
master0 openshift-cluster-version cluster-version-operator-cb6bf8766-2cdsh 20m 0% 0 0% 50Mi 0% 0 0% 45h | |
master0 openshift-controller-manager-operator openshift-controller-manager-operator-b6856d4ff-nvc9c 10m 0% 0 0% 50Mi 0% 0 0% 45h | |
# REDACTED |
Hope that was helpful :o)