How to view resource usage in k8s?
To view the usage of various resources in a Kubernetes cluster, you can use the kubectl command line tool to execute the following command:
View the resource usage of the nodes in the cluster.
kubectl top nodes
This command will return a table containing the resource usage of each node, including CPU and memory usage.
View the resource utilization of all Pods in the cluster.
kubectl top pods --all-namespaces
This command will return a table that includes the resource usage of all Pods in the cluster, including CPU and memory usage. The –all-namespaces option is used to display Pods in all namespaces.
3. View the resource usage of Pods in a specific namespace.
kubectl top pods -n <namespace>
Replace
Before executing these commands, make sure kubectl is properly configured and connected to the Kubernetes cluster. Additionally, the monitoring setup of the cluster may affect the results of these commands.