Documentation
¶
Index ¶
- Constants
- func ConvertBigQueryConfigToConfig(bqc BigQueryConfig) config.KeyedConfig
- func IsK8s(labels map[string]string) bool
- func ParseGCPProjectID(id string) string
- func ParseProviderID(id string) string
- func SelectCategory(service, description string) string
- type Authorizer
- type BigQueryConfig
- type BigQueryConfiguration
- func (bqc *BigQueryConfiguration) Equals(config config.Config) bool
- func (bqc *BigQueryConfiguration) GetBigQueryClient(ctx context.Context) (*bigquery.Client, error)
- func (bqc *BigQueryConfiguration) GetBillingDataDataset() string
- func (bqc *BigQueryConfiguration) Key() string
- func (bqc *BigQueryConfiguration) Sanitize() config.Config
- func (bqc *BigQueryConfiguration) UnmarshalJSON(b []byte) error
- func (bqc *BigQueryConfiguration) Validate() error
- type BigQueryIntegration
- type BigQueryQuerier
- type CloudCostLoader
- type GCP
- func (gcp *GCP) AllNodePricing() (interface{}, error)
- func (gcp *GCP) ApplyReservedInstancePricing(nodes map[string]*models.Node)
- func (gcp *GCP) ClusterInfo() (map[string]string, error)
- func (gcp *GCP) ClusterManagementPricing() (string, float64, error)
- func (gcp *GCP) CombinedDiscountForNode(instanceType string, isPreemptible bool, ...) float64
- func (gcp *GCP) DownloadPricingData() error
- func (gcp *GCP) GetAddresses() ([]byte, error)
- func (gcp *GCP) GetConfig() (*models.CustomPricing, error)
- func (gcp *GCP) GetDisks() ([]byte, error)
- func (gcp *GCP) GetKey(labels map[string]string, n *v1.Node) models.Key
- func (gcp *GCP) GetLocalStorageQuery(window, offset time.Duration, rate bool, used bool) string
- func (gcp *GCP) GetManagementPlatform() (string, error)
- func (gcp *GCP) GetOrphanedResources() ([]models.OrphanedResource, error)
- func (gcp *GCP) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey
- func (gcp *GCP) LoadBalancerPricing() (*models.LoadBalancer, error)
- func (gcp *GCP) NetworkPricing() (*models.Network, error)
- func (gcp *GCP) NodePricing(key models.Key) (*models.Node, error)
- func (gcp *GCP) PVPricing(pvk models.PVKey) (*models.PV, error)
- func (gcp *GCP) PricingSourceStatus() map[string]*models.PricingSource
- func (gcp *GCP) PricingSourceSummary() interface{}
- func (gcp *GCP) Regions() []string
- func (gcp *GCP) ServiceAccountStatus() *models.ServiceAccountStatus
- func (gcp *GCP) UpdateConfig(r io.Reader, updateType string) (*models.CustomPricing, error)
- func (gcp *GCP) UpdateConfigFromConfigMap(a map[string]string) (*models.CustomPricing, error)
- type GCPPricing
- type GCPReservedCounter
- type GCPReservedInstance
- type GCPReservedInstancePlan
- type GCPResourceInfo
- type PricingExpression
- type PricingInfo
- type ServiceAccountKey
- func (gkc *ServiceAccountKey) CreateGCPClientOptions() ([]option.ClientOption, error)
- func (gkc *ServiceAccountKey) Equals(config config.Config) bool
- func (gkc *ServiceAccountKey) MarshalJSON() ([]byte, error)
- func (gkc *ServiceAccountKey) Sanitize() config.Config
- func (gkc *ServiceAccountKey) Validate() error
- type TieredRates
- type UnitPriceInfo
- type WorkloadIdentity
- func (wi *WorkloadIdentity) CreateGCPClientOptions() ([]option.ClientOption, error)
- func (wi *WorkloadIdentity) Equals(config config.Config) bool
- func (wi *WorkloadIdentity) MarshalJSON() ([]byte, error)
- func (wi *WorkloadIdentity) Sanitize() config.Config
- func (wi *WorkloadIdentity) Validate() error
Constants ¶
const ( UsageDateColumnName = "usage_date" BillingAccountIDColumnName = "billing_id" ProjectIDColumnName = "project_id" ServiceDescriptionColumnName = "service" SKUDescriptionColumnName = "description" LabelsColumnName = "labels" ResourceNameColumnName = "resource" CostColumnName = "cost" CreditsColumnName = "credits" )
const ( GCPHourlyPublicIPCost = 0.01 GCPMonthlyBasicDiskCost = 0.04 GCPMonthlySSDDiskCost = 0.17 GCPMonthlyGP2DiskCost = 0.1 GKEPreemptibleLabel = "cloud.google.com/gke-preemptible" GKESpotLabel = "cloud.google.com/gke-spot" )
const ( GCPReservedInstanceResourceTypeRAM string = "MEMORY" GCPReservedInstanceResourceTypeCPU string = "VCPU" GCPReservedInstanceStatusActive string = "ACTIVE" GCPReservedInstancePlanOneYear string = "TWELVE_MONTH" GCPReservedInstancePlanThreeYear string = "THIRTY_SIX_MONTH" )
const BigqueryUpdateType = "bigqueryupdate"
const BiqQueryWhereDateFmt = `usage_start_time >= "%s" AND usage_start_time < "%s"`
const BiqQueryWherePartitionFmt = `DATE(_PARTITIONTIME) >= "%s" AND DATE(_PARTITIONTIME) < "%s"`
const GKE_GPU_TAG = "cloud.google.com/gke-accelerator"
const ServiceAccountKeyAuthorizerType = "GCPServiceAccountKey"
const WorkloadIdentityAuthorizerType = "GCPWorkloadIdentity"
Variables ¶
This section is empty.
Functions ¶
func ConvertBigQueryConfigToConfig ¶
func ConvertBigQueryConfigToConfig(bqc BigQueryConfig) config.KeyedConfig
func ParseGCPProjectID ¶
func ParseProviderID ¶
func SelectCategory ¶
Types ¶
type Authorizer ¶
type Authorizer interface {
config.Authorizer
CreateGCPClientOptions() ([]option.ClientOption, error)
}
Authorizer provide a []option.ClientOption which is used in when creating clients in the GCP SDK
func SelectAuthorizerByType ¶
func SelectAuthorizerByType(typeStr string) (Authorizer, error)
SelectAuthorizerByType is an implementation of AuthorizerSelectorFn and acts as a register for Authorizer types
type BigQueryConfig ¶
type BigQueryConfig struct {
ProjectID string `json:"projectID"`
BillingDataDataset string `json:"billingDataDataset"`
Key map[string]string `json:"key"`
}
BigQueryConfig contain the required config and credentials to access OOC resources for GCP Deprecated: v1.104 Use BigQueryConfiguration instead
func (*BigQueryConfig) IsEmpty ¶
func (bqc *BigQueryConfig) IsEmpty() bool
IsEmpty returns true if all fields in config are empty, false if not.
type BigQueryConfiguration ¶
type BigQueryConfiguration struct {
ProjectID string `json:"projectID"`
Dataset string `json:"dataset"`
Table string `json:"table"`
Authorizer Authorizer `json:"authorizer"`
}
func (*BigQueryConfiguration) Equals ¶
func (bqc *BigQueryConfiguration) Equals(config config.Config) bool
func (*BigQueryConfiguration) GetBigQueryClient ¶
func (*BigQueryConfiguration) GetBillingDataDataset ¶
func (bqc *BigQueryConfiguration) GetBillingDataDataset() string
func (*BigQueryConfiguration) Key ¶
func (bqc *BigQueryConfiguration) Key() string
Key uses the Usage Project Id as the Provider Key for GCP
func (*BigQueryConfiguration) Sanitize ¶
func (bqc *BigQueryConfiguration) Sanitize() config.Config
func (*BigQueryConfiguration) UnmarshalJSON ¶
func (bqc *BigQueryConfiguration) UnmarshalJSON(b []byte) error
UnmarshalJSON assumes data is save as an BigQueryConfigurationDTO
func (*BigQueryConfiguration) Validate ¶
func (bqc *BigQueryConfiguration) Validate() error
type BigQueryIntegration ¶
type BigQueryIntegration struct {
BigQueryQuerier
}
func (*BigQueryIntegration) GetCloudCost ¶
func (bqi *BigQueryIntegration) GetCloudCost(start time.Time, end time.Time) (*kubecost.CloudCostSetRange, error)
type BigQueryQuerier ¶
type BigQueryQuerier struct {
BigQueryConfiguration
ConnectionStatus cloud.ConnectionStatus
}
func (*BigQueryQuerier) Equals ¶
func (bqq *BigQueryQuerier) Equals(config cloudconfig.Config) bool
func (*BigQueryQuerier) Query ¶
func (bqq *BigQueryQuerier) Query(ctx context.Context, queryStr string) (*bigquery.RowIterator, error)
type CloudCostLoader ¶
type GCP ¶
type GCP struct {
Pricing map[string]*GCPPricing
Clientset clustercache.ClusterCache
APIKey string
BaseCPUPrice string
ProjectID string
BillingDataDataset string
DownloadPricingDataLock sync.RWMutex
ReservedInstances []*GCPReservedInstance
Config models.ProviderConfig
ServiceKeyProvided bool
ValidPricingKeys map[string]bool
MetadataClient *metadata.Client
ClusterRegion string
ClusterAccountID string
ClusterProjectID string
// contains filtered or unexported fields
}
GCP implements a provider interface for GCP
func (*GCP) AllNodePricing ¶
AllNodePricing returns the GCP pricing objects stored
func (*GCP) ApplyReservedInstancePricing ¶
func (*GCP) ClusterInfo ¶
ClusterInfo returns information on the GKE cluster, as provided by metadata.
func (*GCP) ClusterManagementPricing ¶
func (*GCP) CombinedDiscountForNode ¶
func (*GCP) DownloadPricingData ¶
DownloadPricingData fetches data from the GCP Pricing API. Requires a key-- a kubecost key is provided for quickstart, but should be replaced by a users.
func (*GCP) GetAddresses ¶
func (*GCP) GetDisks ¶
GetDisks returns the GCP disks backing PVs. Useful because sometimes k8s will not clean up PVs correctly. Requires a json config in /var/configs with key region.
func (*GCP) GetLocalStorageQuery ¶
GetLocalStorageQuery returns the cost of local storage for the given window. Setting rate=true returns hourly spend. Setting used=true only tracks used storage, not total.
func (*GCP) GetManagementPlatform ¶
func (*GCP) GetOrphanedResources ¶
func (gcp *GCP) GetOrphanedResources() ([]models.OrphanedResource, error)
func (*GCP) LoadBalancerPricing ¶
func (gcp *GCP) LoadBalancerPricing() (*models.LoadBalancer, error)
func (*GCP) NetworkPricing ¶
Stubbed NetworkPricing for GCP. Pull directly from gcp.json for now
func (*GCP) NodePricing ¶
NodePricing returns GCP pricing data for a single node
func (*GCP) PricingSourceStatus ¶
func (gcp *GCP) PricingSourceStatus() map[string]*models.PricingSource
func (*GCP) PricingSourceSummary ¶
func (gcp *GCP) PricingSourceSummary() interface{}
PricingSourceSummary returns the pricing source summary for the provider. The summary represents what was _parsed_ from the pricing source, not everything that was _available_ in the pricing source.
func (*GCP) ServiceAccountStatus ¶
func (gcp *GCP) ServiceAccountStatus() *models.ServiceAccountStatus
func (*GCP) UpdateConfig ¶
func (*GCP) UpdateConfigFromConfigMap ¶
type GCPPricing ¶
type GCPPricing struct {
Name string `json:"name"`
SKUID string `json:"skuId"`
Description string `json:"description"`
Category *GCPResourceInfo `json:"category"`
ServiceRegions []string `json:"serviceRegions"`
PricingInfo []*PricingInfo `json:"pricingInfo"`
ServiceProviderName string `json:"serviceProviderName"`
Node *models.Node `json:"node"`
PV *models.PV `json:"pv"`
}
GCPPricing represents GCP pricing data for a SKU
type GCPReservedCounter ¶
type GCPReservedCounter struct {
RemainingCPU int64
RemainingRAM int64
Instance *GCPReservedInstance
}
type GCPReservedInstance ¶
type GCPReservedInstance struct {
ReservedRAM int64
ReservedCPU int64
Plan *GCPReservedInstancePlan
StartDate time.Time
EndDate time.Time
Region string
}
func (*GCPReservedInstance) String ¶
func (r *GCPReservedInstance) String() string
type GCPReservedInstancePlan ¶
type GCPResourceInfo ¶
type GCPResourceInfo struct {
ServiceDisplayName string `json:"serviceDisplayName"`
ResourceFamily string `json:"resourceFamily"`
ResourceGroup string `json:"resourceGroup"`
UsageType string `json:"usageType"`
}
GCPResourceInfo contains metadata about the node.
type PricingExpression ¶
type PricingExpression struct {
UsageUnit string `json:"usageUnit"`
UsageUnitDescription string `json:"usageUnitDescription"`
BaseUnit string `json:"baseUnit"`
BaseUnitConversionFactor int64 `json:"-"`
DisplayQuantity int `json:"displayQuantity"`
TieredRates []*TieredRates `json:"tieredRates"`
}
PricingExpression contains metadata about a cost.
type PricingInfo ¶
type PricingInfo struct {
Summary string `json:"summary"`
PricingExpression *PricingExpression `json:"pricingExpression"`
CurrencyConversionRate float64 `json:"currencyConversionRate"`
EffectiveTime string `json:""`
}
PricingInfo contains metadata about a cost.
type ServiceAccountKey ¶
func (*ServiceAccountKey) CreateGCPClientOptions ¶
func (gkc *ServiceAccountKey) CreateGCPClientOptions() ([]option.ClientOption, error)
func (*ServiceAccountKey) MarshalJSON ¶
func (gkc *ServiceAccountKey) MarshalJSON() ([]byte, error)
MarshalJSON custom json marshalling functions, sets properties as tagged in struct and sets the authorizer type property
func (*ServiceAccountKey) Sanitize ¶
func (gkc *ServiceAccountKey) Sanitize() config.Config
func (*ServiceAccountKey) Validate ¶
func (gkc *ServiceAccountKey) Validate() error
type TieredRates ¶
type TieredRates struct {
StartUsageAmount int `json:"startUsageAmount"`
UnitPrice *UnitPriceInfo `json:"unitPrice"`
}
TieredRates contain data about variable pricing.
type UnitPriceInfo ¶
type UnitPriceInfo struct {
CurrencyCode string `json:"currencyCode"`
Units string `json:"units"`
Nanos float64 `json:"nanos"`
}
UnitPriceInfo contains data about the actual price being charged.
type WorkloadIdentity ¶
type WorkloadIdentity struct{}
WorkloadIdentity passes an empty slice of client options which causes the GCP SDK to check for the workload identity in the environment
func (*WorkloadIdentity) CreateGCPClientOptions ¶
func (wi *WorkloadIdentity) CreateGCPClientOptions() ([]option.ClientOption, error)
func (*WorkloadIdentity) MarshalJSON ¶
func (wi *WorkloadIdentity) MarshalJSON() ([]byte, error)
MarshalJSON custom json marshalling functions, sets properties as tagged in struct and sets the authorizer type property
func (*WorkloadIdentity) Sanitize ¶
func (wi *WorkloadIdentity) Sanitize() config.Config
func (*WorkloadIdentity) Validate ¶
func (wi *WorkloadIdentity) Validate() error