简体   繁体   English

如何获取 K8s 集群中的可用资源(内存、cpu)?

[英]How to get the available resources (memory, cpu) in a K8s cluster?

I would like to know what resources are available in the entire K8s cluster that I am using.我想知道我正在使用的整个 K8s 集群中有哪些资源可用。

To be clear, I am not talking about the Resource Quotas , because those only define resources per namespace.需要明确的是,我不是在谈论Resource Quotas ,因为那些只定义每个命名空间的资源。 I would like to know what the capabilities of the entire cluster are (memory, cpu,...).我想知道整个集群的功能是什么(内存、CPU、...)。 Please note that the sum of all resource quotas is not equal to the capabilities of the cluster.请注意,所有资源配额的总和不等于集群的能力。 The sum can be greater (creates race condition for resources between namespaces) or smaller (cluster not used to its fullest potential) than the resources of the cluster.总和可以比集群的资源更大(为命名空间之间的资源创建竞争条件)或更小(集群未充分利用其潜力)。

Can I use kubectl to answer this query?我可以使用 kubectl 来回答这个查询吗?

You can use kubectl top command to check the memory and CPU consumption of all the nodes or pods.您可以使用kubectl top命令来检查所有节点或 Pod 的内存和 CPU 消耗。

kubectl top nodes

For more information you can do,有关您可以执行的更多信息,

kubectl top -h

For kubectl top command to work, you need to install metrics-server in kubernetes cluster to fetch the CPU and memory metrics.要使 kubectl top 命令起作用,您需要在 kubernetes 集群中安装metrics-server以获取 CPU 和内存指标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM