How do I measure my pods startup, min and max CPU and Memory

1.3k views Asked by At

I like to see how my services will work on kubernethes so I can optimize my code and set good values for request/limit on both CPU and memory.

To do that I have tried kubectl top bit ot only gives me the current usage.

kubectl top pod podname

How do I get the init, min and max usage?

If it is not possible to get all those values, is there any way to get max usage?

1

There are 1 answers

0
Vit On

In order to see stats you may want to use one of these monitoring tools:

  1. cAdvisor

Container Advisor is a great monitoring tool that provides container-level metrics and exposes resource usage and performance data from running containers. It provides quick insight into CPU usage, memory usage, and network receive/transmit of running containers. cAdvisor is embedded into the kubelet, hence you can scrape the kubelet to get container metrics, store the data in a persistent time-series store like Prometheus/InfluxDB, and then visualize it via Grafana.

  1. Metrics Server

Metrics Server is a cluster-wide aggregator of resource usage data and collects basic metrics like CPU and memory usage for Kubernetes nodes, pods, and containers. It’s used by Horizontal Pod Autoscaler and the Kubernetes dashboard itself, and users can access these metrics directly by using the kubectl top command. Metrics Server replaces Heapster as the primary metrics aggregator in the cluster, which has been marked as deprecated in the newer version of Kubernetes.

  1. Node Exporter

Node Exporter is the Prometheus exporter for hardware and operating system metrics. It allows you to monitor node-level metrics such as CPU, memory, filesystem space, network traffic, and other monitoring metrics, which Prometheus scraps from a running node exporter instance. You can then visualize these metrics in Grafana.

  1. Kube-State-Metrics

Kube-state-metrics is an add-on agent that listens to the Kubernetes API server. It generates metrics about the state of the Kubernetes objects inside the cluster like deployments, replica sets, nodes, and pods.

Metrics generated by kube-state-metrics are different from resource utilization metrics, which are primarily geared more towards CPU, memory, and network usage. Kube-state-metrics expose critical metrics about the condition of your Kubernetes cluster:

  • Resource requests and limits
  • Number of objects–nodes, pods, namespaces, services, deployments
  • Number of pods in a running/terminated/failed state
  1. Prometheus

Prometheus is a free software application used for event monitoring and alerting. It records real-time metrics in a time series database built using a HTTP pull model, with flexible queries and real-time alerting

You can visualize Prometheus monitoring data with Grafana and its dashboard collection.

You can find detailed Monitor Your Kubernetes Cluster With Prometheus and Grafana instruction how to use them together