how to calculate kubernetes s pod cpu and memory share rate

4/27/2020

I want to know the share of resource - cpu, memory- per kubernetes's pod. And I want to know what the standard of share is

-- gyuhyeon lee
kubernetes
pod
share

3 Answers

4/28/2020

You can use metrics server which is the Cluster-wide aggregator of resource usage data. It is the source of container resource metrics for Kubernetes built-in autoscaling pipelines. It collects resource metrics from Kubelets and exposes them in Kubernetes apiserver. You can also access the metrics API by kubectl top.

Another solution is using Prometheus as suggested by @jankantert.

-- Abdullah Danyal
Source: StackOverflow

4/27/2020

Try kubectl top and friends. More words because SO requires them.

-- coderanger
Source: StackOverflow

4/27/2020

This is hard to do using kubectl only (or I don't know how). What we usually do is to use the kubelet metric-server to export all metric to prometheus. We then use Grafana to calculate those values. The following metrics should allow you to calculate your values:

CPU cores:

  • kube_node_status_allocatable_cpu_cores - available cores
  • kube_pod_container_resource_requests_cpu_cores - requested cores per container
  • container_cpu_usage_seconds_total - used cores per container

Memory:

  • kube_node_status_allocatable_memory_bytes - available memory
  • kube_pod_container_resource_requests_memory_bytes - requested memory by container
  • container_memory_usage_bytes - used memory by container

You can filter those by label (i.e. by pod name or namespace) and calculate all kinds of things based on them.

-- jankantert
Source: StackOverflow