kubernetes - List `kubectl top pods` filtered by node
问题描述
Is there a way to get top pods
filtered by node?
Use case: I have a node which is reported to use 103% of the cpu and I want to validate which pods are causing it.
解决方案
我认为没有直接的方法可以使用kubectl top pods
命令来执行此操作,因为过滤的唯一选项是仅适用于 pod 的标签/选择器。
对于您的用例,您可以使用以下命令:
kubectl get pods -o wide | grep <node> | awk {'print $1'} | xargs -n1 command kubectl top pods --no-headers
kubectl get pods -o wide
: 显示 pod 及其关联的节点信息grep <node>
:让您过滤位于特定节点上的 podawk {'print $1'}
:打印第一列(豆荚的名称)xargs -n1 command kubectl top pods --no-headers
: 为每个不带 headers (NAME, CPU, MEMORY) 的 pod 执行 top 命令
此外,您可以使用以下命令检查为一个特定节点中的每个 pod 设置的限制kubectl describe node <node>
推荐阅读
- linux - cgdb 向终端产生噪声输出符号
- javascript - 如何在 javascript 函数中设置 request.getSession().setAttribute(obj, obj)
- javascript - 用css和jquery在圆圈中填充颜色的关键帧
- ajax - AJAX 发布到 Razor 页面中的处理函数
- java - 是否可以使用 Java 和 kotlin 来创建 Spring Boot 应用程序?
- html - 图片库过渡时的CSS淡入淡出
- python - 从 HTML 标签 Python/BeautifulSoup 获取第二个元素
- java - 在重复元素程序中遍历循环时出现 N 次问题
- apache - .htaccess 重定向适用于 .html 但不适用于使用 RewriteRule 的 .php
- git - Git 提交会忽略对某些子文件夹的更改。有关如何纠正问题的任何建议?