Documentation ¶
Index ¶
- func AllocateIdleByDefault(p models.Provider) bool
- func ClusterName(p models.Provider) string
- func ConfigWatcherFor(p models.Provider) *watcher.ConfigMapWatcher
- func CustomPricesEnabled(p models.Provider) bool
- func DefaultPricing() *models.CustomPricing
- func GetCsv(location string) (io.Reader, error)
- func NewProvider(cache clustercache.ClusterCache, apiKey string, ...) (models.Provider, error)
- func NodeValueFromMapField(m string, n *v1.Node, useRegion bool) string
- func PVValueFromMapField(m string, n *v1.PersistentVolume) string
- func ParseID(id string) string
- func ParseLBID(id string) string
- func ParsePVID(id string) string
- func ReturnPricingFromConfigs(filename string) (*models.CustomPricing, error)
- func ShareTenancyCosts(p models.Provider) bool
- func SharedLabels(p models.Provider) ([]string, []string)
- func SharedNamespaces(p models.Provider) []string
- type CSVProvider
- func (*CSVProvider) ClusterManagementPricing() (string, float64, error)
- func (c *CSVProvider) CombinedDiscountForNode(instanceType string, isPreemptible bool, ...) float64
- func (c *CSVProvider) DownloadPricingData() error
- func (c *CSVProvider) GetKey(l map[string]string, n *v1.Node) models.Key
- func (c *CSVProvider) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey
- func (c *CSVProvider) NodePricing(key models.Key) (*models.Node, models.PricingMetadata, error)
- func (c *CSVProvider) PVPricing(pvk models.PVKey) (*models.PV, error)
- func (c *CSVProvider) PricingSourceSummary() interface{}
- func (c *CSVProvider) Regions() []string
- func (c *CSVProvider) ServiceAccountStatus() *models.ServiceAccountStatus
- type CustomProvider
- func (cp *CustomProvider) AllNodePricing() (interface{}, error)
- func (*CustomProvider) ApplyReservedInstancePricing(nodes map[string]*models.Node)
- func (cp *CustomProvider) ClusterInfo() (map[string]string, error)
- func (*CustomProvider) ClusterManagementPricing() (string, float64, error)
- func (cp *CustomProvider) CombinedDiscountForNode(instanceType string, isPreemptible bool, ...) float64
- func (cp *CustomProvider) DownloadPricingData() error
- func (*CustomProvider) ExternalAllocations(start string, end string, aggregator []string, filterType string, ...) ([]*models.OutOfClusterAllocation, error)
- func (*CustomProvider) GetAddresses() ([]byte, error)
- func (cp *CustomProvider) GetConfig() (*models.CustomPricing, error)
- func (*CustomProvider) GetDisks() ([]byte, error)
- func (cp *CustomProvider) GetKey(labels map[string]string, n *v1.Node) models.Key
- func (*CustomProvider) GetLocalStorageQuery(window, offset time.Duration, rate bool, used bool) string
- func (*CustomProvider) GetManagementPlatform() (string, error)
- func (*CustomProvider) GetOrphanedResources() ([]models.OrphanedResource, error)
- func (*CustomProvider) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey
- func (cp *CustomProvider) LoadBalancerPricing() (*models.LoadBalancer, error)
- func (cp *CustomProvider) NetworkPricing() (*models.Network, error)
- func (cp *CustomProvider) NodePricing(key models.Key) (*models.Node, models.PricingMetadata, error)
- func (cp *CustomProvider) PVPricing(pvk models.PVKey) (*models.PV, error)
- func (cp *CustomProvider) PricingSourceStatus() map[string]*models.PricingSource
- func (cp *CustomProvider) PricingSourceSummary() interface{}
- func (*CustomProvider) QuerySQL(query string) ([]byte, error)
- func (cp *CustomProvider) Regions() []string
- func (cp *CustomProvider) ServiceAccountStatus() *models.ServiceAccountStatus
- func (cp *CustomProvider) UpdateConfig(r io.Reader, updateType string) (*models.CustomPricing, error)
- func (cp *CustomProvider) UpdateConfigFromConfigMap(a map[string]string) (*models.CustomPricing, error)
- type NodePrice
- type ProviderConfig
- func (pc *ProviderConfig) ConfigFileManager() *config.ConfigFileManager
- func (pc *ProviderConfig) GetCustomPricingData() (*models.CustomPricing, error)
- func (pc *ProviderConfig) Update(updateFunc func(*models.CustomPricing) error) (*models.CustomPricing, error)
- func (pc *ProviderConfig) UpdateFromMap(a map[string]string) (*models.CustomPricing, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateIdleByDefault ¶
AllocateIdleByDefault returns true if the application settings specify to allocate idle by default
func ClusterName ¶
ClusterName returns the name defined in cluster info, defaulting to the CLUSTER_ID environment variable
func ConfigWatcherFor ¶
func ConfigWatcherFor(p models.Provider) *watcher.ConfigMapWatcher
ConfigWatcherFor returns a new ConfigWatcher instance which watches changes to the "pricing-configs" configmap
func CustomPricesEnabled ¶
CustomPricesEnabled returns the boolean equivalent of the cloup provider's custom prices flag, indicating whether or not the cluster is using custom pricing.
func DefaultPricing ¶
func DefaultPricing() *models.CustomPricing
DefaultPricing should be returned so we can do computation even if no file is supplied.
func NewProvider ¶
func NewProvider(cache clustercache.ClusterCache, apiKey string, config *config.ConfigFileManager) (models.Provider, error)
NewProvider looks at the nodespec or provider metadata server to decide which provider to instantiate.
func NodeValueFromMapField ¶
func PVValueFromMapField ¶
func PVValueFromMapField(m string, n *v1.PersistentVolume) string
func ParseID ¶
ParseID attempts to parse a ProviderId from a string based on formats from the various providers and returns the string as is if it cannot find a match
func ParseLBID ¶
ParseLBID attempts to parse a LB ProviderId from a string based on formats from the various providers and returns the string as is if it cannot find a match
func ParsePVID ¶
ParsePVID attempts to parse a PV ProviderId from a string based on formats from the various providers and returns the string as is if it cannot find a match
func ReturnPricingFromConfigs ¶
func ReturnPricingFromConfigs(filename string) (*models.CustomPricing, error)
ReturnPricingFromConfigs is a safe function to return pricing from configs of opensource to the closed source before defaulting it with the above function DefaultPricing
func ShareTenancyCosts ¶
ShareTenancyCosts returns true if the application settings specify to share tenancy costs by default.
func SharedLabels ¶
SharedLabel returns the configured set of shared labels as a parallel tuple of keys to values; e.g. for app:kubecost,type:staging this returns (["app", "type"], ["kubecost", "staging"]) in order to match the signature of the NewSharedResourceInfo
func SharedNamespaces ¶
SharedNamespace returns a list of names of shared namespaces, as defined in the application settings
Types ¶
type CSVProvider ¶
type CSVProvider struct { *CustomProvider CSVLocation string Pricing map[string]*price NodeClassPricing map[string]float64 NodeClassCount map[string]float64 NodeMapField string PricingPV map[string]*price PVMapField string GPUClassPricing map[string]*price GPUMapFields []string // Fields in a node's labels that represent the GPU class. UsesRegion bool DownloadPricingDataLock sync.RWMutex }
func (*CSVProvider) ClusterManagementPricing ¶
func (*CSVProvider) ClusterManagementPricing() (string, float64, error)
func (*CSVProvider) CombinedDiscountForNode ¶
func (c *CSVProvider) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64
func (*CSVProvider) DownloadPricingData ¶
func (c *CSVProvider) DownloadPricingData() error
func (*CSVProvider) GetPVKey ¶
func (c *CSVProvider) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey
func (*CSVProvider) NodePricing ¶
func (c *CSVProvider) NodePricing(key models.Key) (*models.Node, models.PricingMetadata, error)
func (*CSVProvider) PricingSourceSummary ¶
func (c *CSVProvider) PricingSourceSummary() interface{}
func (*CSVProvider) Regions ¶
func (c *CSVProvider) Regions() []string
func (*CSVProvider) ServiceAccountStatus ¶
func (c *CSVProvider) ServiceAccountStatus() *models.ServiceAccountStatus
type CustomProvider ¶
type CustomProvider struct { Clientset clustercache.ClusterCache Pricing map[string]*NodePrice SpotLabel string SpotLabelValue string GPULabel string GPULabelValue string ClusterRegion string ClusterAccountID string DownloadPricingDataLock sync.RWMutex Config models.ProviderConfig }
func (*CustomProvider) AllNodePricing ¶
func (cp *CustomProvider) AllNodePricing() (interface{}, error)
func (*CustomProvider) ApplyReservedInstancePricing ¶
func (*CustomProvider) ApplyReservedInstancePricing(nodes map[string]*models.Node)
func (*CustomProvider) ClusterInfo ¶
func (cp *CustomProvider) ClusterInfo() (map[string]string, error)
func (*CustomProvider) ClusterManagementPricing ¶
func (*CustomProvider) ClusterManagementPricing() (string, float64, error)
func (*CustomProvider) CombinedDiscountForNode ¶
func (cp *CustomProvider) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64
func (*CustomProvider) DownloadPricingData ¶
func (cp *CustomProvider) DownloadPricingData() error
func (*CustomProvider) ExternalAllocations ¶
func (*CustomProvider) ExternalAllocations(start string, end string, aggregator []string, filterType string, filterValue string, crossCluster bool) ([]*models.OutOfClusterAllocation, error)
ExternalAllocations represents tagged assets outside the scope of kubernetes. "start" and "end" are dates of the format YYYY-MM-DD "aggregator" is the tag used to determine how to allocate those assets, ie namespace, pod, etc.
func (*CustomProvider) GetAddresses ¶
func (*CustomProvider) GetAddresses() ([]byte, error)
func (*CustomProvider) GetConfig ¶
func (cp *CustomProvider) GetConfig() (*models.CustomPricing, error)
func (*CustomProvider) GetDisks ¶
func (*CustomProvider) GetDisks() ([]byte, error)
func (*CustomProvider) GetLocalStorageQuery ¶
func (*CustomProvider) GetManagementPlatform ¶
func (*CustomProvider) GetManagementPlatform() (string, error)
func (*CustomProvider) GetOrphanedResources ¶
func (*CustomProvider) GetOrphanedResources() ([]models.OrphanedResource, error)
func (*CustomProvider) GetPVKey ¶
func (*CustomProvider) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey
func (*CustomProvider) LoadBalancerPricing ¶
func (cp *CustomProvider) LoadBalancerPricing() (*models.LoadBalancer, error)
func (*CustomProvider) NetworkPricing ¶
func (cp *CustomProvider) NetworkPricing() (*models.Network, error)
func (*CustomProvider) NodePricing ¶
func (cp *CustomProvider) NodePricing(key models.Key) (*models.Node, models.PricingMetadata, error)
func (*CustomProvider) PricingSourceStatus ¶
func (cp *CustomProvider) PricingSourceStatus() map[string]*models.PricingSource
func (*CustomProvider) PricingSourceSummary ¶
func (cp *CustomProvider) PricingSourceSummary() interface{}
PricingSourceSummary returns the pricing source summary for the provider. The summary represents what was _parsed_ from the pricing source, not what was returned from the relevant API.
func (*CustomProvider) Regions ¶
func (cp *CustomProvider) Regions() []string
func (*CustomProvider) ServiceAccountStatus ¶
func (cp *CustomProvider) ServiceAccountStatus() *models.ServiceAccountStatus
func (*CustomProvider) UpdateConfig ¶
func (cp *CustomProvider) UpdateConfig(r io.Reader, updateType string) (*models.CustomPricing, error)
func (*CustomProvider) UpdateConfigFromConfigMap ¶
func (cp *CustomProvider) UpdateConfigFromConfigMap(a map[string]string) (*models.CustomPricing, error)
type ProviderConfig ¶
type ProviderConfig struct {
// contains filtered or unexported fields
}
ProviderConfig is a utility class that provides a thread-safe configuration storage/cache for all Provider implementations
func NewProviderConfig ¶
func NewProviderConfig(configManager *config.ConfigFileManager, fileName string) *ProviderConfig
NewProviderConfig creates a new ConfigFile and returns the ProviderConfig
func (*ProviderConfig) ConfigFileManager ¶
func (pc *ProviderConfig) ConfigFileManager() *config.ConfigFileManager
ConfigFileManager returns the ConfigFileManager instance used to manage the CustomPricing configuration. In the event of a multi-provider setup, this instance should be used to configure any other configuration providers.
func (*ProviderConfig) GetCustomPricingData ¶
func (pc *ProviderConfig) GetCustomPricingData() (*models.CustomPricing, error)
ThreadSafe method for retrieving the custom pricing config.
func (*ProviderConfig) Update ¶
func (pc *ProviderConfig) Update(updateFunc func(*models.CustomPricing) error) (*models.CustomPricing, error)
Allows a call to manually update the configuration while maintaining proper thread-safety for read/write methods.
func (*ProviderConfig) UpdateFromMap ¶
func (pc *ProviderConfig) UpdateFromMap(a map[string]string) (*models.CustomPricing, error)
ThreadSafe update of the config using a string map