- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
给定一个 kubernetes 集群:
container_memory_usage_bytes
但选择
deployment_name
而不是
pod
.
container_memory_usage_bytes{pod_name=~"foo-.+"}
如果
deployment_name=foo
只要没有部署
deployment_name=foo-bar
就很好.
kube_pod_container_resource_limits_memory_bytes
实现同样的目标.
最佳答案
TL;DR
没有通过 deployment-name
查询普罗米修斯的直接方法。
您可以使用部署的标签查询特定部署的内存使用情况。
使用的查询:
sum(
kube_pod_labels{label_app=~"ubuntu.*"} * on (pod) group_right(label_app) container_memory_usage_bytes{namespace="memory-testing", container=""}
)
by (label_app)
有一篇很棒的文章解释了这个查询背后的概念。我鼓励你阅读它:
container_memory_usage_bytes{pod_name=~"foo-.+"}
.+
- match any string but not an empty string
foo-12345678-abcde
- 将匹配 (部署 foo
)foo-deployment-98765432-zyxzy
- 将匹配 (部署 foo-deployment
)memory-testing
命名空间中有 2 个部署:ubuntu
ubuntu-additional
app: ubuntu
app: ubuntu-additional
1.18.X
Why do I specify Kubernetes version?
Kubernetes 1.16 will remove the duplicate
pod_name
andcontainer_name
metric labels from cAdvisor metrics. For the 1.14 and 1.15 release allpod
,pod_name
,container
andcontainer_name
were available as a grace period.
Github.com: Kubernetes: Metrics Overhaul
这意味着您需要替换如下参数:
pod
和pod_name
container
和container_name
部署 Prometheus 和其他工具来监控我使用的集群: Github.com: Coreos: Kube-prometheusubuntu
部署中的 pod 被配置为生成人工负载(stress-ng
)。这样做是为了展示如何避免所用资源翻倍的情况。memory-testing
命名空间中 pod 使用的资源:
如果您要使用以下查询查询 Prometheus:$ kubectl top pod --namespace=memory-testing
NAME CPU(cores) MEMORY(bytes)
ubuntu-5b5d6c56f6-cfr9g 816m 280Mi
ubuntu-5b5d6c56f6-g6vh9 834m 278Mi
ubuntu-5b5d6c56f6-sxldj 918m 288Mi
ubuntu-additional-84bdf9b7fb-b9pxm 0m 0Mi
ubuntu-additional-84bdf9b7fb-dzt72 0m 0Mi
ubuntu-additional-84bdf9b7fb-k5z6w 0m 0Mi您将获得类似于下面的输出(出于示例目的,它被剪切为仅显示一个 pod,默认情况下,它将显示名称和container_memory_usage_bytes{namespace="memory-testing", pod=~"ubuntu.*"}
ubuntu
命名空间中带有memory-testing
的所有 pod):在这一点上,您需要选择将使用的指标。在这个例子中,我使用了第一个。如需深入了解,请查看以下文章:container_memory_usage_bytes{endpoint="https-metrics",id="/kubepods/besteffort/podb96dea39-b388-471e-a789-8c74b1670c74",instance="192.168.0.117:10250",job="kubelet",metrics_path="/metrics/cadvisor",namespace="memory-testing",node="node1",pod="ubuntu-5b5d6c56f6-cfr9g",service="kubelet"} 308559872
container_memory_usage_bytes{container="POD",endpoint="https-metrics",id="/kubepods/besteffort/podb96dea39-b388-471e-a789-8c74b1670c74/312980f90e6104d021c12c376e83fe2bfc524faa4d4cee6553182d0fa2e007a1",image="k8s.gcr.io/pause:3.2",instance="192.168.0.117:10250",job="kubelet",metrics_path="/metrics/cadvisor",name="k8s_POD_ubuntu-5b5d6c56f6-cfr9g_memory-testing_b96dea39-b388-471e-a789-8c74b1670c74_0",namespace="memory-testing",node="node1",pod="ubuntu-5b5d6c56f6-cfr9g",service="kubelet"} 782336
container_memory_usage_bytes{container="ubuntu",endpoint="https-metrics",id="/kubepods/besteffort/podb96dea39-b388-471e-a789-8c74b1670c74/1b93889a3e7415ad3fa040daf89f3f6bc77e569d85069de518267666ede8e21c",image="ubuntu@sha256:55cd38b70425947db71112eb5dddfa3aa3e3ce307754a3df2269069d2278ce47",instance="192.168.0.117:10250",job="kubelet",metrics_path="/metrics/cadvisor",name="k8s_ubuntu_ubuntu-5b5d6c56f6-cfr9g_memory-testing_b96dea39-b388-471e-a789-8c74b1670c74_0",namespace="memory-testing",node="node1",pod="ubuntu-5b5d6c56f6-cfr9g",service="kubelet"} 307777536
Blog.freshtracks.io: A deep dive into kubernetes metrics part 3 container resource metrics Ianlewis.org: Almighty pause container
如果我们使用sum (QUERY) by (pod)
汇总这些指标,我们实际上会将报告的已用资源翻倍。
剖析主查询:以上查询将输出每个 pod 的已用内存指标记录。container_memory_usage_bytes{namespace="memory-testing", container=""}
container=""
参数用于仅获取一条没有container
参数的记录(前面提到过)。上面的查询将输出带有 pods 的记录及其带有kube_pod_labels{label_app=~"ubuntu.*"}
ubuntu.*
正则表达式的标签以上查询将kube_pod_labels{label_app=~"ubuntu.*"} * on (pod) group_right(label_app) container_memory_usage_bytes{namespace="memory-testing", container=""}
pod
中的kube_pod_labels
与pod
中的container_memory_usage_bytes
进行匹配,并将label_app
添加到每条记录中。上面的查询将通过sum (kube_pod_labels{label_app=~"ubuntu.*"} * on (pod) group_right(label_app) container_memory_usage_bytes{namespace="memory-testing", container=""}) by (label_app)
label_app
对记录求和。
之后,您应该能够通过标签(实际上是部署)获取将使用的内存相加的查询。
至于:
The same I'd like to achieve with the metric
kube_pod_container_resource_limits_memory_bytes
.
假设部署中的每个 pod 具有相同的限制,您可以使用以下查询获取标记有标签的部署的内存限制,如上例所示:您可以在此查询上应用kube_pod_labels{label_app="ubuntu-with-limits"} * on (pod) group_right(label_app) kube_pod_container_resource_limits_memory_bytes{namespace="memory-testing", pod=~".*"}
avg()
、mean()
、max()
等函数来获取将成为您的内存限制的单个数字:如果您使用avg(kube_pod_labels{label_app="ubuntu-with-limits"} * on (pod) group_right(label_app) kube_pod_container_resource_limits_memory_bytes{namespace="memory-testing", pod=~".*"}) by (label_app)
VPA
,您的内存限制可能会有所不同。在这种情况下,您可以同时显示所有这些或使用avg()
来获得所有“部署”的平均值。
作为上述解决方案的 解决方法 ,您可以尝试使用如下正则表达式:container_memory_usage_bytes{pod=~"^ubuntu-.{6,10}-.{5}"}
关于kubernetes - container_memory_usage_bytes 按部署名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62677636/
我在 *.sql 文件中得到了我的数据库转储(表、函数、触发器等)。此时我正在通过 jenkins 部署它们,通过传递执行 shell 命令: sudo -u postgres psql -d my_
我正在使用网络部署 API 来部署网络包(.zip 文件,由 MSDeploy.exe 创建)以编程方式将包发布到服务器(在发布包之前我们需要做一些其他事情这就是为什么我们不使用 MSDeploy.e
我们正在使用 Web Deploy 3 的(几乎完全未记录的)“公共(public) API”来创建我们网站的 .zip 包,然后将其同步到服务器: DeploymentBaseOptions des
将 clojure 应用程序制作成可执行文件的最简单方法是什么,例如 http://rawr.rubyforge.org/ ruby 吗? (exe 和 app 文件也是) 最佳答案 使用 leini
是否可以下载 Android 源代码并针对任何设备进行编译? 我想做的是尝试 GSM 代码部分并编译操作系统并将其部署到我的摩托罗拉手机上。 谢谢! 最佳答案 是的,但这很难,因为大多数手机不共享驱动
我正在考虑用 c/c++ 编写需要在大多数个人计算机上运行的 nbody 样式模拟。本质上是一个 O(n^2) 粒子模拟器。 因为这需要相当用户友好,所以我希望有 1 个不需要用户安装任何东西的 Wi
需要了解 kubernetes 部署中 kube_deployment_status_replicas 和 kube_deployment_spec_replicas 指标的区别 最佳答案 简而言之,
我正在尝试使用分类器部署 Maven Artifact 。由于我需要源代码和 JAR(我从 GWT 使用它),我想获得 artifact-version-classifier.jar 和 artifa
我设置部署以将我的项目代码与存储我的网站的 FTP 服务器上的项目同步。 但是,每次尝试同步时,我总是必须登录。 我什至检查了记住,但它不起作用! 我正在使用最新的 PhpStorm 2017.1.4
我在 Visual Studio 2008 中开发了一个 ASP.NET 网站。现在我想在其他机器上部署它。我怎样才能做到这一点??就像我们为 Windows 应用程序制作安装包一样,我们可以为 AS
将 QT 框架添加到我的 .app 包中 我正在关注 Qt 站点上关于部署的文档。 我创建了一个名为 HTTPClient.app 的应用程序 我在 Contents 下创建了 Framework 文
这个问题不太可能对任何 future 的访客有帮助;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛适用,visit the h
我正在研究改变我目前创建营销网站的策略。目前,我完全用 PHP 从头开始构建网站,使用一个简单的包含系统。所有代码(以及内容)都存储在文件(而不是数据库)中,允许我使用 Subversion 进行
我有一个长期运行的服务(在 while 1 循环中)并通过 GCloud pub/sub 处理有效负载,之后它将结果写入数据库。 该服务不需要监听任何端口。 Kind=Deployment 的声明性
似乎部署已停滞不前。我该如何进一步诊断? kubectl rollout status deployment/wordpress Waiting for rollout to finish: 2 ou
我正在Dart中使用前端的Angular和后端的Shelf构建一个客户端/服务器应用程序。当我执行pub build时,它会按预期生成Dart文件的javascript,但不会替换HTML文件中的Da
我在 Azure 部署中心的下拉列表中看不到我的所有 Github 组织存储库。 Azure 很久以前就已经被授权了,下拉列表正确地显示了所有的存储库,直到上周我在 DevOps 中玩游戏时,不得不再
我认为标题几乎说明了一切...对于 Deployd 来说是全新的,所以任何关于如何最好地实现这一点的指示都值得赞赏。 最佳答案 要获取用户创建的集合中的对象(我假设您使用的是 javascript 库
我有一个试图用于CD服务器的部署脚本,但是在编写bash脚本以完成一些所需的步骤(例如运行npm和迁移命令)时遇到了问题。 我将如何从该脚本进入容器bash,运行下面的命令,然后退出以完成对更改的提取
我想在使用 kubectl 时将参数传递给 Kubernetes 部署命令应用部署文件。 示例:在我的部署 .yaml 中,我有如下参数,我想在使用 kubectl apply - f .yaml 运
我是一名优秀的程序员,十分优秀!