Is there an efficient way to check the usage for PV/PVC in Kubernetes

12/12/2019

For example, I have 50 Gib PV/PVC and grant to one Pod, I just want to check usage of the storage

The way I am just following is to set up a busybox pod with mounting the same PVC, then exec into the busybox to run df -h to check the storage.

I just want to know if there is an efficient way to do the same thing.

-- Vampire_D
kubernetes
kubernetes-pvc

2 Answers

12/12/2019

Unfortunately we don't have this at the moment. What I often do is querying on Prometheus (because I have a Prom cluster there) for the metrics kubelet_volume_stats_used_bytes for the information.

Or in the harder way, you can write an operator to watch a CRD which wraps the PVC and to display the usage of the PVC.

-- hxquangnhat
Source: StackOverflow

12/12/2019

There are many types of PV-s (e.g. various cloud storage). Each of them might have a different way of getting this information. You could always use kubectl describe pv <pv-name> or kubectl get pv <pv-name> -o yaml. This might give you some information about the current state of the PV, but it might lack the information you need.

I assume though that you are using Local PV-s. In this case your solution to run df -h inside a container is not bad. One other thing you could do is to run this command on the node which hosts the PV directly.

-- Dávid Molnár
Source: StackOverflow