Monitoring metrics using the CLI

As part of the Metrics Server, the Resource Metrics API provides access to CPU and memory resource metrics for pods and nodes. Let's use the Resource Metrics API to access the metrics data from the CLI:

  1. First, let's display node resource utilization: 
$ kubectl top nodes
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
ip-172-20-32-169.ec2.internal 259m 12% 1492Mi 19%
ip-172-20-37-106.ec2.internal 190m 9% 1450Mi 18%
ip-172-20-48-49.ec2.internal 262m 13% 2166Mi 27%
ip-172-20-58-155.ec2.internal 745m 37% 1130Mi 14%

The command will return utilized CPU and memory on all your Kubernetes nodes.

There are a couple of ways to use the metrics information. First of all, at any given time, usage of both CPU and memory should be below your desired threshold, otherwise new nodes need to be added to your cluster to handle services smoothly. Balanced utilization is also important, which means that if the percentage of memory usage is higher than the average percentage of CPU usage, you may need to consider changing your cloud instance type to use better-balanced VM instances.
  1. Display pod resource utilization in any namespace. In this example, we are listing the pods in the openebs namespace:
$ kubectl top pods -n openebs
NAME CPU(cores) MEMORY(bytes)
maya-apiserver-6ff5bc7bdd-l5gmt 2m 10Mi
openebs-admission-server-76dbdf97d9-swjw9 0m 3Mi
openebs-localpv-provisioner-6777f78966-f6lzp 2m 8Mi
openebs-ndm-operator-797495544c-hblxv 5m 12Mi
openebs-ndm-prvcr 1m 6Mi
openebs-ndm-qmr66 1m 6Mi
openebs-ndm-xbc2q 1m 6Mi
openebs-provisioner-58bbbb8575-jzch2 3m 7Mi
openebs-snapshot-operator-6d7545dc69-b2zr7 4m 15Mi

The command should return the utilized CPU and memory on all your pods. Kubernetes features such as Horizontal Pod Scaler can utilize this information to scale your pods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.22.23