provider

package
v1.109.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateIdleByDefault

func AllocateIdleByDefault(p models.Provider) bool

AllocateIdleByDefault returns true if the application settings specify to allocate idle by default

func ClusterName

func ClusterName(p models.Provider) string

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

func CustomPricesEnabled(p models.Provider) bool

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 ExtractConfigFromProviders added in v1.108.0

func ExtractConfigFromProviders(prov models.Provider) models.ProviderConfig

func GetCsv

func GetCsv(location string) (io.Reader, error)

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 NodeValueFromMapField(m string, n *v1.Node, useRegion bool) string

func PVValueFromMapField

func PVValueFromMapField(m string, n *v1.PersistentVolume) string

func ParseID

func ParseID(id string) string

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

func ParseLBID(id string) string

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

func ParsePVID(id string) string

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

func ShareTenancyCosts(p models.Provider) bool

ShareTenancyCosts returns true if the application settings specify to share tenancy costs by default.

func SharedLabels

func SharedLabels(p models.Provider) ([]string, []string)

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

func SharedNamespaces(p models.Provider) []string

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) GetKey

func (c *CSVProvider) GetKey(l map[string]string, n *v1.Node) models.Key

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) PVPricing

func (c *CSVProvider) PVPricing(pvk models.PVKey) (*models.PV, 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) GetKey

func (cp *CustomProvider) GetKey(labels map[string]string, n *v1.Node) models.Key

func (*CustomProvider) GetLocalStorageQuery

func (*CustomProvider) GetLocalStorageQuery(window, offset time.Duration, rate bool, used bool) string

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) PVPricing

func (cp *CustomProvider) PVPricing(pvk models.PVKey) (*models.PV, 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) QuerySQL

func (*CustomProvider) QuerySQL(query string) ([]byte, error)

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 NodePrice

type NodePrice struct {
	CPU string
	RAM string
	GPU string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL