When comparing the output data from opencost and cloudcost exporter, one bit that didn't quite make sense was a mismatch in PVC's between the two. The total costs between the two was small enough to be insignificant, which only made things more confusing.
After analyzing the metrics further, the biggest difference was the name of the disks. cloudcost-exporter was pulling the name directly from the disk metadata, which was prepending most pv's with gke-$cluster. The problem with this is that kube-state-metrics and other metrics only look at what k8s calls them.
This change updates how name is sourced.
Loads the disk.Description into a map
Check for the existence of two labels
If either keys are found, return the value
Otherwise, fall back to disk.Name as a final resource
When comparing the output data from opencost and cloudcost exporter, one bit that didn't quite make sense was a mismatch in PVC's between the two. The total costs between the two was small enough to be insignificant, which only made things more confusing.
After analyzing the metrics further, the biggest difference was the name of the disks.
cloudcost-exporter
was pulling the name directly from the disk metadata, which was prepending most pv's withgke-$cluster
. The problem with this is thatkube-state-metrics
and other metrics only look at what k8s calls them.This change updates how name is sourced.
disk.Description
into a mapdisk.Name
as a final resource