package metrics
import "k8s.io/kubernetes/pkg/controller/podautoscaler/metrics"
Index ¶
- func GetMetricUsageRatio(metrics PodMetricsInfo, targetUsage int64) (usageRatio float64, currentUsage int64)
- func GetResourceUtilizationRatio(metrics PodMetricsInfo, requests map[string]int64, targetUtilization int32) (utilizationRatio float64, currentUtilization int32, rawAverageValue int64, err error)
- type MetricsClient
- type PodMetric
- type PodMetricsInfo
Functions ¶
func GetMetricUsageRatio ¶
func GetMetricUsageRatio(metrics PodMetricsInfo, targetUsage int64) (usageRatio float64, currentUsage int64)
GetMetricUsageRatio takes in a set of metrics and a target usage value, and calculates the ratio of desired to actual usage (returning that and the actual usage)
func GetResourceUtilizationRatio ¶
func GetResourceUtilizationRatio(metrics PodMetricsInfo, requests map[string]int64, targetUtilization int32) (utilizationRatio float64, currentUtilization int32, rawAverageValue int64, err error)
GetResourceUtilizationRatio takes in a set of metrics, a set of matching requests, and a target utilization percentage, and calculates the ratio of desired to actual utilization (returning that, the actual utilization, and the raw average value)
Types ¶
type MetricsClient ¶
type MetricsClient interface { // GetResourceMetric gets the given resource metric (and an associated oldest timestamp) // for the specified named container in all pods matching the specified selector in the given namespace and when // the container is an empty string it returns the sum of all the container metrics. // Missing metrics will not error and callers should rely on Pod status to filter metrics info returned from this interface. GetResourceMetric(ctx context.Context, resource v1.ResourceName, namespace string, selector labels.Selector, container string) (PodMetricsInfo, time.Time, error) // GetRawMetric gets the given metric (and an associated oldest timestamp) // for all pods matching the specified selector in the given namespace GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error) // GetObjectMetric gets the given metric (and an associated timestamp) for the given // object in the given namespace GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error) // GetExternalMetric gets all the values of a given external metric // that match the specified selector. GetExternalMetric(metricName string, namespace string, selector labels.Selector) ([]int64, time.Time, error) }
MetricsClient knows how to query a remote interface to retrieve container-level resource metrics as well as pod-level arbitrary metrics
func NewRESTMetricsClient ¶
func NewRESTMetricsClient(resourceClient resourceclient.PodMetricsesGetter, customClient customclient.CustomMetricsClient, externalClient externalclient.ExternalMetricsClient) MetricsClient
type PodMetric ¶
PodMetric contains pod metric value (the metric values are expected to be the metric as a milli-value)
type PodMetricsInfo ¶
PodMetricsInfo contains pod metrics as a map from pod names to PodMetricsInfo
Source Files ¶
client.go interfaces.go utilization.go
- Version
- v1.33.1 (latest)
- Published
- May 15, 2025
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 13 hours ago –
Tools for package owners.