检查kubernetes Pod CPU和内存 [英] Checking kubernetes pod CPU and memory

查看:1177
本文介绍了检查kubernetes Pod CPU和内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查看kubernetes容器使用了多少内存和CPU.为此,我运行了以下命令:

I am trying to see how much memory and CPU is utilized by a kubernetes pod. I ran the following command for this:

kubectl top pod podname --namespace=default

我遇到以下错误:

W0205 15:14:47.248366    2767 top_pod.go:190] Metrics not available for pod default/podname, age: 190h57m1.248339485s
error: Metrics not available for pod default/podname, age: 190h57m1.248339485s

  1. 该错误该怎么办?还有其他方法可以获取Pod的CPU和内存使用情况吗?
  2. 我看到了此命令的示例输出,该示例显示CPU为250m.该如何解释?

  1. What do I do about this error? Is there any other way to get CPU and memory usage of the pod?
  2. I saw the sample output of this command which shows CPU as 250m. How is this to be interpreted?

如果我们进入Pod并运行linux top命令,我们会得到相同的输出吗?

Do we get the same output if we enter the pod and run the linux top command?

推荐答案

  1. docs 中所述,则应安装 metrics-server

250m表示250毫秒CPU,CPU资源为 等同于:

250m means 250 milliCPU, The CPU resource is measured in CPU units, in Kubernetes, is equivalent to:

  • 1个AWS vCPU
  • 1个GCP核心
  • 1个Azure vCore
  • 具有超线程功能的裸机Intel处理器上的1个超线程

允许使用分数.一个请求0.5 CPU的容器是 保证CPU数量是请求1个CPU的容器的一半.你 可以使用后缀m表示毫.例如100m CPU,100 milliCPU和0.1 CPU都相同.精度不超过1m 允许.

Fractional values are allowed. A Container that requests 0.5 CPU is guaranteed half as much CPU as a Container that requests 1 CPU. You can use the suffix m to mean milli. For example 100m CPU, 100 milliCPU, and 0.1 CPU are all the same. Precision finer than 1m is not allowed.

CPU始终被请求为绝对数量,而不是相对数量 数量; 0.1是单核,双核上的相同CPU数量, 或48核计算机.

CPU is always requested as an absolute quantity, never as a relative quantity; 0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine.

  • 否,kubectl top pod podname显示给定Pod的度量,Linux topfree在容器内运行,并基于Linux系统报告基于存储在虚拟文件系统中的信息来报告度量 /proc/,他们不知道它在哪里运行.

  • No, kubectl top pod podname shows metrics for a given pod, Linux top and free runs inside a Container and report metrics based on Linux system reporting based on the information stored in the virtual filesystem /proc/, they are not aware of the cgroup where it runs.

    这些链接上有更多详细信息:

    There are more details on these links:

    • Why top and free inside containers don't show the correct container memory
    • Kubernetes top vs Linux top

    这篇关于检查kubernetes Pod CPU和内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆