Documentation
¶
Index ¶
- Constants
- func ConvertAlibabaInfoToConfig(acc AlibabaInfo) cloud.KeyedConfig
- func GetBoaQueryInstanceBillFunc(fn func(bssopenapi.Item) error, billingDate string) func(output *bssopenapi.QueryInstanceBillResponse) bool
- func SelectAlibabaCategory(item bssopenapi.Item) string
- type AccessKey
- type Alibaba
- func (alibaba *Alibaba) AllNodePricing() (interface{}, error)
- func (alibaba *Alibaba) ApplyReservedInstancePricing(nodes map[string]*models.Node)
- func (alibaba *Alibaba) ClusterInfo() (map[string]string, error)
- func (alibaba *Alibaba) ClusterManagementPricing() (string, float64, error)
- func (alibaba *Alibaba) CombinedDiscountForNode(string, bool, float64, float64) float64
- func (alibaba *Alibaba) DownloadPricingData() error
- func (alibaba *Alibaba) GetAddresses() ([]byte, error)
- func (alibaba *Alibaba) GetAlibabaAccessKey() (*credentials.AccessKeyCredential, error)
- func (alibaba *Alibaba) GetAlibabaCloudInfo() (*AlibabaInfo, error)
- func (alibaba *Alibaba) GetConfig() (*models.CustomPricing, error)
- func (alibaba *Alibaba) GetDisks() ([]byte, error)
- func (alibaba *Alibaba) GetKey(mapValue map[string]string, node *v1.Node) models.Key
- func (alibaba *Alibaba) GetLocalStorageQuery(window, offset time.Duration, rate bool, used bool) string
- func (alibaba *Alibaba) GetManagementPlatform() (string, error)
- func (alibaba *Alibaba) GetOrphanedResources() ([]models.OrphanedResource, error)
- func (alibaba *Alibaba) GetPVKey(pv *v1.PersistentVolume, parameters map[string]string, defaultRegion string) models.PVKey
- func (alibaba *Alibaba) LoadBalancerPricing() (*models.LoadBalancer, error)
- func (alibaba *Alibaba) NetworkPricing() (*models.Network, error)
- func (alibaba *Alibaba) NodePricing(key models.Key) (*models.Node, models.PricingMetadata, error)
- func (alibaba *Alibaba) PVPricing(pvk models.PVKey) (*models.PV, error)
- func (alibaba *Alibaba) PricingSourceStatus() map[string]*models.PricingSource
- func (a *Alibaba) PricingSourceSummary() interface{}
- func (alibaba *Alibaba) Regions() []string
- func (alibaba *Alibaba) ServiceAccountStatus() *models.ServiceAccountStatus
- func (alibaba *Alibaba) UpdateConfig(r io.Reader, updateType string) (*models.CustomPricing, error)
- func (alibaba *Alibaba) UpdateConfigFromConfigMap(cm map[string]string) (*models.CustomPricing, error)
- type AlibabaAccessKey
- type AlibabaInfo
- type AlibabaNodeAttributes
- type AlibabaNodeKey
- func (alibabaNodeKey *AlibabaNodeKey) Features() string
- func (alibabaNodeKey *AlibabaNodeKey) FeaturesWithOtherDisk(overrideDiskCategory string) string
- func (alibabaNodeKey *AlibabaNodeKey) GPUCount() int
- func (alibabaNodeKey *AlibabaNodeKey) GPUType() string
- func (alibabaNodeKey *AlibabaNodeKey) ID() string
- type AlibabaPVAttributes
- type AlibabaPVKey
- type AlibabaPricing
- type AlibabaPricingDetails
- type AlibabaPricingTerms
- type Authorizer
- type BOAConfiguration
- func (bc *BOAConfiguration) Equals(config cloud.Config) bool
- func (bc *BOAConfiguration) Key() string
- func (bc *BOAConfiguration) Provider() string
- func (bc *BOAConfiguration) Sanitize() cloud.Config
- func (bc *BOAConfiguration) UnmarshalJSON(b []byte) error
- func (bc *BOAConfiguration) Validate() error
- type BoaQuerier
- func (bq *BoaQuerier) Equals(config cloud.Config) bool
- func (bq *BoaQuerier) GetStatus() cloud.ConnectionStatus
- func (bq *BoaQuerier) QueryBoaPaginated(client *bssopenapi.Client, isBillingItem bool, ...) error
- func (bq *BoaQuerier) QueryInstanceBill(client *bssopenapi.Client, isBillingItem bool, ...) (*bssopenapi.QueryInstanceBillResponse, error)
- type DescribeDiskResponse
- type DescribePriceResponse
- type Disk
- type Disks
- type Price
- type PriceInfo
- type SlimK8sDisk
- type SlimK8sNode
Constants ¶
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" )
const AccessKeyAuthorizerType = "AlibabaAccessKey"
Variables ¶
This section is empty.
Functions ¶
func ConvertAlibabaInfoToConfig ¶
func ConvertAlibabaInfoToConfig(acc AlibabaInfo) cloud.KeyedConfig
func GetBoaQueryInstanceBillFunc ¶
func GetBoaQueryInstanceBillFunc(fn func(bssopenapi.Item) error, billingDate string) func(output *bssopenapi.QueryInstanceBillResponse) bool
GetBoaQueryInstanceBillFunc gives the item to the handler function in boaIntegration.go to process computeItem, topNItem and aggregatedItem
func SelectAlibabaCategory ¶
func SelectAlibabaCategory(item bssopenapi.Item) string
SelectAlibabaCategory processes the Alibaba service to associated Kubecost category
Types ¶
type AccessKey ¶
type AccessKey struct { AccessKeyID string `json:"accessKeyID"` AccessKeySecret string `json:"accessKeySecret"` }
AccessKey holds Alibaba credentials parsing from the service-key.json file.
func (*AccessKey) GetCredentials ¶
func (ak *AccessKey) GetCredentials() (auth.Credential, error)
GetCredentials creates a credentials object to authorize the use of service sdk calls
func (*AccessKey) MarshalJSON ¶
MarshalJSON custom json marshalling functions, sets properties as tagged in struct and sets the authorizer type property
type Alibaba ¶
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 models.ProviderConfig ServiceAccountChecks *models.ServiceAccountChecks ClusterAccountId string ClusterRegion string // contains filtered or unexported fields }
Alibaba cloud's Provider struct
func (*Alibaba) AllNodePricing ¶
AllNodePricing returns all the pricing data for all nodes and pvs
func (*Alibaba) ApplyReservedInstancePricing ¶
Will look at this in Next PR if needed
func (*Alibaba) ClusterInfo ¶
ClusterInfo returns information about Alibaba Cloud cluster, as provided by metadata.
func (*Alibaba) ClusterManagementPricing ¶
Will look at this in Next PR if needed
func (*Alibaba) CombinedDiscountForNode ¶
Will look at this in Next PR if needed
func (*Alibaba) DownloadPricingData ¶
DownloadPricingData satisfies the provider interface and downloads the prices for Node instances and PVs.
func (*Alibaba) GetAddresses ¶
Will look at this in Next PR if needed
func (*Alibaba) GetAlibabaAccessKey ¶
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 ¶
func (alibaba *Alibaba) GetAlibabaCloudInfo() (*AlibabaInfo, error)
func (*Alibaba) GetLocalStorageQuery ¶
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 ¶
Will look at this in Next PR if needed
func (*Alibaba) GetOrphanedResources ¶
func (alibaba *Alibaba) GetOrphanedResources() ([]models.OrphanedResource, error)
func (*Alibaba) LoadBalancerPricing ¶
func (alibaba *Alibaba) LoadBalancerPricing() (*models.LoadBalancer, error)
Alibaba loadbalancer has three different types https://www.alibabacloud.com/product/server-load-balancer, defaulted price to classic load balancer https://www.alibabacloud.com/help/en/server-load-balancer/latest/pay-as-you-go.
func (*Alibaba) NetworkPricing ¶
Inter zone and Inter region network cost are defaulted based on https://www.alibabacloud.com/help/en/cloud-data-transmission/latest/cross-region-data-transfers Internet cost is default based on https://www.alibabacloud.com/help/en/elastic-compute-service/latest/public-bandwidth to $0.123
func (*Alibaba) NodePricing ¶
NodePricing gives pricing information of a specific node given by the key
func (*Alibaba) PricingSourceStatus ¶
func (alibaba *Alibaba) PricingSourceStatus() map[string]*models.PricingSource
Will look at this in Next PR if needed
func (*Alibaba) PricingSourceSummary ¶
func (a *Alibaba) PricingSourceSummary() interface{}
PricingSourceSummary returns the pricing source summary for the provider. The summary represents what was _parsed_ from the pricing source, not everything that was _available_ in the pricing source.
func (*Alibaba) ServiceAccountStatus ¶
func (alibaba *Alibaba) ServiceAccountStatus() *models.ServiceAccountStatus
Will look at this in Next PR if needed
func (*Alibaba) UpdateConfig ¶
func (*Alibaba) UpdateConfigFromConfigMap ¶
type AlibabaAccessKey ¶
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. Deprecated: v1.104 Use AccessKey instead
type AlibabaInfo ¶
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 Deprecated: v1.104 Use BOAConfiguration instead
func (*AlibabaInfo) IsEmpty ¶
func (ai *AlibabaInfo) IsEmpty() bool
IsEmpty returns true if all fields in config are empty, false if not.
type AlibabaNodeAttributes ¶
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 ¶
func NewAlibabaNodeAttributes(node *SlimK8sNode) *AlibabaNodeAttributes
type AlibabaNodeKey ¶
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 ¶
func NewAlibabaNodeKey(node *SlimK8sNode, optimizedKeyword, systemDiskCategory, systemDiskSizeInGiB, systemDiskPerfromanceLevel string) *AlibabaNodeKey
func (*AlibabaNodeKey) Features ¶
func (alibabaNodeKey *AlibabaNodeKey) Features() string
func (*AlibabaNodeKey) FeaturesWithOtherDisk ¶ added in v1.111.0
func (alibabaNodeKey *AlibabaNodeKey) FeaturesWithOtherDisk(overrideDiskCategory string) string
func (*AlibabaNodeKey) GPUCount ¶
func (alibabaNodeKey *AlibabaNodeKey) GPUCount() int
func (*AlibabaNodeKey) GPUType ¶
func (alibabaNodeKey *AlibabaNodeKey) GPUType() string
func (*AlibabaNodeKey) ID ¶
func (alibabaNodeKey *AlibabaNodeKey) ID() string
type AlibabaPVAttributes ¶
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 ¶
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 ¶
type AlibabaPVKey struct { ProviderID string RegionID string PVType string PVSubType string PVCategory string PVPerformaceLevel string StorageClassName string SizeInGiB string }
func (*AlibabaPVKey) Features ¶
func (alibabaPVKey *AlibabaPVKey) Features() string
func (*AlibabaPVKey) GetStorageClass ¶
func (alibabaPVKey *AlibabaPVKey) GetStorageClass() string
Get storage class information for PV.
func (*AlibabaPVKey) ID ¶
func (alibabaPVKey *AlibabaPVKey) ID() string
type AlibabaPricing ¶
type AlibabaPricing struct { NodeAttributes *AlibabaNodeAttributes PVAttributes *AlibabaPVAttributes PricingTerms *AlibabaPricingTerms Node *models.Node PV *models.PV }
Alibaba Pricing struct carry the Attributes and pricing information for Node or PV
type AlibabaPricingDetails ¶
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 ¶
func NewAlibabaPricingDetails(hourlyPrice float32, priceUnit string, tradePrice float32, currencyCode string) *AlibabaPricingDetails
type AlibabaPricingTerms ¶
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 ¶
func NewAlibabaPricingTerms(billingMethod string, pricingDetails *AlibabaPricingDetails) *AlibabaPricingTerms
type Authorizer ¶
type Authorizer interface { cloud.Authorizer GetCredentials() (auth.Credential, error) }
Authorizer provide *bssopenapi.Client for Alibaba cloud BOS for Billing related SDK calls
func SelectAuthorizerByType ¶
func SelectAuthorizerByType(typeStr string) (Authorizer, error)
SelectAuthorizerByType is an implementation of AuthorizerSelectorFn and acts as a register for Authorizer types
type BOAConfiguration ¶
type BOAConfiguration struct { Account string `json:"account"` Region string `json:"region"` Authorizer Authorizer `json:"authorizer"` }
BOAConfiguration is the BSS open API configuration for Alibaba's Billing information
func (*BOAConfiguration) Key ¶
func (bc *BOAConfiguration) Key() string
func (*BOAConfiguration) Provider ¶ added in v1.108.0
func (bc *BOAConfiguration) Provider() string
func (*BOAConfiguration) Sanitize ¶
func (bc *BOAConfiguration) Sanitize() cloud.Config
func (*BOAConfiguration) UnmarshalJSON ¶
func (bc *BOAConfiguration) UnmarshalJSON(b []byte) error
func (*BOAConfiguration) Validate ¶
func (bc *BOAConfiguration) Validate() error
type BoaQuerier ¶
type BoaQuerier struct { BOAConfiguration ConnectionStatus cloud.ConnectionStatus }
func (*BoaQuerier) GetStatus ¶ added in v1.107.0
func (bq *BoaQuerier) GetStatus() cloud.ConnectionStatus
func (*BoaQuerier) QueryBoaPaginated ¶
func (bq *BoaQuerier) QueryBoaPaginated(client *bssopenapi.Client, isBillingItem bool, invocationScheme, granularity, billingCycle, billingDate string, fn func(*bssopenapi.QueryInstanceBillResponse) bool) error
QueryBoaPaginated Calls the API in a paginated fashion. There's no paramter in API that can distinguish if it hasMorePages hence the logic of processedItem <= TotalItem.
func (*BoaQuerier) QueryInstanceBill ¶
func (bq *BoaQuerier) QueryInstanceBill(client *bssopenapi.Client, isBillingItem bool, invocationScheme, granularity, billingCycle, billingDate string, pageNum int) (*bssopenapi.QueryInstanceBillResponse, error)
QueryInstanceBill performs the request to the BSS client and get the response for the current page number
type DescribeDiskResponse ¶
type DescribePriceResponse ¶
type Price ¶
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 SlimK8sDisk ¶
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 ¶
func NewSlimK8sDisk(diskType, regionID, priceUnit, diskCategory, performanceLevel, providerID, storageClass, sizeInGiB string) *SlimK8sDisk
type SlimK8sNode ¶
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 ¶
func NewSlimK8sNode(instanceType, regionID, priceUnit, memorySizeInKiB, osType, providerID, instanceTypeFamily string, isIOOptimized bool, systemDiskInfo *SlimK8sDisk) *SlimK8sNode