How to identify the storage space left in a persis

2020-05-30 04:04发布

I have a Kubernetes cluster on Google Cloud Platform. It has a persistent Volume Claim with a Capacity of 1GB. The persistent volume claim is bound to many deployments.

I would like to identify the space left in the persistent Volume Claim in order to know if 1GB is sufficient for my application.

I have used the command "kubectl get pv" but this does not show the storage space left.

3条回答
啃猪蹄的小仙女
2楼-- · 2020-05-30 04:32

You can monitorize them with kubelet prometheus metrics:

kubelet_volume_stats_available_bytes{persistentvolumeclaim="your-pvc"}
kubelet_volume_stats_capacity_bytes{persistentvolumeclaim="your-pvc"}
查看更多
狗以群分
3楼-- · 2020-05-30 04:34

If there's a running pod with mounted PV from the PVC,

kubectl -n <namespace> exec <pod-name> df

...will list all file systems, including the mounted volumes, and their free disk space.

查看更多
forever°为你锁心
4楼-- · 2020-05-30 04:37

I wrote a script that lists all the PVCs in a cluster in a format similar to df.

It requires kubectl proxy to be running.

You can run it via:

./kubedf

or:

./kubedf -h

for a human readable output.

查看更多
登录 后发表回答