cloud

package
v1.101.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 69 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALIBABA_ECS_PRODUCT_CODE                   = "ecs"
	ALIBABA_ECS_VERSION                        = "2014-05-26"
	ALIBABA_ECS_DOMAIN                         = "ecs.aliyuncs.com"
	ALIBABA_DESCRIBE_PRICE_API_ACTION          = "DescribePrice"
	ALIBABA_DESCRIBE_DISK_API_ACTION           = "DescribeDisks"
	ALIBABA_INSTANCE_RESOURCE_TYPE             = "instance"
	ALIBABA_DISK_RESOURCE_TYPE                 = "disk"
	ALIBABA_PAY_AS_YOU_GO_BILLING              = "Pay-As-You-Go"
	ALIBABA_SUBSCRIPTION_BILLING               = "Subscription"
	ALIBABA_PREEMPTIBLE_BILLING                = "Preemptible"
	ALIBABA_OPTIMIZE_KEYWORD                   = "optimize"
	ALIBABA_NON_OPTIMIZE_KEYWORD               = "nonoptimize"
	ALIBABA_HOUR_PRICE_UNIT                    = "Hour"
	ALIBABA_MONTH_PRICE_UNIT                   = "Month"
	ALIBABA_YEAR_PRICE_UNIT                    = "Year"
	ALIBABA_UNKNOWN_INSTANCE_FAMILY_TYPE       = "unknown"
	ALIBABA_NOT_SUPPORTED_INSTANCE_FAMILY_TYPE = "unsupported"
	ALIBABA_DISK_CLOUD_ESSD_CATEGORY           = "cloud_essd"
	ALIBABA_DISK_CLOUD_CATEGORY                = "cloud"
	ALIBABA_DATA_DISK_CATEGORY                 = "data"
	ALIBABA_SYSTEM_DISK_CATEGORY               = "system"
	ALIBABA_DATA_DISK_PREFIX                   = "DataDisk"
	ALIBABA_PV_CLOUD_DISK_TYPE                 = "CloudDisk"
	ALIBABA_PV_NAS_TYPE                        = "NAS"
	ALIBABA_PV_OSS_TYPE                        = "OSS"
	ALIBABA_DEFAULT_DATADISK_SIZE              = "2000"
	ALIBABA_DISK_TOPOLOGY_REGION_LABEL         = "topology.diskplugin.csi.alibabacloud.com/region"
	ALIBABA_DISK_TOPOLOGY_ZONE_LABEL           = "topology.diskplugin.csi.alibabacloud.com/zone"
)
View Source
const (
	SpotInfoUpdateType   = "spotinfo"
	AthenaInfoUpdateType = "athenainfo"
	PreemptibleType      = "preemptible"

	APIPricingSource              = "Public API"
	SpotPricingSource             = "Spot Data Feed"
	ReservedInstancePricingSource = "Savings Plan, Reserved Instance, and Out-Of-Cluster"

	InUseState    = "in-use"
	AttachedState = "attached"

	AWSHourlyPublicIPCost    = 0.005
	EKSCapacityTypeLabel     = "eks.amazonaws.com/capacityType"
	EKSCapacitySpotTypeValue = "SPOT"
)
View Source
const (
	AzureFilePremiumStorageClass     = "premium_smb"
	AzureFileStandardStorageClass    = "standard_smb"
	AzureDiskPremiumSSDStorageClass  = "premium_ssd"
	AzureDiskStandardSSDStorageClass = "standard_ssd"
	AzureDiskStandardStorageClass    = "standard_hdd"

	AzureStorageUpdateType = "AzureStorage"
)
View Source
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"
)
View Source
const (
	GCPReservedInstanceResourceTypeRAM string = "MEMORY"
	GCPReservedInstanceResourceTypeCPU string = "VCPU"
	GCPReservedInstanceStatusActive    string = "ACTIVE"
	GCPReservedInstancePlanOneYear     string = "TWELVE_MONTH"
	GCPReservedInstancePlanThreeYear   string = "THIRTY_SIX_MONTH"
)
View Source
const BigqueryUpdateType = "bigqueryupdate"
View Source
const ClusterIdEnvVar = "AWS_CLUSTER_ID"

ClusterIdEnvVar is the environment variable in which one can manually set the ClusterId

View Source
const GKE_GPU_TAG = "cloud.google.com/gke-accelerator"
View Source
const HourlyRateCode = ".6YS6EN2CT7"

HourlyRateCode is appended to a node sku

View Source
const HourlyRateCodeCn = ".Q7UJUT2CE6"
View Source
const (
	InstanceAPIPricing = "Instance API Pricing"
)
View Source
const KarpenterCapacitySpotTypeValue = "spot"
View Source
const KarpenterCapacityTypeLabel = "karpenter.sh/capacity-type"
View Source
const OnDemandRateCode = ".JRTCKXETXF"

OnDemandRateCode is appended to an node sku

View Source
const OnDemandRateCodeCn = ".99YE2YK9UR"
View Source
const ReservedRateCode = ".38NPMPTW36"

ReservedRateCode is appended to a node sku

View Source
const SpotRefreshDuration = 15 * time.Minute

How often spot data is refreshed

Variables

This section is empty.

Functions

func AllocateIdleByDefault

func AllocateIdleByDefault(p Provider) bool

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

func ClusterName

func ClusterName(p Provider) string

ClusterName returns the name defined in cluster info, defaulting to the CLUSTER_ID environment variable

func ConfigWatcherFor

func ConfigWatcherFor(p Provider) *watcher.ConfigMapWatcher

ConfigWatcherFor returns a new ConfigWatcher instance which watches changes to the "pricing-configs" configmap

func CreateClusterMeta

func CreateClusterMeta(cluster_id, cluster_name string) error

func CustomPricesEnabled

func CustomPricesEnabled(p 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 GetClusterMeta

func GetClusterMeta(cluster_id string) (string, string, error)

func GetCsv

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

func GetOrCreateClusterMeta

func GetOrCreateClusterMeta(cluster_id, cluster_name string) (string, string, error)

func NewClientCredentialsConfig

func NewClientCredentialsConfig(clientID string, clientSecret string, tenantID string, env azure.Environment) auth.ClientCredentialsConfig

NewClientCredentialsConfig creates an AuthorizerConfig object configured to obtain an Authorizer through Client Credentials.

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 SetCustomPricingField

func SetCustomPricingField(obj *CustomPricing, name string, value string) error

func ShareTenancyCosts

func ShareTenancyCosts(p Provider) bool

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

func SharedLabels

func SharedLabels(p 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 Provider) []string

SharedNamespace returns a list of names of shared namespaces, as defined in the application settings

func UpdateClusterMeta

func UpdateClusterMeta(cluster_id, cluster_name string) error

Types

type AWS

type AWS struct {
	Pricing                     map[string]*AWSProductTerms
	SpotPricingByInstanceID     map[string]*spotInfo
	SpotPricingUpdatedAt        *time.Time
	SpotRefreshRunning          bool
	SpotPricingLock             sync.RWMutex
	SpotPricingError            error
	RIPricingByInstanceID       map[string]*RIData
	RIPricingError              error
	RIDataRunning               bool
	RIDataLock                  sync.RWMutex
	SavingsPlanDataByInstanceID map[string]*SavingsPlanData
	SavingsPlanDataRunning      bool
	SavingsPlanDataLock         sync.RWMutex
	ValidPricingKeys            map[string]bool
	Clientset                   clustercache.ClusterCache
	BaseCPUPrice                string
	BaseRAMPrice                string
	BaseGPUPrice                string
	BaseSpotCPUPrice            string
	BaseSpotRAMPrice            string
	BaseSpotGPUPrice            string
	SpotLabelName               string
	SpotLabelValue              string
	SpotDataRegion              string
	SpotDataBucket              string
	SpotDataPrefix              string
	ProjectID                   string
	DownloadPricingDataLock     sync.RWMutex
	Config                      *ProviderConfig

	*CustomProvider
	// contains filtered or unexported fields
}

AWS represents an Amazon Provider

func (*AWS) AllNodePricing

func (aws *AWS) AllNodePricing() (interface{}, error)

AllNodePricing returns all the billing data fetched.

func (*AWS) ApplyReservedInstancePricing

func (aws *AWS) ApplyReservedInstancePricing(nodes map[string]*Node)

ApplyReservedInstancePricing TODO

func (*AWS) ClusterInfo

func (awsProvider *AWS) ClusterInfo() (map[string]string, error)

ClusterInfo returns an object that represents the cluster. TODO: actually return the name of the cluster. Blocked on cluster federation.

func (*AWS) ClusterManagementPricing

func (aws *AWS) ClusterManagementPricing() (string, float64, error)

func (*AWS) CombinedDiscountForNode

func (aws *AWS) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64

func (*AWS) ConfigureAuth

func (aws *AWS) ConfigureAuth() error

updates the authentication to the latest values (via config or secret)

func (*AWS) ConfigureAuthWith

func (aws *AWS) ConfigureAuthWith(config *CustomPricing) error

updates the authentication to the latest values (via config or secret)

func (*AWS) DownloadPricingData

func (aws *AWS) DownloadPricingData() error

DownloadPricingData fetches data from the AWS Pricing API

func (*AWS) GetAWSAccessKey

func (aws *AWS) GetAWSAccessKey() (*AWSAccessKey, error)

GetAWSAccessKey generate an AWSAccessKey object from the config

func (*AWS) GetAWSAthenaInfo

func (aws *AWS) GetAWSAthenaInfo() (*AwsAthenaInfo, error)

GetAWSAthenaInfo generate an AWSAthenaInfo object from the config

func (*AWS) GetAddresses

func (aws *AWS) GetAddresses() ([]byte, error)

GetAddresses retrieves EC2 addresses

func (*AWS) GetConfig

func (aws *AWS) GetConfig() (*CustomPricing, error)

func (*AWS) GetDisks

func (aws *AWS) GetDisks() ([]byte, error)

GetDisks returns the AWS disks backing PVs. Useful because sometimes k8s will not clean up PVs correctly. Requires a json config in /var/configs with key region.

func (*AWS) GetKey

func (aws *AWS) GetKey(labels map[string]string, n *v1.Node) Key

GetKey maps node labels to information needed to retrieve pricing data

func (*AWS) GetLocalStorageQuery

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

func (*AWS) GetManagementPlatform

func (aws *AWS) GetManagementPlatform() (string, error)

func (*AWS) GetOrphanedResources added in v1.99.0

func (aws *AWS) GetOrphanedResources() ([]OrphanedResource, error)

func (*AWS) GetPVKey

func (aws *AWS) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*AWS) GetReservationDataFromAthena

func (aws *AWS) GetReservationDataFromAthena() error

func (*AWS) GetSavingsPlanDataFromAthena

func (aws *AWS) GetSavingsPlanDataFromAthena() error

func (*AWS) KubeAttrConversion

func (aws *AWS) KubeAttrConversion(location, instanceType, operatingSystem string) string

KubeAttrConversion maps the k8s labels for region to an aws region

func (*AWS) LoadBalancerPricing

func (aws *AWS) LoadBalancerPricing() (*LoadBalancer, error)

func (*AWS) NetworkPricing

func (aws *AWS) NetworkPricing() (*Network, error)

Stubbed NetworkPricing for AWS. Pull directly from aws.json for now

func (*AWS) NodePricing

func (aws *AWS) NodePricing(k Key) (*Node, error)

NodePricing takes in a key from GetKey and returns a Node object for use in building the cost model.

func (*AWS) PVPricing

func (aws *AWS) PVPricing(pvk PVKey) (*PV, error)

func (*AWS) PricingSourceStatus

func (aws *AWS) PricingSourceStatus() map[string]*PricingSource

func (*AWS) QueryAthenaPaginated

func (aws *AWS) QueryAthenaPaginated(ctx context.Context, query string, fn func(*athena.GetQueryResultsOutput) bool) error

QueryAthenaPaginated executes athena query and processes results.

func (*AWS) Regions

func (aws *AWS) Regions() []string

Regions returns a predefined list of AWS regions

func (*AWS) ServiceAccountStatus

func (aws *AWS) ServiceAccountStatus() *ServiceAccountStatus

func (*AWS) SpotRefreshEnabled

func (aws *AWS) SpotRefreshEnabled() bool

SpotRefreshEnabled determines whether the required configs to run the spot feed query have been set up

func (*AWS) UpdateConfig

func (aws *AWS) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)

func (*AWS) UpdateConfigFromConfigMap

func (aws *AWS) UpdateConfigFromConfigMap(cm map[string]string) (*CustomPricing, error)

type AWSAccessKey

type AWSAccessKey struct {
	AccessKeyID     string `json:"aws_access_key_id"`
	SecretAccessKey string `json:"aws_secret_access_key"`
}

AWSAccessKey holds AWS credentials and fulfils the awsV2.CredentialsProvider interface

func (AWSAccessKey) CreateConfig

func (accessKey AWSAccessKey) CreateConfig(region string) (awsSDK.Config, error)

CreateConfig creates an AWS SDK V2 Config for the credentials that it contains for the provided region

func (AWSAccessKey) Retrieve

func (accessKey AWSAccessKey) Retrieve(ctx context.Context) (awsSDK.Credentials, error)

Retrieve returns a set of awsV2 credentials using the AWSAccessKey's key and secret. This fulfils the awsV2.CredentialsProvider interface contract.

type AWSCurrencyCode

type AWSCurrencyCode struct {
	USD string `json:"USD,omitempty"`
	CNY string `json:"CNY,omitempty"`
}

AWSCurrencyCode is the localized currency. (TODO: support non-USD)

type AWSOfferTerm

type AWSOfferTerm struct {
	Sku             string                  `json:"sku"`
	PriceDimensions map[string]*AWSRateCode `json:"priceDimensions"`
}

AWSOfferTerm is a sku extension used to pay for the node.

func (*AWSOfferTerm) String

func (ot *AWSOfferTerm) String() string

type AWSPricing

type AWSPricing struct {
	Products map[string]*AWSProduct `json:"products"`
	Terms    AWSPricingTerms        `json:"terms"`
}

AWSPricing maps a k8s node to an AWS Pricing "product"

type AWSPricingTerms

type AWSPricingTerms struct {
	OnDemand map[string]map[string]*AWSOfferTerm `json:"OnDemand"`
	Reserved map[string]map[string]*AWSOfferTerm `json:"Reserved"`
}

AWSPricingTerms are how you pay for the node: OnDemand, Reserved, or (TODO) Spot

type AWSProduct

type AWSProduct struct {
	Sku        string               `json:"sku"`
	Attributes AWSProductAttributes `json:"attributes"`
}

AWSProduct represents a purchased SKU

type AWSProductAttributes

type AWSProductAttributes struct {
	Location        string `json:"location"`
	InstanceType    string `json:"instanceType"`
	Memory          string `json:"memory"`
	Storage         string `json:"storage"`
	VCpu            string `json:"vcpu"`
	UsageType       string `json:"usagetype"`
	OperatingSystem string `json:"operatingSystem"`
	PreInstalledSw  string `json:"preInstalledSw"`
	InstanceFamily  string `json:"instanceFamily"`
	CapacityStatus  string `json:"capacitystatus"`
	GPU             string `json:"gpu"` // GPU represents the number of GPU on the instance
}

AWSProductAttributes represents metadata about the product used to map to a node.

type AWSProductTerms

type AWSProductTerms struct {
	Sku      string        `json:"sku"`
	OnDemand *AWSOfferTerm `json:"OnDemand"`
	Reserved *AWSOfferTerm `json:"Reserved"`
	Memory   string        `json:"memory"`
	Storage  string        `json:"storage"`
	VCpu     string        `json:"vcpu"`
	GPU      string        `json:"gpu"` // GPU represents the number of GPU on the instance
	PV       *PV           `json:"pv"`
}

AWSProductTerms represents the full terms of the product

type AWSRateCode

type AWSRateCode struct {
	Unit         string          `json:"unit"`
	PricePerUnit AWSCurrencyCode `json:"pricePerUnit"`
}

AWSRateCode encodes data about the price of a product

func (*AWSRateCode) String

func (rc *AWSRateCode) String() string

type Alibaba added in v1.99.0

type Alibaba struct {
	// Data to store Alibaba cloud's pricing struct, key in the map represents exact match to
	// node.features() or pv.features for easy lookup
	Pricing map[string]*AlibabaPricing
	// Lock Needed to provide thread safe
	DownloadPricingDataLock sync.RWMutex
	Clientset               clustercache.ClusterCache
	Config                  *ProviderConfig
	*CustomProvider
	// contains filtered or unexported fields
}

Alibaba cloud's Provider struct

func (*Alibaba) AllNodePricing added in v1.99.0

func (alibaba *Alibaba) AllNodePricing() (interface{}, error)

AllNodePricing returns all the pricing data for all nodes and pvs

func (*Alibaba) ApplyReservedInstancePricing added in v1.99.0

func (alibaba *Alibaba) ApplyReservedInstancePricing(nodes map[string]*Node)

Will look at this in Next PR if needed

func (*Alibaba) ClusterInfo added in v1.99.0

func (alibaba *Alibaba) ClusterInfo() (map[string]string, error)

ClusterInfo returns information about Alibaba Cloud cluster, as provided by metadata.

func (*Alibaba) ClusterManagementPricing added in v1.99.0

func (alibaba *Alibaba) ClusterManagementPricing() (string, float64, error)

Will look at this in Next PR if needed

func (*Alibaba) CombinedDiscountForNode added in v1.99.0

func (alibaba *Alibaba) CombinedDiscountForNode(string, bool, float64, float64) float64

Will look at this in Next PR if needed

func (*Alibaba) DownloadPricingData added in v1.99.0

func (alibaba *Alibaba) DownloadPricingData() error

DownloadPricingData satisfies the provider interface and downloads the prices for Node instances and PVs.

func (*Alibaba) GetAddresses added in v1.99.0

func (alibaba *Alibaba) GetAddresses() ([]byte, error)

Will look at this in Next PR if needed

func (*Alibaba) GetAlibabaAccessKey added in v1.99.0

func (alibaba *Alibaba) GetAlibabaAccessKey() (*credentials.AccessKeyCredential, error)

GetAlibabaAccessKey return the Access Key used to interact with the Alibaba cloud, if not set it set it first by looking at env variables else load it from secret files.

func (*Alibaba) GetAlibabaCloudInfo added in v1.100.0

func (alibaba *Alibaba) GetAlibabaCloudInfo() (*AlibabaInfo, error)

func (*Alibaba) GetConfig added in v1.99.0

func (alibaba *Alibaba) GetConfig() (*CustomPricing, error)

func (*Alibaba) GetDisks added in v1.99.0

func (alibaba *Alibaba) GetDisks() ([]byte, error)

Will look at this in Next PR if needed

func (*Alibaba) GetKey added in v1.99.0

func (alibaba *Alibaba) GetKey(mapValue map[string]string, node *v1.Node) Key

Get's the key for the k8s node input

func (*Alibaba) GetLocalStorageQuery added in v1.99.0

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

Will look at this in Next PR if needed

func (*Alibaba) GetManagementPlatform added in v1.99.0

func (alibaba *Alibaba) GetManagementPlatform() (string, error)

Will look at this in Next PR if needed

func (*Alibaba) GetOrphanedResources added in v1.99.0

func (alibaba *Alibaba) GetOrphanedResources() ([]OrphanedResource, error)

func (*Alibaba) GetPVKey added in v1.99.0

func (alibaba *Alibaba) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*Alibaba) LoadBalancerPricing added in v1.99.0

func (alibaba *Alibaba) LoadBalancerPricing() (*LoadBalancer, error)

Stubbed LoadBalancerPricing for Alibaba Cloud. Will look at this in Next PR

func (*Alibaba) NetworkPricing added in v1.99.0

func (alibaba *Alibaba) NetworkPricing() (*Network, error)

Stubbed NetworkPricing for Alibaba Cloud. Will look at this in Next PR

func (*Alibaba) NodePricing added in v1.99.0

func (alibaba *Alibaba) NodePricing(key Key) (*Node, error)

NodePricing gives pricing information of a specific node given by the key

func (*Alibaba) PVPricing added in v1.99.0

func (alibaba *Alibaba) PVPricing(pvk PVKey) (*PV, error)

PVPricing gives a pricing information of a specific PV given by PVkey

func (*Alibaba) PricingSourceStatus added in v1.99.0

func (alibaba *Alibaba) PricingSourceStatus() map[string]*PricingSource

Will look at this in Next PR if needed

func (*Alibaba) Regions added in v1.99.0

func (alibaba *Alibaba) Regions() []string

Regions returns a current supported list of Alibaba regions

func (*Alibaba) ServiceAccountStatus added in v1.99.0

func (alibaba *Alibaba) ServiceAccountStatus() *ServiceAccountStatus

Will look at this in Next PR if needed

func (*Alibaba) UpdateConfig added in v1.99.0

func (alibaba *Alibaba) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)

func (*Alibaba) UpdateConfigFromConfigMap added in v1.99.0

func (alibaba *Alibaba) UpdateConfigFromConfigMap(cm map[string]string) (*CustomPricing, error)

type AlibabaAccessKey added in v1.99.0

type AlibabaAccessKey struct {
	AccessKeyID     string `json:"alibaba_access_key_id"`
	SecretAccessKey string `json:"alibaba_secret_access_key"`
}

AlibabaAccessKey holds Alibaba credentials parsing from the service-key.json file.

type AlibabaInfo added in v1.100.0

type AlibabaInfo struct {
	AlibabaClusterRegion    string `json:"clusterRegion"`
	AlibabaServiceKeyName   string `json:"serviceKeyName"`
	AlibabaServiceKeySecret string `json:"serviceKeySecret"`
	AlibabaAccountID        string `json:"accountID"`
}

AlibabaInfo contains configuration for Alibaba's CUR integration

func (*AlibabaInfo) IsEmpty added in v1.100.0

func (ai *AlibabaInfo) IsEmpty() bool

IsEmpty returns true if all fields in config are empty, false if not.

type AlibabaNodeAttributes added in v1.99.0

type AlibabaNodeAttributes struct {
	// InstanceType represents the type of instance.
	InstanceType string `json:"instanceType"`
	// MemorySizeInKiB represents the size of memory of instance.
	MemorySizeInKiB string `json:"memorySizeInKiB"`
	// IsIoOptimized represents the if instance is I/O optimized.
	IsIoOptimized bool `json:"isIoOptimized"`
	// OSType represents the OS installed in the Instance.
	OSType string `json:"osType"`
	// SystemDiskCategory represents the exact category of the system disk attached to the node.
	SystemDiskCategory string `json:"systemDiskCategory"`
	// SystemDiskSizeInGiB represents the size of the system disk attached to the node.
	SystemDiskSizeInGiB string `json:"systemDiskSizeInGiB"`
	// SystemDiskPerformanceLevel represents the performance level of the system disk attached to the node.
	SystemDiskPerformanceLevel string `json:"systemPerformanceLevel"`
}

AlibabaNodeAttributes represents metadata about the Node in its pricing information. Basic Attributes needed atleast to get the key, Some attributes from k8s Node response be populated directly into *Node object.

func NewAlibabaNodeAttributes added in v1.99.0

func NewAlibabaNodeAttributes(node *SlimK8sNode) *AlibabaNodeAttributes

type AlibabaNodeKey added in v1.99.0

type AlibabaNodeKey struct {
	ProviderID                 string
	RegionID                   string
	InstanceType               string
	OSType                     string
	OptimizedKeyword           string //If IsIoOptimized is true use the word optimize in the Node key and if its not optimized use the word nonoptimize
	SystemDiskCategory         string
	SystemDiskSizeInGiB        string
	SystemDiskPerformanceLevel string
}

func NewAlibabaNodeKey added in v1.99.0

func NewAlibabaNodeKey(node *SlimK8sNode, optimizedKeyword, systemDiskCategory, systemDiskSizeInGiB, systemDiskPerfromanceLevel string) *AlibabaNodeKey

func (*AlibabaNodeKey) Features added in v1.99.0

func (alibabaNodeKey *AlibabaNodeKey) Features() string

func (*AlibabaNodeKey) GPUCount added in v1.99.0

func (alibabaNodeKey *AlibabaNodeKey) GPUCount() int

func (*AlibabaNodeKey) GPUType added in v1.99.0

func (alibabaNodeKey *AlibabaNodeKey) GPUType() string

func (*AlibabaNodeKey) ID added in v1.99.0

func (alibabaNodeKey *AlibabaNodeKey) ID() string

type AlibabaPVAttributes added in v1.99.0

type AlibabaPVAttributes struct {
	// PVType can be Cloud Disk, NetWork Attached Storage(NAS) or Object Storage Service (OSS).
	// Represents the way the PV was attached
	PVType string `json:"pvType"`
	// PVSubType represent the sub category of PVType. This is Data in case of Cloud Disk.
	PVSubType string `json:"pvSubType"`
	// Example for PVCategory with cloudDisk PVType are cloud, cloud_efficiency, cloud_ssd,
	// ephemeral_ssd and cloud_essd. If not present returns empty.
	PVCategory string `json:"pvCategory"`
	// Example for PerformanceLevel with cloudDisk PVType are PL0,PL1,PL2 &PL3. If not present returns empty.
	PVPerformanceLevel string `json:"performanceLevel"`
	// The Size of the PV in terms of GiB
	SizeInGiB string `json:"sizeInGiB"`
}

AlibabaPVAttributes represents metadata the PV in its pricing information. Basic Attributes needed atleast to get the keys. Some attributes from k8s PV response be populated directly into *PV object.

func NewAlibabaPVAttributes added in v1.99.0

func NewAlibabaPVAttributes(disk *SlimK8sDisk) *AlibabaPVAttributes

TO-Do: next iteration of Alibaba provider support NetWork Attached Storage(NAS) and Object Storage Service (OSS type PVs). Currently defaulting to cloudDisk with provision to add work in future.

type AlibabaPVKey added in v1.99.0

type AlibabaPVKey struct {
	ProviderID        string
	RegionID          string
	PVType            string
	PVSubType         string
	PVCategory        string
	PVPerformaceLevel string
	StorageClassName  string
	SizeInGiB         string
}

func (*AlibabaPVKey) Features added in v1.99.0

func (alibabaPVKey *AlibabaPVKey) Features() string

func (*AlibabaPVKey) GetStorageClass added in v1.99.0

func (alibabaPVKey *AlibabaPVKey) GetStorageClass() string

Get storage class information for PV.

func (*AlibabaPVKey) ID added in v1.99.0

func (alibabaPVKey *AlibabaPVKey) ID() string

type AlibabaPricing added in v1.99.0

type AlibabaPricing struct {
	NodeAttributes *AlibabaNodeAttributes
	PVAttributes   *AlibabaPVAttributes
	PricingTerms   *AlibabaPricingTerms
	Node           *Node
	PV             *PV
}

Alibaba Pricing struct carry the Attributes and pricing information for Node or PV

type AlibabaPricingDetails added in v1.99.0

type AlibabaPricingDetails struct {
	// Represents hourly price for the given Alibaba cloud Product.
	HourlyPrice float32 `json:"hourlyPrice"`
	// Represents the unit in which Alibaba Product is billed can be Hour, Month or Year based on the billingMethod.
	PriceUnit string `json:"priceUnit"`
	// Original Price paid to acquire the Alibaba Product.
	TradePrice float32 `json:"tradePrice"`
	// Represents the currency unit of the price for billing Alibaba Product.
	CurrencyCode string `json:"currencyCode"`
}

Stage 1 support will be Pay-As-You-Go with HourlyPrice equal to TradePrice with PriceUnit as Hour TO-DO: Subscription and Premptible support, Information can be gathered from describing instance for subscription type and spotprice can be gather from DescribeSpotPriceHistory API. TO-DO: how would you calculate hourly price for subscription type, is it PRICE_YEARLY/HOURS_IN_THE_YEAR|MONTH?

func NewAlibabaPricingDetails added in v1.99.0

func NewAlibabaPricingDetails(hourlyPrice float32, priceUnit string, tradePrice float32, currencyCode string) *AlibabaPricingDetails

type AlibabaPricingTerms added in v1.99.0

type AlibabaPricingTerms struct {
	BillingMethod  string                 `json:"billingMethod"`
	PricingDetails *AlibabaPricingDetails `json:"pricingDetails"`
}

AlibabaPricingTerms can have three types of supported billing method Pay-As-You-Go, Subscription and Premptible

func NewAlibabaPricingTerms added in v1.99.0

func NewAlibabaPricingTerms(billingMethod string, pricingDetails *AlibabaPricingDetails) *AlibabaPricingTerms

type AwsAthenaInfo

type AwsAthenaInfo struct {
	AthenaBucketName string `json:"athenaBucketName"`
	AthenaRegion     string `json:"athenaRegion"`
	AthenaDatabase   string `json:"athenaDatabase"`
	AthenaTable      string `json:"athenaTable"`
	AthenaWorkgroup  string `json:"athenaWorkgroup"`
	ServiceKeyName   string `json:"serviceKeyName"`
	ServiceKeySecret string `json:"serviceKeySecret"`
	AccountID        string `json:"projectID"`
	MasterPayerARN   string `json:"masterPayerARN"`
}

AwsAthenaInfo contains configuration for CUR integration

func (*AwsAthenaInfo) CreateConfig

func (aai *AwsAthenaInfo) CreateConfig() (awsSDK.Config, error)

CreateConfig creates an AWS SDK V2 Config for the credentials that it contains

func (*AwsAthenaInfo) IsEmpty

func (aai *AwsAthenaInfo) IsEmpty() bool

IsEmpty returns true if all fields in config are empty, false if not.

type AwsSpotFeedInfo

type AwsSpotFeedInfo struct {
	BucketName       string `json:"bucketName"`
	Prefix           string `json:"prefix"`
	Region           string `json:"region"`
	AccountID        string `json:"projectID"`
	ServiceKeyName   string `json:"serviceKeyName"`
	ServiceKeySecret string `json:"serviceKeySecret"`
	SpotLabel        string `json:"spotLabel"`
	SpotLabelValue   string `json:"spotLabelValue"`
}

AwsSpotFeedInfo contains configuration for spot feed integration

type Azure

type Azure struct {
	Pricing                 map[string]*AzurePricing
	DownloadPricingDataLock sync.RWMutex
	Clientset               clustercache.ClusterCache
	Config                  *ProviderConfig

	RateCardPricingError error
	// contains filtered or unexported fields
}

func (*Azure) AllNodePricing

func (az *Azure) AllNodePricing() (interface{}, error)

AllNodePricing returns the Azure pricing objects stored

func (*Azure) ApplyReservedInstancePricing

func (az *Azure) ApplyReservedInstancePricing(nodes map[string]*Node)

func (*Azure) ClusterInfo

func (az *Azure) ClusterInfo() (map[string]string, error)

func (*Azure) ClusterManagementPricing

func (*Azure) ClusterManagementPricing() (string, float64, error)

func (*Azure) CombinedDiscountForNode

func (az *Azure) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64

func (*Azure) DownloadPricingData

func (az *Azure) DownloadPricingData() error

DownloadPricingData uses provided azure "best guesses" for pricing

func (*Azure) GetAddresses

func (*Azure) GetAddresses() ([]byte, error)

func (*Azure) GetAzureStorageConfig

func (az *Azure) GetAzureStorageConfig(forceReload bool, cp *CustomPricing) (*AzureStorageConfig, error)

GetAzureStorageConfig retrieves storage config from secret and sets default values

func (*Azure) GetConfig

func (az *Azure) GetConfig() (*CustomPricing, error)

func (*Azure) GetDisks

func (az *Azure) GetDisks() ([]byte, error)

func (*Azure) GetKey

func (az *Azure) GetKey(labels map[string]string, n *v1.Node) Key

func (*Azure) GetLocalStorageQuery

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

func (*Azure) GetManagementPlatform

func (az *Azure) GetManagementPlatform() (string, error)

func (*Azure) GetOrphanedResources added in v1.99.0

func (az *Azure) GetOrphanedResources() ([]OrphanedResource, error)

func (*Azure) GetPVKey

func (az *Azure) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*Azure) LoadBalancerPricing

func (azr *Azure) LoadBalancerPricing() (*LoadBalancer, error)

LoadBalancerPricing on Azure, LoadBalancer services correspond to public IPs. For now the pricing of LoadBalancer services will be that of a standard static public IP https://azure.microsoft.com/en-us/pricing/details/ip-addresses/. Azure still has load balancers which follow the standard pricing scheme based on rules https://azure.microsoft.com/en-us/pricing/details/load-balancer/, they are created on a per-cluster basis.

func (*Azure) NetworkPricing

func (az *Azure) NetworkPricing() (*Network, error)

Stubbed NetworkPricing for Azure. Pull directly from azure.json for now

func (*Azure) NodePricing

func (az *Azure) NodePricing(key Key) (*Node, error)

NodePricing returns Azure pricing data for a single node

func (*Azure) PVPricing

func (az *Azure) PVPricing(pvk PVKey) (*PV, error)

func (*Azure) PricingSourceStatus

func (az *Azure) PricingSourceStatus() map[string]*PricingSource

PricingSourceStatus returns the status of the rate card api

func (*Azure) Regions

func (az *Azure) Regions() []string

func (*Azure) ServiceAccountStatus

func (az *Azure) ServiceAccountStatus() *ServiceAccountStatus

func (*Azure) UpdateConfig

func (az *Azure) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)

func (*Azure) UpdateConfigFromConfigMap

func (az *Azure) UpdateConfigFromConfigMap(a map[string]string) (*CustomPricing, error)

type AzureAppKey

type AzureAppKey struct {
	AppID       string `json:"appId"`
	DisplayName string `json:"displayName"`
	Name        string `json:"name"`
	Password    string `json:"password"`
	Tenant      string `json:"tenant"`
}

Represents an azure app key

type AzurePricing

type AzurePricing struct {
	Node *Node
	PV   *PV
}

AzurePricing either contains a Node or PV

type AzureRetailPricing

type AzureRetailPricing struct {
	BillingCurrency    string                         `json:"BillingCurrency"`
	CustomerEntityId   string                         `json:"CustomerEntityId"`
	CustomerEntityType string                         `json:"CustomerEntityType"`
	Items              []AzureRetailPricingAttributes `json:"Items"`
	NextPageLink       string                         `json:"NextPageLink"`
	Count              int                            `json:"Count"`
}

AzureRetailPricing struct for unmarshalling Azure Retail pricing api JSON response

type AzureRetailPricingAttributes

type AzureRetailPricingAttributes struct {
	CurrencyCode         string     `json:"currencyCode"`
	TierMinimumUnits     float32    `json:"tierMinimumUnits"`
	RetailPrice          float32    `json:"retailPrice"`
	UnitPrice            float32    `json:"unitPrice"`
	ArmRegionName        string     `json:"armRegionName"`
	Location             string     `json:"location"`
	EffectiveStartDate   *time.Time `json:"effectiveStartDate"`
	EffectiveEndDate     *time.Time `json:"effectiveEndDate"`
	MeterId              string     `json:"meterId"`
	MeterName            string     `json:"meterName"`
	ProductId            string     `json:"productId"`
	SkuId                string     `json:"skuId"`
	ProductName          string     `json:"productName"`
	SkuName              string     `json:"skuName"`
	ServiceName          string     `json:"serviceName"`
	ServiceId            string     `json:"serviceId"`
	ServiceFamily        string     `json:"serviceFamily"`
	UnitOfMeasure        string     `json:"unitOfMeasure"`
	Type                 string     `json:"type"`
	IsPrimaryMeterRegion bool       `json:"isPrimaryMeterRegion"`
	ArmSkuName           string     `json:"armSkuName"`
}

AzureRetailPricingAttributes struct for unmarshalling Azure Retail pricing api JSON response

type AzureServiceKey

type AzureServiceKey struct {
	SubscriptionID string       `json:"subscriptionId"`
	ServiceKey     *AzureAppKey `json:"serviceKey"`
}

Azure service key for a specific subscription

func (*AzureServiceKey) IsValid

func (ask *AzureServiceKey) IsValid() bool

Validity check on service key

type AzureStorageConfig

type AzureStorageConfig struct {
	SubscriptionId string `json:"azureSubscriptionID"`
	AccountName    string `json:"azureStorageAccount"`
	AccessKey      string `json:"azureStorageAccessKey"`
	ContainerName  string `json:"azureStorageContainer"`
	ContainerPath  string `json:"azureContainerPath"`
	AzureCloud     string `json:"azureCloud"`
}

AzureStorageConfig Represents an azure storage config

func (*AzureStorageConfig) IsEmpty

func (asc *AzureStorageConfig) IsEmpty() bool

IsEmpty returns true if all fields in config are empty, false if not.

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

func (*BigQueryConfig) IsEmpty

func (bqc *BigQueryConfig) IsEmpty() bool

IsEmpty returns true if all fields in config are empty, false if not.

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

func (*CSVProvider) GetPVKey

func (c *CSVProvider) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*CSVProvider) NodePricing

func (c *CSVProvider) NodePricing(key Key) (*Node, error)

func (*CSVProvider) PVPricing

func (c *CSVProvider) PVPricing(pvk PVKey) (*PV, error)

func (*CSVProvider) Regions

func (c *CSVProvider) Regions() []string

func (*CSVProvider) ServiceAccountStatus

func (c *CSVProvider) ServiceAccountStatus() *ServiceAccountStatus

type CustomPricing

type CustomPricing struct {
	Provider    string `json:"provider"`
	Description string `json:"description"`
	// CPU a string-encoded float describing cost per core-hour of CPU.
	CPU string `json:"CPU"`
	// CPU a string-encoded float describing cost per core-hour of CPU for spot
	// nodes.
	SpotCPU string `json:"spotCPU"`
	// RAM a string-encoded float describing cost per GiB-hour of RAM/memory.
	RAM string `json:"RAM"`
	// SpotRAM a string-encoded float describing cost per GiB-hour of RAM/memory
	// for spot nodes.
	SpotRAM string `json:"spotRAM"`
	GPU     string `json:"GPU"`
	SpotGPU string `json:"spotGPU"`
	// Storage is a string-encoded float describing cost per GB-hour of storage
	// (e.g. PV, disk) resources.
	Storage                      string `json:"storage"`
	ZoneNetworkEgress            string `json:"zoneNetworkEgress"`
	RegionNetworkEgress          string `json:"regionNetworkEgress"`
	InternetNetworkEgress        string `json:"internetNetworkEgress"`
	FirstFiveForwardingRulesCost string `json:"firstFiveForwardingRulesCost"`
	AdditionalForwardingRuleCost string `json:"additionalForwardingRuleCost"`
	LBIngressDataCost            string `json:"LBIngressDataCost"`
	SpotLabel                    string `json:"spotLabel,omitempty"`
	SpotLabelValue               string `json:"spotLabelValue,omitempty"`
	GpuLabel                     string `json:"gpuLabel,omitempty"`
	GpuLabelValue                string `json:"gpuLabelValue,omitempty"`
	ServiceKeyName               string `json:"awsServiceKeyName,omitempty"`
	ServiceKeySecret             string `json:"awsServiceKeySecret,omitempty"`
	AlibabaServiceKeyName        string `json:"alibabaServiceKeyName,omitempty"`
	AlibabaServiceKeySecret      string `json:"alibabaServiceKeySecret,omitempty"`
	AlibabaClusterRegion         string `json:"alibabaClusterRegion,omitempty"`
	SpotDataRegion               string `json:"awsSpotDataRegion,omitempty"`
	SpotDataBucket               string `json:"awsSpotDataBucket,omitempty"`
	SpotDataPrefix               string `json:"awsSpotDataPrefix,omitempty"`
	ProjectID                    string `json:"projectID,omitempty"`
	AthenaProjectID              string `json:"athenaProjectID,omitempty"`
	AthenaBucketName             string `json:"athenaBucketName"`
	AthenaRegion                 string `json:"athenaRegion"`
	AthenaDatabase               string `json:"athenaDatabase"`
	AthenaTable                  string `json:"athenaTable"`
	AthenaWorkgroup              string `json:"athenaWorkgroup"`
	MasterPayerARN               string `json:"masterPayerARN"`
	BillingDataDataset           string `json:"billingDataDataset,omitempty"`
	CustomPricesEnabled          string `json:"customPricesEnabled"`
	DefaultIdle                  string `json:"defaultIdle"`
	AzureSubscriptionID          string `json:"azureSubscriptionID"`
	AzureClientID                string `json:"azureClientID"`
	AzureClientSecret            string `json:"azureClientSecret"`
	AzureTenantID                string `json:"azureTenantID"`
	AzureBillingRegion           string `json:"azureBillingRegion"`
	AzureOfferDurableID          string `json:"azureOfferDurableID"`
	AzureStorageSubscriptionID   string `json:"azureStorageSubscriptionID"`
	AzureStorageAccount          string `json:"azureStorageAccount"`
	AzureStorageAccessKey        string `json:"azureStorageAccessKey"`
	AzureStorageContainer        string `json:"azureStorageContainer"`
	AzureContainerPath           string `json:"azureContainerPath"`
	AzureCloud                   string `json:"azureCloud"`
	CurrencyCode                 string `json:"currencyCode"`
	Discount                     string `json:"discount"`
	NegotiatedDiscount           string `json:"negotiatedDiscount"`
	SharedOverhead               string `json:"sharedOverhead"`
	ClusterName                  string `json:"clusterName"`
	SharedNamespaces             string `json:"sharedNamespaces"`
	SharedLabelNames             string `json:"sharedLabelNames"`
	SharedLabelValues            string `json:"sharedLabelValues"`
	ShareTenancyCosts            string `json:"shareTenancyCosts"` // TODO clean up configuration so we can use a type other that string (this should be a bool, but the app panics if it's not a string)
	ReadOnly                     string `json:"readOnly"`
	EditorAccess                 string `json:"editorAccess"`
	KubecostToken                string `json:"kubecostToken"`
	GoogleAnalyticsTag           string `json:"googleAnalyticsTag"`
	ExcludeProviderID            string `json:"excludeProviderID"`
}

func DefaultPricing

func DefaultPricing() *CustomPricing

DefaultPricing should be returned so we can do computation even if no file is supplied.

func (*CustomPricing) GetSharedOverheadCostPerMonth

func (cp *CustomPricing) GetSharedOverheadCostPerMonth() float64

GetSharedOverheadCostPerMonth parses and returns a float64 representation of the configured monthly shared overhead cost. If the string version cannot be parsed into a float, an error is logged and 0.0 is returned.

type CustomProvider

type CustomProvider struct {
	Clientset               clustercache.ClusterCache
	Pricing                 map[string]*NodePrice
	SpotLabel               string
	SpotLabelValue          string
	GPULabel                string
	GPULabelValue           string
	DownloadPricingDataLock sync.RWMutex
	Config                  *ProviderConfig
}

func (*CustomProvider) AllNodePricing

func (cp *CustomProvider) AllNodePricing() (interface{}, error)

func (*CustomProvider) ApplyReservedInstancePricing

func (*CustomProvider) ApplyReservedInstancePricing(nodes map[string]*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) ([]*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() (*CustomPricing, error)

func (*CustomProvider) GetDisks

func (*CustomProvider) GetDisks() ([]byte, error)

func (*CustomProvider) GetKey

func (cp *CustomProvider) GetKey(labels map[string]string, n *v1.Node) 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 added in v1.99.0

func (*CustomProvider) GetOrphanedResources() ([]OrphanedResource, error)

func (*CustomProvider) GetPVKey

func (*CustomProvider) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*CustomProvider) LoadBalancerPricing

func (cp *CustomProvider) LoadBalancerPricing() (*LoadBalancer, error)

func (*CustomProvider) NetworkPricing

func (cp *CustomProvider) NetworkPricing() (*Network, error)

func (*CustomProvider) NodePricing

func (cp *CustomProvider) NodePricing(key Key) (*Node, error)

func (*CustomProvider) PVPricing

func (cp *CustomProvider) PVPricing(pvk PVKey) (*PV, error)

func (*CustomProvider) PricingSourceStatus

func (cp *CustomProvider) PricingSourceStatus() map[string]*PricingSource

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() *ServiceAccountStatus

func (*CustomProvider) UpdateConfig

func (cp *CustomProvider) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)

func (*CustomProvider) UpdateConfigFromConfigMap

func (cp *CustomProvider) UpdateConfigFromConfigMap(a map[string]string) (*CustomPricing, error)

type DescribeDiskResponse added in v1.99.0

type DescribeDiskResponse struct {
	TotalCount int    `json:"TotalCount"`
	Disks      *Disks `json:"Disks"`
}

type DescribePriceResponse added in v1.99.0

type DescribePriceResponse struct {
	RequestId string    `json:"RequestId"`
	PriceInfo PriceInfo `json:"PriceInfo"`
}

type Disk added in v1.99.0

type Disk struct {
	Category         string `json:"Category"`
	Size             int    `json:"Size"`
	PerformanceLevel string `json:"PerformanceLevel"`
	Type             string `json:"Type"`
	RegionId         string `json:"RegionId"`
	DiskId           string `json:"DiskId"`
	DiskChargeType   string `json:"DiskChargeType"`
}

type Disks added in v1.99.0

type Disks struct {
	Disk []*Disk `json:"Disk"`
}

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                  *ProviderConfig
	ServiceKeyProvided      bool
	ValidPricingKeys        map[string]bool

	*CustomProvider
	// contains filtered or unexported fields
}

GCP implements a provider interface for GCP

func (*GCP) AllNodePricing

func (gcp *GCP) AllNodePricing() (interface{}, error)

AllNodePricing returns the GCP pricing objects stored

func (*GCP) ApplyReservedInstancePricing

func (gcp *GCP) ApplyReservedInstancePricing(nodes map[string]*Node)

func (*GCP) ClusterInfo

func (gcp *GCP) ClusterInfo() (map[string]string, error)

ClusterInfo returns information on the GKE cluster, as provided by metadata.

func (*GCP) ClusterManagementPricing

func (gcp *GCP) ClusterManagementPricing() (string, float64, error)

func (*GCP) CombinedDiscountForNode

func (gcp *GCP) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64

func (*GCP) DownloadPricingData

func (gcp *GCP) DownloadPricingData() error

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 *GCP) GetAddresses() ([]byte, error)

func (*GCP) GetConfig

func (gcp *GCP) GetConfig() (*CustomPricing, error)

func (*GCP) GetDisks

func (gcp *GCP) GetDisks() ([]byte, error)

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

func (gcp *GCP) GetKey(labels map[string]string, n *v1.Node) Key

func (*GCP) GetLocalStorageQuery

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

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 *GCP) GetManagementPlatform() (string, error)

func (*GCP) GetOrphanedResources added in v1.99.0

func (gcp *GCP) GetOrphanedResources() ([]OrphanedResource, error)

func (*GCP) GetPVKey

func (gcp *GCP) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*GCP) LoadBalancerPricing

func (gcp *GCP) LoadBalancerPricing() (*LoadBalancer, error)

func (*GCP) NetworkPricing

func (gcp *GCP) NetworkPricing() (*Network, error)

Stubbed NetworkPricing for GCP. Pull directly from gcp.json for now

func (*GCP) NodePricing

func (gcp *GCP) NodePricing(key Key) (*Node, error)

NodePricing returns GCP pricing data for a single node

func (*GCP) PVPricing

func (gcp *GCP) PVPricing(pvk PVKey) (*PV, error)

func (*GCP) PricingSourceStatus

func (gcp *GCP) PricingSourceStatus() map[string]*PricingSource

func (*GCP) Regions

func (gcp *GCP) Regions() []string

func (*GCP) ServiceAccountStatus

func (gcp *GCP) ServiceAccountStatus() *ServiceAccountStatus

func (*GCP) UpdateConfig

func (gcp *GCP) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)

func (*GCP) UpdateConfigFromConfigMap

func (gcp *GCP) UpdateConfigFromConfigMap(a map[string]string) (*CustomPricing, error)

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                *Node            `json:"node"`
	PV                  *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 GCPReservedInstancePlan struct {
	Name    string
	CPUCost float64
	RAMCost float64
}

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 Key

type Key interface {
	ID() string       // ID represents an exact match
	Features() string // Features are a comma separated string of node metadata that could match pricing
	GPUType() string  // GPUType returns "" if no GPU exists or GPUs, but the name of the GPU otherwise
	GPUCount() int    // GPUCount returns 0 if no GPU exists or GPUs, but the number of attached GPUs otherwise
}

Key represents a way for nodes to match between the k8s API and a pricing API

type LoadBalancer

type LoadBalancer struct {
	IngressIPAddresses []string `json:"IngressIPAddresses"`
	Cost               float64  `json:"hourlyCost"`
}

LoadBalancer is the interface by which the provider and cost model communicate LoadBalancer prices. The provider will best-effort try to fill out this struct.

type Network

type Network struct {
	ZoneNetworkEgressCost     float64
	RegionNetworkEgressCost   float64
	InternetNetworkEgressCost float64
}

Network is the interface by which the provider and cost model communicate network egress prices. The provider will best-effort try to fill out this struct.

type Node

type Node struct {
	Cost             string                `json:"hourlyCost"`
	VCPU             string                `json:"CPU"`
	VCPUCost         string                `json:"CPUHourlyCost"`
	RAM              string                `json:"RAM"`
	RAMBytes         string                `json:"RAMBytes"`
	RAMCost          string                `json:"RAMGBHourlyCost"`
	Storage          string                `json:"storage"`
	StorageCost      string                `json:"storageHourlyCost"`
	UsesBaseCPUPrice bool                  `json:"usesDefaultPrice"`
	BaseCPUPrice     string                `json:"baseCPUPrice"` // Used to compute an implicit RAM GB/Hr price when RAM pricing is not provided.
	BaseRAMPrice     string                `json:"baseRAMPrice"` // Used to compute an implicit RAM GB/Hr price when RAM pricing is not provided.
	BaseGPUPrice     string                `json:"baseGPUPrice"`
	UsageType        string                `json:"usageType"`
	GPU              string                `json:"gpu"` // GPU represents the number of GPU on the instance
	GPUName          string                `json:"gpuName"`
	GPUCost          string                `json:"gpuCost"`
	InstanceType     string                `json:"instanceType,omitempty"`
	Region           string                `json:"region,omitempty"`
	Reserved         *ReservedInstanceData `json:"reserved,omitempty"`
	ProviderID       string                `json:"providerID,omitempty"`
	PricingType      PricingType           `json:"pricingType,omitempty"`
}

Node is the interface by which the provider and cost model communicate Node prices. The provider will best-effort try to fill out this struct.

func (*Node) IsSpot

func (n *Node) IsSpot() bool

IsSpot determines whether or not a Node uses spot by usage type

type NodePrice

type NodePrice struct {
	CPU string
	RAM string
	GPU string
}

type OrphanedResource added in v1.99.0

type OrphanedResource struct {
	Kind        string            `json:"resourceKind"`
	Region      string            `json:"region"`
	Description map[string]string `json:"description"`
	Size        *int64            `json:"diskSizeInGB,omitempty"`
	DiskName    string            `json:"diskName,omitempty"`
	Url         string            `json:"url"`
	Address     string            `json:"ipAddress,omitempty"`
	MonthlyCost *float64          `json:"monthlyCost"`
}

type OutOfClusterAllocation

type OutOfClusterAllocation struct {
	Aggregator  string  `json:"aggregator"`
	Environment string  `json:"environment"`
	Service     string  `json:"service"`
	Cost        float64 `json:"cost"`
	Cluster     string  `json:"cluster"`
}

OutOfClusterAllocation represents a cloud provider cost not associated with kubernetes

type PV

type PV struct {
	Cost       string            `json:"hourlyCost"`
	CostPerIO  string            `json:"costPerIOOperation"`
	Class      string            `json:"storageClass"`
	Size       string            `json:"size"`
	Region     string            `json:"region"`
	ProviderID string            `json:"providerID,omitempty"`
	Parameters map[string]string `json:"parameters"`
}

PV is the interface by which the provider and cost model communicate PV prices. The provider will best-effort try to fill out this struct.

type PVKey

type PVKey interface {
	Features() string
	GetStorageClass() string
	ID() string
}

type Price added in v1.99.0

type Price struct {
	OriginalPrice             float32 `json:"OriginalPrice"`
	ReservedInstanceHourPrice float32 `json:"ReservedInstanceHourPrice"`
	DiscountPrice             float32 `json:"DiscountPrice"`
	Currency                  string  `json:"Currency"`
	TradePrice                float32 `json:"TradePrice"`
}

Below structs are used to unmarshal json response of Alibaba cloud's API DescribePrice

type PriceInfo added in v1.99.0

type PriceInfo struct {
	Price Price `json:"Price"`
}

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 PricingMatchMetadata

type PricingMatchMetadata struct {
	TotalNodes        int                 `json:"TotalNodes"`
	PricingTypeCounts map[PricingType]int `json:"PricingType"`
}

type PricingSource

type PricingSource struct {
	Name      string `json:"name"`
	Enabled   bool   `json:"enabled"`
	Available bool   `json:"available"`
	Error     string `json:"error"`
}

type PricingSources

type PricingSources struct {
	PricingSources map[string]*PricingSource
}

type PricingType

type PricingType string
const (
	Api           PricingType = "api"
	Spot          PricingType = "spot"
	Reserved      PricingType = "reserved"
	SavingsPlan   PricingType = "savingsPlan"
	CsvExact      PricingType = "csvExact"
	CsvClass      PricingType = "csvClass"
	DefaultPrices PricingType = "defaultPrices"
)

type Provider

type Provider interface {
	ClusterInfo() (map[string]string, error)
	GetAddresses() ([]byte, error)
	GetDisks() ([]byte, error)
	GetOrphanedResources() ([]OrphanedResource, error)
	NodePricing(Key) (*Node, error)
	PVPricing(PVKey) (*PV, error)
	NetworkPricing() (*Network, error)           // TODO: add key interface arg for dynamic price fetching
	LoadBalancerPricing() (*LoadBalancer, error) // TODO: add key interface arg for dynamic price fetching
	AllNodePricing() (interface{}, error)
	DownloadPricingData() error
	GetKey(map[string]string, *v1.Node) Key
	GetPVKey(*v1.PersistentVolume, map[string]string, string) PVKey
	UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)
	UpdateConfigFromConfigMap(map[string]string) (*CustomPricing, error)
	GetConfig() (*CustomPricing, error)
	GetManagementPlatform() (string, error)
	GetLocalStorageQuery(time.Duration, time.Duration, bool, bool) string
	ApplyReservedInstancePricing(map[string]*Node)
	ServiceAccountStatus() *ServiceAccountStatus
	PricingSourceStatus() map[string]*PricingSource
	ClusterManagementPricing() (string, float64, error)
	CombinedDiscountForNode(string, bool, float64, float64) float64
	Regions() []string
}

Provider represents a k8s provider.

func NewProvider

func NewProvider(cache clustercache.ClusterCache, apiKey string, config *config.ConfigFileManager) (Provider, error)

NewProvider looks at the nodespec or provider metadata server to decide which provider to instantiate.

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() (*CustomPricing, error)

ThreadSafe method for retrieving the custom pricing config.

func (*ProviderConfig) Update

func (pc *ProviderConfig) Update(updateFunc func(*CustomPricing) error) (*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) (*CustomPricing, error)

ThreadSafe update of the config using a string map

type RIData

type RIData struct {
	ResourceID     string
	EffectiveCost  float64
	ReservationARN string
	MostRecentDate string
}

type ReservedInstanceData

type ReservedInstanceData struct {
	ReservedCPU int64   `json:"reservedCPU"`
	ReservedRAM int64   `json:"reservedRAM"`
	CPUCost     float64 `json:"CPUHourlyCost"`
	RAMCost     float64 `json:"RAMHourlyCost"`
}

ReservedInstanceData keeps record of resources on a node should be priced at reserved rates

type SavingsPlanData

type SavingsPlanData struct {
	ResourceID     string
	EffectiveCost  float64
	SavingsPlanARN string
	MostRecentDate string
}

type Scaleway added in v1.97.0

type Scaleway struct {
	Clientset               clustercache.ClusterCache
	Config                  *ProviderConfig
	Pricing                 map[string]*ScalewayPricing
	DownloadPricingDataLock sync.RWMutex
}

func (*Scaleway) AllNodePricing added in v1.97.0

func (c *Scaleway) AllNodePricing() (interface{}, error)

func (*Scaleway) ApplyReservedInstancePricing added in v1.97.0

func (*Scaleway) ApplyReservedInstancePricing(map[string]*Node)

func (*Scaleway) ClusterInfo added in v1.97.0

func (scw *Scaleway) ClusterInfo() (map[string]string, error)

func (*Scaleway) ClusterManagementPricing added in v1.97.0

func (*Scaleway) ClusterManagementPricing() (string, float64, error)

func (*Scaleway) CombinedDiscountForNode added in v1.97.0

func (c *Scaleway) CombinedDiscountForNode(instanceType string, isPreemptible bool, defaultDiscount, negotiatedDiscount float64) float64

func (*Scaleway) DownloadPricingData added in v1.97.0

func (c *Scaleway) DownloadPricingData() error

func (*Scaleway) GetAddresses added in v1.97.0

func (*Scaleway) GetAddresses() ([]byte, error)

func (*Scaleway) GetConfig added in v1.97.0

func (scw *Scaleway) GetConfig() (*CustomPricing, error)

func (*Scaleway) GetDisks added in v1.97.0

func (*Scaleway) GetDisks() ([]byte, error)

func (*Scaleway) GetKey added in v1.97.0

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

func (*Scaleway) GetLocalStorageQuery added in v1.97.0

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

func (*Scaleway) GetManagementPlatform added in v1.97.0

func (scw *Scaleway) GetManagementPlatform() (string, error)

func (*Scaleway) GetOrphanedResources added in v1.99.0

func (*Scaleway) GetOrphanedResources() ([]OrphanedResource, error)

func (*Scaleway) GetPVKey added in v1.97.0

func (c *Scaleway) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) PVKey

func (*Scaleway) LoadBalancerPricing added in v1.97.0

func (c *Scaleway) LoadBalancerPricing() (*LoadBalancer, error)

func (*Scaleway) NetworkPricing added in v1.97.0

func (c *Scaleway) NetworkPricing() (*Network, error)

func (*Scaleway) NodePricing added in v1.97.0

func (c *Scaleway) NodePricing(key Key) (*Node, error)

func (*Scaleway) PVPricing added in v1.97.0

func (c *Scaleway) PVPricing(pvk PVKey) (*PV, error)

func (*Scaleway) PricingSourceStatus added in v1.97.0

func (c *Scaleway) PricingSourceStatus() map[string]*PricingSource

func (*Scaleway) Regions added in v1.97.0

func (c *Scaleway) Regions() []string

func (*Scaleway) ServiceAccountStatus added in v1.97.0

func (c *Scaleway) ServiceAccountStatus() *ServiceAccountStatus

func (*Scaleway) UpdateConfig added in v1.97.0

func (c *Scaleway) UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)

func (*Scaleway) UpdateConfigFromConfigMap added in v1.97.0

func (c *Scaleway) UpdateConfigFromConfigMap(a map[string]string) (*CustomPricing, error)

type ScalewayPricing added in v1.97.0

type ScalewayPricing struct {
	NodesInfos map[string]*instance.ServerType
	PVCost     float64
}

type ServiceAccountCheck

type ServiceAccountCheck struct {
	Message        string `json:"message"`
	Status         bool   `json:"status"`
	AdditionalInfo string `json:"additionalInfo"`
}

type ServiceAccountChecks

type ServiceAccountChecks struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ServiceAccountChecks is a thread safe map for holding ServiceAccountCheck objects

func NewServiceAccountChecks

func NewServiceAccountChecks() *ServiceAccountChecks

NewServiceAccountChecks initialize ServiceAccountChecks

type ServiceAccountStatus

type ServiceAccountStatus struct {
	Checks []*ServiceAccountCheck `json:"checks"`
}

type SlimK8sDisk added in v1.99.0

type SlimK8sDisk struct {
	DiskType         string
	RegionID         string
	PriceUnit        string
	SizeInGiB        string
	DiskCategory     string
	PerformanceLevel string
	ProviderID       string
	StorageClass     string
}

Slim Version of k8s disk assigned to a node or PV.

func NewSlimK8sDisk added in v1.99.0

func NewSlimK8sDisk(diskType, regionID, priceUnit, diskCategory, performanceLevel, providerID, storageClass, sizeInGiB string) *SlimK8sDisk

type SlimK8sNode added in v1.99.0

type SlimK8sNode struct {
	InstanceType       string
	RegionID           string
	PriceUnit          string
	MemorySizeInKiB    string // TO-DO : Possible to convert to float?
	IsIoOptimized      bool
	OSType             string
	ProviderID         string
	SystemDisk         *SlimK8sDisk
	InstanceTypeFamily string // Bug in DescribePrice, doesn't default to enhanced type correctly and you get an error in DescribePrice to get around need the family of the InstanceType.
}

Slim version of a k8s v1.node just to pass along the object of this struct instead of constant getting the labels from within v1.Node & unit testing.

func NewSlimK8sNode added in v1.99.0

func NewSlimK8sNode(instanceType, regionID, priceUnit, memorySizeInKiB, osType, providerID, instanceTypeFamily string, isIOOptimized bool, systemDiskInfo *SlimK8sDisk) *SlimK8sNode

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.

Jump to

Keyboard shortcuts

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