是否有任何简单的方法来获取Kubernetes上Pod的实际存储使用情况?

我尝试使用Prometheus进行此操作,但是仅公开分配给每个Pod的存储量,而不显示应用程序(pod)真正消耗的存储量。

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

最佳答案

有办法,但可能不是“直截了当”的办法。
如果Pod在Linux中运行,则可以执行:

kubectl exec -it <pod> 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. <please add status regarding NFS and
CIFS at a later time>


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

请让我知道是否有帮助。

关于go - 如何获得Kubernetes上Pod的实际和实际存储使用情况?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57159924/

10-17 00:32