Documentation
¶
Index ¶
- Constants
- func SetCustomPricingField(obj *CustomPricing, name string, value string) error
- type CustomPricing
- type Key
- type LoadBalancer
- type Network
- type Node
- type OrphanedResource
- type OutOfClusterAllocation
- type PV
- type PVKey
- type PricingMatchMetadata
- type PricingMetadata
- type PricingSource
- type PricingSources
- type PricingType
- type Provider
- type ProviderConfig
- type ReservedInstanceData
- type ServiceAccountCheck
- type ServiceAccountChecks
- type ServiceAccountStatus
Constants ¶
const ( AuthSecretPath = "/var/secrets/service-key.json" StorageConfigSecretPath = "/var/azure-storage-config/azure-storage-config.json" KarpenterCapacityTypeLabel = "karpenter.sh/capacity-type" KarpenterCapacitySpotTypeValue = "spot" )
Variables ¶
This section is empty.
Functions ¶
func SetCustomPricingField ¶
func SetCustomPricingField(obj *CustomPricing, name string, value string) error
Types ¶
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"`
AthenaCatalog string `json:"athenaCatalog"`
AthenaTable string `json:"athenaTable"`
AthenaWorkgroup string `json:"athenaWorkgroup"`
MasterPayerARN string `json:"masterPayerARN"`
AthenaCURVersion string `json:"athenaCURVersion,omitempty"` // "1.0" or "2.0", defaults to "2.0"
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"`
AzureBillingAccount string `json:"azureBillingAccount"`
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"`
ClusterName string `json:"clusterName"`
ClusterAccountID string `json:"clusterAccount,omitempty"`
ReadOnly string `json:"readOnly"`
EditorAccess string `json:"editorAccess"`
KubecostToken string `json:"kubecostToken"`
GoogleAnalyticsTag string `json:"googleAnalyticsTag"`
ExcludeProviderID string `json:"excludeProviderID"`
DefaultLBPrice string `json:"defaultLBPrice"`
}
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 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"`
VGPU string `json:"vgpu"` // virtualized gpu-- if we are using gpu replicas
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"`
ArchType string `json:"archType,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.
type OrphanedResource ¶
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 PricingMatchMetadata ¶
type PricingMatchMetadata struct {
TotalNodes int `json:"TotalNodes"`
PricingTypeCounts map[PricingType]int `json:"PricingType"`
}
type PricingMetadata ¶ added in v1.106.0
type PricingSource ¶
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, PricingMetadata, error)
GpuPricing(map[string]string) (string, 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, *clustercache.Node) Key
GetPVKey(*clustercache.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)
ApplyReservedInstancePricing(map[string]*Node)
ServiceAccountStatus() *ServiceAccountStatus
PricingSourceStatus() map[string]*PricingSource
ClusterManagementPricing() (string, float64, error)
CombinedDiscountForNode(string, bool, float64, float64) float64
Regions() []string
PricingSourceSummary() interface{}
}
Provider represents a k8s provider.
type ProviderConfig ¶
type ProviderConfig interface {
ConfigFileManager() *config.ConfigFileManager
GetCustomPricingData() (*CustomPricing, error)
Update(func(*CustomPricing) error) (*CustomPricing, error)
UpdateFromMap(map[string]string) (*CustomPricing, error)
}
ProviderConfig describes config storage common to all providers.
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 ServiceAccountCheck ¶
type ServiceAccountChecks ¶
ServiceAccountChecks is a thread safe map for holding ServiceAccountCheck objects
func NewServiceAccountChecks ¶
func NewServiceAccountChecks() *ServiceAccountChecks
NewServiceAccountChecks initialize ServiceAccountChecks
func (*ServiceAccountChecks) GetStatus ¶
func (sac *ServiceAccountChecks) GetStatus() *ServiceAccountStatus
getStatus extracts ServiceAccountCheck objects into a slice and returns them in a ServiceAccountStatus
func (*ServiceAccountChecks) Set ¶
func (sac *ServiceAccountChecks) Set(key string, check *ServiceAccountCheck)
type ServiceAccountStatus ¶
type ServiceAccountStatus struct {
Checks []*ServiceAccountCheck `json:"checks"`
}