How to get the real & actual storage usage of pods on Kubernetes?

7/23/2019

Is there any straight-forward way to get the actual storage usage of pods on Kubernetes?

I've tried to do so using Prometheus, but only the amount of storage allocated to every pod is exposed, not what is really consumed by my application (pods).

I need a way to see how much storage every pod is consuming and reporting that to Prometheus or Grafana.

-- MelDev
go
kubernetes
storage

2 Answers

8/7/2019

this is very tricky, prometheus is scraping some kubelet metrics and just created a grafana dashboard with below parameters and worked : Query : kubelet_volume_stats_used_bytes / kubelet_volume_stats_capacity_bytes * 100 grafana legend : {{ namespace }} | {{ persistentvolumeclaim }}

-- MelDev
Source: StackOverflow

7/23/2019

There is a way but it might not be a 'straight forward' one. If pods are running in Linux you can execute:

kubectl exec -it <pod> cat /proc/1/io

It will return stats regarding the main IO processes. Here is the description of those:

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.

You can also get info regarding disk usage of a particular container. It was already described here.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow