I have a GCP Persistent Disk associated with a pod in a GKE cluster. How do I find the disk usage for the persistent disk ? Is there any GCP commands which will be help me find the disk usage ?
Thanks a lot for your answers.
I have a GCP Persistent Disk associated with a pod in a GKE cluster. How do I find the disk usage for the persistent disk ? Is there any GCP commands which will be help me find the disk usage ?
Thanks a lot for your answers.
You cannot see the disk usage via a prepared command. But, you can check it via Stackdriver Monitoring (Google Cloud Operations Suite) with the metric named container/disk/bytes_used
: documentation. You can use Monitoring APIs if you need to automatize it.
Please notice that you must enable Stackdriver on your cluster before. If you haven't, follow the documentation.
TL;DR
You can use the utilization (percentage of used space) of a certain volume mount for a
Pod
with following metric:kubernetes.io/pod/volume/utilization
The description states:
You can use this metric to monitor specific volume mounts that are backed by
Persistent Disk
.Using the
kubernetes.io/pod/volume/utilization
metricAssuming that you have a
GKE
cluster with:PVC
's that are backed byPD
's with100GB
of space eachPods
where each of them is using singlePVC
ubuntu-ten
- where there is 10GB stored on mountedPVC
ubuntu-twenty
- where there is 20GB stored on mountedPVC
ubuntu-thirty
- where there is 30GB stored on mountedPVC
You can follow:
GCP Cloud Console
(Web UI) ->Monitoring
->Metrics explorer
Querying the API
As asked in the comments under another answer:
Yes they are. You can query the monitoring API for data by using
MQL
(Monitoring Query Language).You will need to have query from example used earlier (
volume_utilization
). You can extract such query by going intoQuery Editor
(it's on last image).To query the API you can use
Try this API
feature available inGCP
documentation:Query created with the help of this tool:
In the response you should get the information about the utilization of volumes used by
Pods
.Additional resources: