Documentation ¶
Index ¶
Constants ¶
const (
BootDiskLabel = "goog-gke-node"
)
const PriceRefreshInterval = 24 * time.Hour
Variables ¶
var ( GkeClusterLabel = "goog-k8s-cluster-name" GkeRegionLabel = "goog-k8s-cluster-location" )
var ( ErrSkuNotFound = errors.New("no sku was interested in us") ErrSkuIsNil = errors.New("sku is nil") ErrSkuNotParsable = errors.New("can't parse sku") ErrSkuNotRelevant = errors.New("sku isn't relevant for the current use cases") ErrPricingDataIsOff = errors.New("pricing data in sku isn't parsable") ErrRegionNotFound = errors.New("region wasn't found in pricing map") ErrFamilyTypeNotFound = errors.New("family wasn't found in pricing map for this region") ErrInitializingPricingMap = errors.New("failed to populate pricing map") )
var (
ErrListInstances = errors.New("no list price was found for the sku")
)
Functions ¶
Types ¶
type Collector ¶
type Collector struct { Projects []string PricingMap *PricingMap NextScrape time.Time // contains filtered or unexported fields }
func New ¶
func New(config *Config, computeService *compute.Service, billingService *billingv1.CloudCatalogClient) (*Collector, error)
func (*Collector) CollectMetrics ¶
func (c *Collector) CollectMetrics(ch chan<- prometheus.Metric) float64
type Disk ¶
type Disk struct { Cluster string Project string Size int64 // contains filtered or unexported fields }
func (Disk) DiskType ¶
DiskType will search through the labels to determine the type of disk. If the disk has a label "goog-gke-node" it will return "boot_disk" Otherwise it returns persistent_volume
func (Disk) Name ¶
Name will return the name of the disk. If the disk has a label "kubernetes.io/created-for/pv/name" it will return the value stored in that key. otherwise it will return the disk name that is directly associated with the disk.
func (Disk) Namespace ¶
Namespace will search through the description fields for the namespace of the disk. If the namespace can't be determined An empty string is return.
func (Disk) Region ¶
Region will return the region of the disk by search through the zone field and returning the region. If the region can't be determined It will return an empty string
func (Disk) StorageClass ¶
StorageClass will return the storage class of the disk by looking at the type. Type in GCP is represented as a URL and as such we're looking for the last part of the URL to determine the storage class
func (Disk) UseStatus ¶ added in v0.4.10
UseStatus will return two constant strings to tell apart disks that are sitting idle from those that are mounted to a pod It's named UseStatus and not just Status because the GCP API already has a field Status that holds a different concept that we don't want to overwrite. From their docs: Status: [Output Only] The status of disk creation. - CREATING: Disk is provisioning. - RESTORING: Source data is being copied into the disk. - FAILED: Disk creation failed. - READY: Disk is ready for use. - DELETING: Disk is deleting. UNAVAILABLE - Disk is currently unavailable and cannot be accessed,
type FamilyPricing ¶ added in v0.4.9
type FamilyPricing struct {
Family map[string]*PriceTiers
}
FamilyPricing is a map where the key is the family and the value is the price tiers
func NewMachineTypePricing ¶ added in v0.4.9
func NewMachineTypePricing() *FamilyPricing
type MachineSpec ¶ added in v0.4.9
type MachineSpec struct { Instance string Zone string Region string Family string MachineType string SpotInstance bool Labels map[string]string PriceTier string }
MachineSpec is a slimmed down representation of a google compute.Instance struct
func ListInstancesInZone ¶ added in v0.4.9
func ListInstancesInZone(projectID, zone string, c *compute.Service) ([]*MachineSpec, error)
ListInstancesInZone will list all instances in a given zone and return a slice of MachineSpecs
func NewMachineSpec ¶ added in v0.4.9
func NewMachineSpec(instance *compute.Instance) *MachineSpec
NewMachineSpec will create a new MachineSpec from compute.Instance objects. It's responsible for determining the machine family and region that it operates in
func (*MachineSpec) GetClusterName ¶ added in v0.4.9
func (m *MachineSpec) GetClusterName() string
type ParsedSkuData ¶ added in v0.4.9
type ParsedSkuData struct { Region string PriceTier PriceTier Price int32 Description string ComputeResource Resource }
func NewParsedSkuData ¶ added in v0.4.9
type PriceTiers ¶ added in v0.4.9
func NewPriceTiers ¶ added in v0.4.9
func NewPriceTiers() *PriceTiers
type PricingMap ¶ added in v0.4.9
type PricingMap struct { Compute map[string]*FamilyPricing Storage map[string]*StoragePricing }
PricingMap is a map of regions to a map of family to price tiers
func GeneratePricingMap ¶ added in v0.4.9
func GeneratePricingMap(skus []*billingpb.Sku) (*PricingMap, error)
Paula: deprecate this function in favour of func (pm *PricingMap) Populate(skus []*billingpb.Sku) (*PricingMap, error)
func NewComputePricingMap ¶ added in v0.4.9
func NewComputePricingMap() *PricingMap
NewComputePricingMap returns a new PricingMap in a way that can be used afterwards.
func NewPricingMap ¶ added in v0.4.9
func NewPricingMap(ctx context.Context, billingService *billingv1.CloudCatalogClient) (*PricingMap, error)
NewPricingMap returns a new PricingMap in a way that can be used afterwards.
func (PricingMap) GetCostOfInstance ¶ added in v0.4.9
func (m PricingMap) GetCostOfInstance(instance *MachineSpec) (float64, float64, error)
func (PricingMap) GetCostOfStorage ¶ added in v0.4.9
func (m PricingMap) GetCostOfStorage(region, storageClass string) (float64, error)
func (*PricingMap) Populate ¶ added in v0.4.9
func (pm *PricingMap) Populate(ctx context.Context, billingService *billingv1.CloudCatalogClient) error
type StoragePricing ¶ added in v0.4.9
StoragePricing is a map where the key is the storage type and the value is the price
func NewStoragePricing ¶ added in v0.4.9
func NewStoragePricing() *StoragePricing