Documentation
¶
Index ¶
- Constants
- Variables
- func ClusterDisks(dataSource source.OpenCostDataSource, cp models.Provider, start, end time.Time) (map[DiskIdentifier]*Disk, error)
- func ClusterLoadBalancers(dataSource source.OpenCostDataSource, start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
- func ClusterManagement(dataSource source.OpenCostDataSource, start, end time.Time) (map[ClusterManagementIdentifier]*ClusterManagementCost, error)
- func ClusterNodes(dataSource source.OpenCostDataSource, cp models.Provider, start, end time.Time) (map[NodeIdentifier]*Node, error)
- func GetContainerMetricVector(qrs []*source.ContainerMetricResult, defaultClusterID string) (map[string][]*util.Vector, error)
- func GetContainerMetricVectors(qrs []*source.ContainerMetricResult, defaultClusterID string) (map[string][]*util.Vector, error)
- func GetDeploymentMatchLabelsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetNamespaceAnnotationsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetNamespaceLabelsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetNetworkCost(usage *NetworkUsageData, cloud costAnalyzerCloud.Provider) ([]*util.Vector, error)
- func GetNetworkUsageData(zr []*source.NetZoneGiBResult, rr []*source.NetRegionGiBResult, ...) (map[string]*NetworkUsageData, error)
- func GetNormalizedContainerMetricVectors(qrs []*source.QueryResult, normalizationValues []*util.Vector, ...) (map[string][]*util.Vector, error)
- func GetPVAllocationMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string][]*PersistentVolumeClaimData, error)
- func GetPVCostMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]*costAnalyzerCloud.PV, error)
- func GetPVInfo(qrs []*source.QueryResult, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
- func GetPVInfoLocal(cache clustercache.ClusterCache, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
- func GetPodAnnotationsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetPodDaemonsetsWithMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]string, error)
- func GetPodJobsWithMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]string, error)
- func GetPodLabelsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetServiceSelectorLabelsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetStatefulsetMatchLabelsMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func InitializeCloudCost(router *httprouter.Router, providerConfig models.ProviderConfig)
- func InitializeCustomCost(router *httprouter.Router) *customcost.PipelineService
- func NewClusterInfoWriteOnRequest(clusterInfo clusters.ClusterInfoProvider, config *config.ConfigFile) clusters.ClusterInfoProvider
- func NewConfiguredClusterInfoProvider(config *config.ConfigFile) clusters.ClusterInfoProvider
- func NewLocalClusterInfoProvider(k8s kubernetes.Interface, cloud cloudProvider.Provider) clusters.ClusterInfoProvider
- func NewNodeClientConfigFromEnv() (*nodes.NodeClientConfig, error)
- func ParseAggregationProperties(aggregations []string) ([]string, error)
- func ParsePercentString(percentStr string) (float64, error)
- func UpdateCSV(ctx context.Context, fileManager filemanager.FileManager, ...) error
- func WriteData(w http.ResponseWriter, data interface{}, err error)
- type Accesses
- func (a *Accesses) AddServiceKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ClusterInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAllocationHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAllocationHandlerSummary(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAssetsCarbonHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAssetsFromCostmodel(window opencost.Window, filterString string) (*opencost.AssetSet, error)
- func (a *Accesses) ComputeAssetsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) CostDataModel(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllNodePricing(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetClusterInfoMap(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetHelmValues(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetInstallInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) GetInstallNamespace(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) GetOrphanedPods(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetPricingSourceCounts(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetPricingSourceStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetPricingSourceSummary(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (a *Accesses) GetServiceAccountStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) InitializeSettingsPubSub()
- func (a *Accesses) ManagementPlatform(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) RefreshPricingData(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) SubscribeToCustomPricingChanges(ch chan string)
- func (a *Accesses) SubscribeToDiscountChanges(ch chan string)
- func (a *Accesses) UpdateAthenaInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateAzureStorageConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateBigQueryInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateConfigByKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateSpotInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type AllocationModel
- type ClusterCosts
- type ClusterCostsBreakdown
- type ClusterInfoCollector
- type ClusterInfoMetric
- type ClusterManagementCost
- type ClusterManagementIdentifier
- type CoefficientComponent
- type ContainerInfo
- type ContainerMetric
- func NewContainerMetricFrom(result *source.ContainerMetricResult, defaultClusterID string) (*ContainerMetric, error)
- func NewContainerMetricFromKey(key string) (*ContainerMetric, error)
- func NewContainerMetricFromResult(result *source.QueryResult, defaultClusterID string) (*ContainerMetric, error)
- func NewContainerMetricFromValues(ns, podName, containerName, nodeName, clusterId string) *ContainerMetric
- func NewContainerMetricsFromPod(pod *clustercache.Pod, clusterID string) ([]*ContainerMetric, error)
- type CostData
- type CostModel
- func (cm *CostModel) CanCompute(start, end time.Time) bool
- func (cm *CostModel) ClusterDisks(start, end time.Time) (map[DiskIdentifier]*Disk, error)
- func (cm *CostModel) ClusterLoadBalancers(start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
- func (cm *CostModel) ClusterManagement(start, end time.Time) (map[ClusterManagementIdentifier]*ClusterManagementCost, error)
- func (cm *CostModel) ClusterNodes(start, end time.Time) (map[NodeIdentifier]*Node, error)
- func (cm *CostModel) ComputeAllocation(start, end time.Time) (*opencost.AllocationSet, error)
- func (cm *CostModel) ComputeAssets(start, end time.Time) (*opencost.AssetSet, error)
- func (cm *CostModel) ComputeCostData(start, end time.Time) (map[string]*CostData, error)
- func (cm *CostModel) ComputeNetworkInsights(start, end time.Time) (*opencost.NetworkInsightSet, error)
- func (cm *CostModel) DateRange(limitDays int) (time.Time, time.Time, error)
- func (cm *CostModel) GetDataSource() source.OpenCostDataSource
- func (cm *CostModel) GetLBCost() (map[serviceKey]*costAnalyzerCloud.LoadBalancer, error)
- func (cm *CostModel) GetNetworkInsightSet(start, end time.Time) (*opencost.NetworkInsightSet, error)
- func (cm *CostModel) GetNodeCost() (map[string]*costAnalyzerCloud.Node, error)
- func (cm *CostModel) GetPVCost(pv *costAnalyzerCloud.PV, kpv *clustercache.PersistentVolume, ...) error
- func (cm *CostModel) GetPricingSourceCounts() (*costAnalyzerCloud.PricingMatchMetadata, error)
- func (cm *CostModel) Name() string
- func (cm *CostModel) PropertiesFromCluster(props *opencost.AssetProperties)
- func (cm *CostModel) QueryAllocation(window opencost.Window, step time.Duration, aggregate []string, ...) (*opencost.AllocationSetRange, error)
- type CostModelMetricsEmitter
- type Disk
- type DiskIdentifier
- type InstallInfo
- type IntervalPoint
- type IntervalPoints
- type KeyTuple
- type LoadBalancer
- type LoadBalancerIdentifier
- type NetworkUsageData
- type NetworkUsageVector
- type Node
- type NodeCostAverages
- type NodeIdentifier
- type NodeOverhead
- type PersistentVolumeClaimData
Constants ¶
const ( // SplitTypeWeighted signals that shared costs should be shared // proportionally, rather than evenly SplitTypeWeighted = "weighted" // UnallocatedSubfield indicates an allocation datum that does not have the // chosen Aggregator; e.g. during aggregation by some label, there may be // cost data that do not have the given label. UnallocatedSubfield = "__unallocated__" )
const ( GpuUsageAverageMode = "AVERAGE" GpuUsageMaxMode = "MAX" GpuInfoMode = "GPU_INFO" )
const ( RFC3339Milli = "2006-01-02T15:04:05.000Z" CustomPricingSetting = "CustomPricing" DiscountSetting = "Discount" )
const CPU_SANITY_LIMIT = 512
This is a bit of a hack to work around garbage data from cadvisor Ideally you cap each pod to the max CPU on its node, but that involves a bit more complexity, as it it would need to be done when allocations joins with asset data.
const GiB = 1024.0 * MiB
const KiB = 1024.0
Sanity Limit for PV usage, set to 10 PB, in bytes for now
const MAX_LOCAL_STORAGE_SIZE = 1024 * 1024 * 1024 * 1024
const MiB = 1024.0 * KiB
const PV_USAGE_SANITY_LIMIT_BYTES = 10.0 * PiB
const PiB = 1024.0 * TiB
const SIG_STORAGE_LOCAL_PROVISIONER_PREFIX = "local-pv-"
When ASSET_INCLUDE_LOCAL_DISK_COST is set to false, local storage provisioned by sig-storage-local-static-provisioner is excluded by checking if the volume is prefixed by "local-pv-".
This is based on the sig-storage-local-static-provisioner implementation, which creates all PVs with the "local-pv-" prefix. For reference, see: https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner/blob/b6f465027bd059e92c0032c81dd1e1d90e35c909/pkg/discovery/discovery.go#L410-L417
const TiB = 1024.0 * GiB
Variables ¶
var ( // Static KeyTuple Errors ErrNewKeyTuple = errors.New("new-key-tuple: key not containing exactly 3 components") // Static Errors for ContainerMetric creation ErrInvalidKey error = errors.New("not a valid key") ErrNoContainer error = errors.New("vector does not have container name") ErrNoContainerName error = errors.New("vector does not have string container name") ErrNoPod error = errors.New("vector does not have pod name") ErrNoPodName error = errors.New("vector does not have string pod name") ErrNoNamespace error = errors.New("vector does not have namespace") ErrNoNamespaceName error = errors.New("vector does not have string namespace") ErrNoNodeName error = errors.New("vector does not have string node") ErrNoClusterID error = errors.New("vector does not have string cluster id") )
Functions ¶
func ClusterDisks ¶
func ClusterDisks(dataSource source.OpenCostDataSource, cp models.Provider, start, end time.Time) (map[DiskIdentifier]*Disk, error)
func ClusterLoadBalancers ¶
func ClusterLoadBalancers(dataSource source.OpenCostDataSource, start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
func ClusterManagement ¶ added in v1.115.0
func ClusterManagement(dataSource source.OpenCostDataSource, start, end time.Time) (map[ClusterManagementIdentifier]*ClusterManagementCost, error)
func ClusterNodes ¶
func ClusterNodes(dataSource source.OpenCostDataSource, cp models.Provider, start, end time.Time) (map[NodeIdentifier]*Node, error)
func GetNetworkCost ¶
func GetNetworkCost(usage *NetworkUsageData, cloud costAnalyzerCloud.Provider) ([]*util.Vector, error)
GetNetworkCost computes the actual cost for NetworkUsageData based on data provided by the Provider.
func GetNetworkUsageData ¶
func GetNetworkUsageData(zr []*source.NetZoneGiBResult, rr []*source.NetRegionGiBResult, ir []*source.NetInternetGiBResult, defaultClusterID string) (map[string]*NetworkUsageData, error)
GetNetworkUsageData performs a join of the the results of zone, region, and internet usage queries to return a single map containing network costs for each namespace+pod
func GetPVAllocationMetrics ¶
func GetPVAllocationMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string][]*PersistentVolumeClaimData, error)
func GetPVCostMetrics ¶
func GetPVCostMetrics(qrs []*source.QueryResult, defaultClusterID string) (map[string]*costAnalyzerCloud.PV, error)
func GetPVInfo ¶
func GetPVInfo(qrs []*source.QueryResult, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
func GetPVInfoLocal ¶
func GetPVInfoLocal(cache clustercache.ClusterCache, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
func GetPodJobsWithMetrics ¶
func GetPodLabelsMetrics ¶
func InitializeCloudCost ¶ added in v1.111.0
func InitializeCloudCost(router *httprouter.Router, providerConfig models.ProviderConfig)
InitializeCloudCost Initializes Cloud Cost pipeline and querier and registers endpoints
func InitializeCustomCost ¶ added in v1.111.0
func InitializeCustomCost(router *httprouter.Router) *customcost.PipelineService
func NewClusterInfoWriteOnRequest ¶
func NewClusterInfoWriteOnRequest(clusterInfo clusters.ClusterInfoProvider, config *config.ConfigFile) clusters.ClusterInfoProvider
NewClusterInfoWriteOnRequest instantiates and returns a cluster info provider which writes the cluster info to a configuration before each request.
func NewConfiguredClusterInfoProvider ¶
func NewConfiguredClusterInfoProvider(config *config.ConfigFile) clusters.ClusterInfoProvider
NewConfiguredClusterInfoProvider instantiates and returns a cluster info provider which loads cluster info from a config file.
func NewLocalClusterInfoProvider ¶
func NewLocalClusterInfoProvider(k8s kubernetes.Interface, cloud cloudProvider.Provider) clusters.ClusterInfoProvider
NewLocalClusterInfoProvider creates a new clusters.LocalClusterInfoProvider implementation for providing local cluster information
func NewNodeClientConfigFromEnv ¶ added in v1.115.0
func NewNodeClientConfigFromEnv() (*nodes.NodeClientConfig, error)
func ParseAggregationProperties ¶
ParseAggregationProperties attempts to parse and return aggregation properties encoded under the given key. If none exist, or if parsing fails, an error is returned with empty AllocationProperties.
func ParsePercentString ¶
ParsePercentString takes a string of expected format "N%" and returns a floating point 0.0N. If the "%" symbol is missing, it just returns 0.0N. Empty string is interpreted as "0%" and return 0.0.
func UpdateCSV ¶ added in v1.103.0
func UpdateCSV(ctx context.Context, fileManager filemanager.FileManager, model AllocationModel, labelsAll bool, labels []string) error
func WriteData ¶ added in v1.115.0
func WriteData(w http.ResponseWriter, data interface{}, err error)
Types ¶
type Accesses ¶
type Accesses struct {
DataSource source.OpenCostDataSource
KubeClientSet kubernetes.Interface
ClusterCache clustercache.ClusterCache
ClusterMap clusters.ClusterMap
CloudProvider models.Provider
ConfigFileManager *config.ConfigFileManager
ClusterInfoProvider clusters.ClusterInfoProvider
Model *CostModel
MetricsEmitter *CostModelMetricsEmitter
// SettingsCache stores current state of app settings
SettingsCache *cache.Cache
// contains filtered or unexported fields
}
Accesses defines a singleton application instance, providing access to Prometheus, Kubernetes, the cloud provider, and caches.
func Initialize ¶
func Initialize(router *httprouter.Router, additionalConfigWatchers ...*watcher.ConfigMapWatcher) *Accesses
func (*Accesses) AddServiceKey ¶
func (a *Accesses) AddServiceKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ClusterInfo ¶
func (a *Accesses) ClusterInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ComputeAllocationHandler ¶
func (a *Accesses) ComputeAllocationHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ComputeAllocationHandler computes an AllocationSetRange from the CostModel.
func (*Accesses) ComputeAllocationHandlerSummary ¶
func (a *Accesses) ComputeAllocationHandlerSummary(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ComputeAssetsCarbonHandler ¶ added in v1.111.0
func (a *Accesses) ComputeAssetsCarbonHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ComputeAllocationHandler returns the assets from the CostModel.
func (*Accesses) ComputeAssetsFromCostmodel ¶ added in v1.115.0
func (*Accesses) ComputeAssetsHandler ¶ added in v1.104.0
func (a *Accesses) ComputeAssetsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ComputeAllocationHandler returns the assets from the CostModel.
func (*Accesses) CostDataModel ¶
func (a *Accesses) CostDataModel(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllNodePricing ¶
func (a *Accesses) GetAllNodePricing(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetClusterInfoMap ¶
func (a *Accesses) GetClusterInfoMap(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetConfigs ¶
func (a *Accesses) GetConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetHelmValues ¶
func (a *Accesses) GetHelmValues(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetInstallInfo ¶
func (a *Accesses) GetInstallInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) GetInstallNamespace ¶
func (a *Accesses) GetInstallNamespace(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) GetOrphanedPods ¶
func (a *Accesses) GetOrphanedPods(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetPricingSourceCounts ¶
func (a *Accesses) GetPricingSourceCounts(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) GetPricingSourceStatus ¶
func (a *Accesses) GetPricingSourceStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) GetPricingSourceSummary ¶ added in v1.102.0
func (a *Accesses) GetPricingSourceSummary(w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Accesses) GetServiceAccountStatus ¶
func (a *Accesses) GetServiceAccountStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) InitializeSettingsPubSub ¶
func (a *Accesses) InitializeSettingsPubSub()
InitializeSettingsPubSub sets up the pub/sub mechanisms and kicks of routines to detect and publish changes, as well as some routines that subscribe and take actions.
func (*Accesses) ManagementPlatform ¶
func (a *Accesses) ManagementPlatform(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) RefreshPricingData ¶
func (a *Accesses) RefreshPricingData(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
RefreshPricingData needs to be called when a new node joins the fleet, since we cache the relevant subsets of pricing data to avoid storing the whole thing.
func (*Accesses) SubscribeToCustomPricingChanges ¶
SubscribeToCustomPricingChanges subscribes the given channel to receive custom pricing changes.
func (*Accesses) SubscribeToDiscountChanges ¶
SubscribeToDiscountChanges subscribes the given channel to receive discount changes.
func (*Accesses) UpdateAthenaInfoConfigs ¶
func (a *Accesses) UpdateAthenaInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateAzureStorageConfigs ¶
func (a *Accesses) UpdateAzureStorageConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateBigQueryInfoConfigs ¶
func (a *Accesses) UpdateBigQueryInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateConfigByKey ¶
func (a *Accesses) UpdateConfigByKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateSpotInfoConfigs ¶
func (a *Accesses) UpdateSpotInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
type AllocationModel ¶ added in v1.103.0
type ClusterCosts ¶
type ClusterCosts struct {
Start *time.Time `json:"startTime"`
End *time.Time `json:"endTime"`
CPUCumulative float64 `json:"cpuCumulativeCost"`
CPUMonthly float64 `json:"cpuMonthlyCost"`
CPUBreakdown *ClusterCostsBreakdown `json:"cpuBreakdown"`
GPUCumulative float64 `json:"gpuCumulativeCost"`
GPUMonthly float64 `json:"gpuMonthlyCost"`
RAMCumulative float64 `json:"ramCumulativeCost"`
RAMMonthly float64 `json:"ramMonthlyCost"`
RAMBreakdown *ClusterCostsBreakdown `json:"ramBreakdown"`
StorageCumulative float64 `json:"storageCumulativeCost"`
StorageMonthly float64 `json:"storageMonthlyCost"`
StorageBreakdown *ClusterCostsBreakdown `json:"storageBreakdown"`
TotalCumulative float64 `json:"totalCumulativeCost"`
TotalMonthly float64 `json:"totalMonthlyCost"`
DataMinutes float64
}
Costs represents cumulative and monthly cluster costs over a given duration. Costs are broken down by cores, memory, and storage.
type ClusterCostsBreakdown ¶
type ClusterCostsBreakdown struct {
Idle float64 `json:"idle"`
Other float64 `json:"other"`
System float64 `json:"system"`
User float64 `json:"user"`
}
ClusterCostsBreakdown provides percentage-based breakdown of a resource by categories: user for user-space (i.e. non-system) usage, system, and idle.
type ClusterInfoCollector ¶
type ClusterInfoCollector struct {
ClusterInfo clusters.ClusterInfoProvider
// contains filtered or unexported fields
}
ClusterInfoCollector is a prometheus collector that generates ClusterInfoMetrics
func (ClusterInfoCollector) Collect ¶
func (cic ClusterInfoCollector) Collect(ch chan<- prometheus.Metric)
Collect is called by the Prometheus registry when collecting metrics.
func (ClusterInfoCollector) Describe ¶
func (cic ClusterInfoCollector) Describe(ch chan<- *prometheus.Desc)
Describe sends the super-set of all possible descriptors of metrics collected by this Collector.
type ClusterInfoMetric ¶
type ClusterInfoMetric struct {
// contains filtered or unexported fields
}
ClusterInfoMetric is a prometheus.Metric used to encode the local cluster info
func (ClusterInfoMetric) Desc ¶
func (cim ClusterInfoMetric) Desc() *prometheus.Desc
Desc returns the descriptor for the Metric. This method idempotently returns the same descriptor throughout the lifetime of the Metric.
type ClusterManagementCost ¶ added in v1.115.0
type ClusterManagementIdentifier ¶ added in v1.115.0
type CoefficientComponent ¶
CoefficientComponent is a representative struct holding two fields which describe an interval as part of a single number cost coefficient calculation: 1. Proportion: The division of cost based on how many pods were running between those points 2. Time: The ratio of the time between those points to the total time that pod was running
type ContainerInfo ¶
type ContainerInfo struct {
ContainerName string `json:"containerName"`
Image string `json:"image"`
StartTime string `json:"startTime"`
}
func GetKubecostContainers ¶ added in v1.111.0
func GetKubecostContainers(kubeClientSet kubernetes.Interface) ([]ContainerInfo, error)
type ContainerMetric ¶
type ContainerMetric struct {
Namespace string
PodName string
ContainerName string
NodeName string
ClusterID string
// contains filtered or unexported fields
}
ContainerMetric contains a set of identifiers specific to a kubernetes container including a unique string key
func NewContainerMetricFrom ¶ added in v1.115.0
func NewContainerMetricFrom(result *source.ContainerMetricResult, defaultClusterID string) (*ContainerMetric, error)
func NewContainerMetricFromKey ¶
func NewContainerMetricFromKey(key string) (*ContainerMetric, error)
NewContainerMetricFromKey creates a new ContainerMetric instance using a provided comma delimitted string key.
func NewContainerMetricFromResult ¶ added in v1.115.0
func NewContainerMetricFromResult(result *source.QueryResult, defaultClusterID string) (*ContainerMetric, error)
NewContainerMetricFromResult accepts the metrics map from a QueryResult and returns a new ContainerMetric instance
func NewContainerMetricFromValues ¶
func NewContainerMetricFromValues(ns, podName, containerName, nodeName, clusterId string) *ContainerMetric
NewContainerMetricFromValues creates a new ContainerMetric instance using the provided string parameters.
func NewContainerMetricsFromPod ¶
func NewContainerMetricsFromPod(pod *clustercache.Pod, clusterID string) ([]*ContainerMetric, error)
NewContainerMetricsFromPod creates a slice of ContainerMetric instances for each container in the provided Pod.
func (*ContainerMetric) Key ¶
func (c *ContainerMetric) Key() string
Key returns a unique string key that can be used in map[string]interface{}
type CostData ¶
type CostData struct {
Name string `json:"name,omitempty"`
PodName string `json:"podName,omitempty"`
NodeName string `json:"nodeName,omitempty"`
NodeData *costAnalyzerCloud.Node `json:"node,omitempty"`
Namespace string `json:"namespace,omitempty"`
Deployments []string `json:"deployments,omitempty"`
Services []string `json:"services,omitempty"`
Daemonsets []string `json:"daemonsets,omitempty"`
Statefulsets []string `json:"statefulsets,omitempty"`
Jobs []string `json:"jobs,omitempty"`
RAMReq []*util.Vector `json:"ramreq,omitempty"`
RAMUsed []*util.Vector `json:"ramused,omitempty"`
RAMAllocation []*util.Vector `json:"ramallocated,omitempty"`
CPUReq []*util.Vector `json:"cpureq,omitempty"`
CPUUsed []*util.Vector `json:"cpuused,omitempty"`
CPUAllocation []*util.Vector `json:"cpuallocated,omitempty"`
GPUReq []*util.Vector `json:"gpureq,omitempty"`
PVCData []*PersistentVolumeClaimData `json:"pvcData,omitempty"`
NetworkData []*util.Vector `json:"network,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
NamespaceLabels map[string]string `json:"namespaceLabels,omitempty"`
ClusterID string `json:"clusterId"`
ClusterName string `json:"clusterName"`
}
func (*CostData) GetController ¶
type CostModel ¶
type CostModel struct {
Cache clustercache.ClusterCache
ClusterMap clusters.ClusterMap
BatchDuration time.Duration
RequestGroup *singleflight.Group
DataSource source.OpenCostDataSource
Provider costAnalyzerCloud.Provider
// contains filtered or unexported fields
}
func NewCostModel ¶
func NewCostModel( dataSource source.OpenCostDataSource, provider costAnalyzerCloud.Provider, cache clustercache.ClusterCache, clusterMap clusters.ClusterMap, batchDuration time.Duration, ) *CostModel
func (*CostModel) CanCompute ¶
CanCompute should return true if CostModel can act as a valid source for the given time range. In the case of CostModel we want to attempt to compute as long as the range starts in the past. If the CostModel ends up not having data to match, that's okay, and should be communicated with an error response from ComputeAllocation.
func (*CostModel) ClusterDisks ¶ added in v1.103.0
func (*CostModel) ClusterLoadBalancers ¶ added in v1.103.0
func (cm *CostModel) ClusterLoadBalancers(start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
func (*CostModel) ClusterManagement ¶ added in v1.115.0
func (cm *CostModel) ClusterManagement(start, end time.Time) (map[ClusterManagementIdentifier]*ClusterManagementCost, error)
func (*CostModel) ClusterNodes ¶ added in v1.103.0
func (*CostModel) ComputeAllocation ¶
ComputeAllocation uses the CostModel instance to compute an AllocationSet for the window defined by the given start and end times. The Allocations returned are unaggregated (i.e. down to the container level).
func (*CostModel) ComputeAssets ¶ added in v1.103.0
func (*CostModel) ComputeCostData ¶
func (*CostModel) ComputeNetworkInsights ¶ added in v1.115.0
func (*CostModel) DateRange ¶ added in v1.103.0
DateRange checks the data (up to 90 days in the past), and returns the oldest and newest sample timestamp from opencost scraping metric it supposed to be a good indicator of available allocation data
func (*CostModel) GetDataSource ¶ added in v1.115.0
func (cm *CostModel) GetDataSource() source.OpenCostDataSource
func (*CostModel) GetLBCost ¶
func (cm *CostModel) GetLBCost() (map[serviceKey]*costAnalyzerCloud.LoadBalancer, error)
TODO: drop some logs
func (*CostModel) GetNetworkInsightSet ¶ added in v1.115.0
func (*CostModel) GetNodeCost ¶
func (cm *CostModel) GetNodeCost() (map[string]*costAnalyzerCloud.Node, error)
func (*CostModel) GetPVCost ¶ added in v1.115.0
func (cm *CostModel) GetPVCost(pv *costAnalyzerCloud.PV, kpv *clustercache.PersistentVolume, defaultRegion string) error
func (*CostModel) GetPricingSourceCounts ¶
func (cm *CostModel) GetPricingSourceCounts() (*costAnalyzerCloud.PricingMatchMetadata, error)
func (*CostModel) PropertiesFromCluster ¶ added in v1.103.0
func (cm *CostModel) PropertiesFromCluster(props *opencost.AssetProperties)
propertiesFromCluster populates static cluster properties to individual asset properties
func (*CostModel) QueryAllocation ¶ added in v1.103.0
func (cm *CostModel) QueryAllocation(window opencost.Window, step time.Duration, aggregate []string, includeIdle, idleByNode, includeProportionalAssetResourceCosts, includeAggregatedMetadata, sharedLoadBalancer bool, accumulateBy opencost.AccumulateOption, shareIdle bool) (*opencost.AllocationSetRange, error)
type CostModelMetricsEmitter ¶
type CostModelMetricsEmitter struct {
PrometheusClient promclient.Client
KubeClusterCache clustercache.ClusterCache
CloudProvider models.Provider
Model *CostModel
// Metrics
CPUPriceRecorder *prometheus.GaugeVec
RAMPriceRecorder *prometheus.GaugeVec
PersistentVolumePriceRecorder *prometheus.GaugeVec
GPUPriceRecorder *prometheus.GaugeVec
GPUCountRecorder *prometheus.GaugeVec
PVAllocationRecorder *prometheus.GaugeVec
NodeSpotRecorder *prometheus.GaugeVec
NodeTotalPriceRecorder *prometheus.GaugeVec
RAMAllocationRecorder *prometheus.GaugeVec
CPUAllocationRecorder *prometheus.GaugeVec
GPUAllocationRecorder *prometheus.GaugeVec
ClusterManagementCostRecorder *prometheus.GaugeVec
LBCostRecorder *prometheus.GaugeVec
NetworkZoneEgressRecorder prometheus.Gauge
NetworkRegionEgressRecorder prometheus.Gauge
NetworkInternetEgressRecorder prometheus.Gauge
// contains filtered or unexported fields
}
CostModelMetricsEmitter emits all cost-model specific metrics calculated by the CostModel.ComputeCostData() method.
func NewCostModelMetricsEmitter ¶
func NewCostModelMetricsEmitter(clusterCache clustercache.ClusterCache, provider models.Provider, clusterInfo clusters.ClusterInfoProvider, model *CostModel) *CostModelMetricsEmitter
NewCostModelMetricsEmitter creates a new cost-model metrics emitter. Use Start() to begin metric emission.
func (*CostModelMetricsEmitter) IsRunning ¶
func (cmme *CostModelMetricsEmitter) IsRunning() bool
IsRunning returns true if metric recording is running.
func (*CostModelMetricsEmitter) Start ¶
func (cmme *CostModelMetricsEmitter) Start() bool
StartCostModelMetricRecording starts the go routine that emits metrics used to determine cluster costs.
func (*CostModelMetricsEmitter) Stop ¶
func (cmme *CostModelMetricsEmitter) Stop()
Stop halts the metrics emission loop after the current emission is completed or if the emission is paused.
type Disk ¶
type Disk struct {
Cluster string
Name string
ProviderID string
StorageClass string
VolumeName string
ClaimName string
ClaimNamespace string
Cost float64
Bytes float64
// These two fields may not be available at all times because they rely on
// a new set of metrics that may or may not be available. Thus, they must
// be nilable to represent the complete absence of the data.
//
// In other words, nilability here lets us distinguish between
// "metric is not available" and "metric is available but is 0".
//
// They end in "Ptr" to distinguish from an earlier version in order to
// ensure that all usages are checked for nil.
BytesUsedAvgPtr *float64
BytesUsedMaxPtr *float64
Local bool
Start time.Time
End time.Time
Minutes float64
Breakdown *ClusterCostsBreakdown
}
type DiskIdentifier ¶
type InstallInfo ¶
type InstallInfo struct {
Containers []ContainerInfo `json:"containers"`
ClusterInfo map[string]string `json:"clusterInfo"`
Version string `json:"version"`
}
type IntervalPoint ¶
IntervalPoint describes a start or end of a window of time Currently, this used in PVC-pod relations to detect/calculate coefficients for PV cost when a PVC is shared between pods.
func NewIntervalPoint ¶
func NewIntervalPoint(time time.Time, pointType string, key podKey) IntervalPoint
NewIntervalPoint creates and returns a new IntervalPoint instance with given parameters.
type IntervalPoints ¶
type IntervalPoints []IntervalPoint
IntervalPoints describes a slice of IntervalPoint structs
func (IntervalPoints) Len ¶
func (ips IntervalPoints) Len() int
Requisite functions for implementing sort.Sort for IntervalPointList
func (IntervalPoints) Less ¶
func (ips IntervalPoints) Less(i, j int) bool
func (IntervalPoints) Swap ¶
func (ips IntervalPoints) Swap(i, j int)
type KeyTuple ¶
type KeyTuple struct {
// contains filtered or unexported fields
}
KeyTuple contains is a utility which parses Namespace, Key, and ClusterID from a comma delimitted string.
func NewKeyTuple ¶
NewKeyTuple creates a new KeyTuple instance by determining the exact indices of each tuple entry. When each component is requested, a string slice is returned using the boundaries.
type LoadBalancer ¶
type LoadBalancerIdentifier ¶
type NetworkUsageData ¶
type NetworkUsageData struct {
ClusterID string
PodName string
Namespace string
NetworkZoneEgress []*util.Vector
NetworkRegionEgress []*util.Vector
NetworkInternetEgress []*util.Vector
}
NetworkUsageVNetworkUsageDataector contains the network usage values for egress network traffic
type NetworkUsageVector ¶
type NetworkUsageVector struct {
ClusterID string
PodName string
Namespace string
Values []*util.Vector
}
NetworkUsageVector contains a network usage vector for egress network traffic
type Node ¶
type Node struct {
Cluster string
Name string
ProviderID string
NodeType string
CPUCost float64
CPUCores float64
GPUCost float64
GPUCount float64
RAMCost float64
RAMBytes float64
Discount float64
Preemptible bool
CPUBreakdown *ClusterCostsBreakdown
RAMBreakdown *ClusterCostsBreakdown
Start time.Time
End time.Time
Minutes float64
Labels map[string]string
CostPerCPUHr float64
CostPerRAMGiBHr float64
CostPerGPUHr float64
Overhead *NodeOverhead
}
type NodeCostAverages ¶
type NodeCostAverages struct {
CpuCostAverage float64
RamCostAverage float64
NumCpuDataPoints float64
NumRamDataPoints float64
}
NodeCostAverages tracks a running average of a node's cost attributes. The averages are used to detect and discard spurrious outliers.
type NodeIdentifier ¶
type NodeOverhead ¶ added in v1.104.0
type PersistentVolumeClaimData ¶
type PersistentVolumeClaimData struct {
Class string `json:"class"`
Claim string `json:"claim"`
Namespace string `json:"namespace"`
ClusterID string `json:"clusterId"`
TimesClaimed int `json:"timesClaimed"`
VolumeName string `json:"volumeName"`
Volume *costAnalyzerCloud.PV `json:"persistentVolume"`
Values []*util.Vector `json:"values"`
}
Source Files
¶
- aggregation.go
- allocation.go
- allocation_helpers.go
- allocation_types.go
- allocationnode.go
- assets.go
- cluster.go
- cluster_helpers.go
- clusterinfo.go
- containerkeys.go
- costmodel.go
- csv_export.go
- handlers.go
- intervals.go
- key.go
- metrics.go
- networkcosts.go
- networkinsight.go
- nodeclientconfig.go
- resultparsers.go
- router.go
- settings.go