Kubernetes CKA sample exam question 55 with answer

Question
The metrics-server has been installed in the cluster. Your colleague would like to know the kubectl commmands to:

  1. show Nodes resource usage
  2. show pods and their containers resource usage
Please write the commands into /opt/course/7/node.sh and /opt/course/7/pod.sh

Answer
For nodes:
kubectl top nodes
echo "kubectl top nodes" > /opt/course/7/node.sh
For pods:
kubectl top pods --containers
echo "kubectl top pods --containers" > /opt/course/7/pod.sh
Verify:
bash /opt/course/7/node.sh
bash /opt/course/7/pod.sh