登录
首页 >  Golang >  Go问答

如何获取 Kubernetes 上 pod 真实的存储使用情况?

来源:stackoverflow

时间:2024-04-05 14:39:37 282浏览 收藏

IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《如何获取 Kubernetes 上 pod 真实的存储使用情况?》,聊聊,我们一起来看看吧!

问题内容

是否有任何直接的方法可以获取 Kubernetes 上 Pod 的实际存储使用情况?

我尝试使用 Prometheus 来实现此目的,但仅公开分配给每个 Pod 的存储量,而不是我的应用程序(Pod)真正消耗的存储量。

我需要一种方法来查看每个 Pod 消耗了多少存储空间并将其报告给 Prometheus 或 Grafana。


解决方案


有一种方法,但可能不是“直接”的方法。 如果 pod 在 linux 中运行,您可以执行:

kubectl exec -it  cat /proc/1/io

它将返回有关主要 io 进程的统计信息。以下是这些内容的描述:

rchar
-----

I/O counter: chars read
The number of bytes which this task has caused to be read from storage. This
is simply the sum of bytes which this process passed to read() and pread().
It includes things like tty IO and it is unaffected by whether or not actual
physical disk IO was required (the read might have been satisfied from
pagecache)


wchar
-----

I/O counter: chars written
The number of bytes which this task has caused, or shall cause to be written
to disk. Similar caveats apply here as with rchar.


read_bytes
----------

I/O counter: bytes read
Attempt to count the number of bytes which this process really did cause to
be fetched from the storage layer. Done at the submit_bio() level, so it is
accurate for block-backed filesystems. 


write_bytes
-----------

I/O counter: bytes written
Attempt to count the number of bytes which this process caused to be sent to
the storage layer. This is done at page-dirtying time.

您还可以获得有关特定容器的磁盘使用情况的信息。已经描述过 here

如果有帮助,请告诉我。

以上就是本文的全部内容了,是否有顺利帮助你解决问题?若是能给你带来学习上的帮助,请大家多多支持golang学习网!更多关于Golang的相关知识,也可关注golang学习网公众号。

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>