This is a simple metrics exporter for the local-path-provisioner or any hostPath
typed PersistentVolumes that share the same provisioned path on the hosts. It generates local_volume_stats_capacity_bytes
and local_volume_stats_used_bytes
metrics for the persistent volumes PV
based on the hostPath
solution.
Easy deployment of local-path-provisioner made it one of the most popular dynamic PV provisioning tool, especially used in the dev environment. Since the local-path-provisioner is a hostPath-based
solution, It does not support any integrations to generate metrics such as kubelet_volume_stats_used_bytes
or kubelet_volume_stats_capacity_bytes
. Some use cases and warnings for the hostPath
solution are listed on the kubernetes documentation. But since the local-path-provisioner provides a dynamic provisioning solution it is a good alternative for development and testing environments in which data loss can be tolerated.
Another alternative is local
typed ones, but there are some limitations to using local
type volumes too as stated in sig-storage-local-static-provisioner best practices. So unless we have separate partitions for each PV, we cannot use the metrics kubelet_volume_stats.*
because it will show the total capacity and used bytes of the whole partition, not the PV. Also, It does not support dynamic provisioning
, and that's another critical point for development and testing environments.
We have two main components in this solution:
The first one is the lp-exporter
which talks to the API Server to get PVC names that used local-path storage class and requested capacities of them respectively. It generates local_volume_stats_capacity_bytes
metrics and pushes it to pushgateway. To get the used bytes per PV, it generates a job
for each different node that PVs are provisioned.
Job consists of a simple python code block to get used bytes for each PVs that are provisioned on that node and it pushes the local_volume_stats_used_bytes
metrics to the pushgateway.
Simple Illustration of the architecture
Take a look grafana dashboard examples and alert examples rules.
For deployment and usage, please take a look at the deployment page.
Some known issues are listed in the issues page.
This is not an official solution. It is just a simple solution to generate metrics for local-path-provisioner by using prometheus/kubernetes python clients and prometheus pushgateway. It is not tested in a production environment.