...

Source file src/k8s.io/kubernetes/pkg/controller/podautoscaler/metrics/interfaces.go

Documentation: k8s.io/kubernetes/pkg/controller/podautoscaler/metrics

     1  /*
     2  Copyright 2017 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package metrics
    18  
    19  import (
    20  	"context"
    21  	"time"
    22  
    23  	autoscaling "k8s.io/api/autoscaling/v2"
    24  	v1 "k8s.io/api/core/v1"
    25  	"k8s.io/apimachinery/pkg/labels"
    26  )
    27  
    28  // PodMetric contains pod metric value (the metric values are expected to be the metric as a milli-value)
    29  type PodMetric struct {
    30  	Timestamp time.Time
    31  	Window    time.Duration
    32  	Value     int64
    33  }
    34  
    35  // PodMetricsInfo contains pod metrics as a map from pod names to PodMetricsInfo
    36  type PodMetricsInfo map[string]PodMetric
    37  
    38  // MetricsClient knows how to query a remote interface to retrieve container-level
    39  // resource metrics as well as pod-level arbitrary metrics
    40  type MetricsClient interface {
    41  	// GetResourceMetric gets the given resource metric (and an associated oldest timestamp)
    42  	// for the specified named container in all pods matching the specified selector in the given namespace and when
    43  	// the container is an empty string it returns the sum of all the container metrics.
    44  	GetResourceMetric(ctx context.Context, resource v1.ResourceName, namespace string, selector labels.Selector, container string) (PodMetricsInfo, time.Time, error)
    45  
    46  	// GetRawMetric gets the given metric (and an associated oldest timestamp)
    47  	// for all pods matching the specified selector in the given namespace
    48  	GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error)
    49  
    50  	// GetObjectMetric gets the given metric (and an associated timestamp) for the given
    51  	// object in the given namespace
    52  	GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error)
    53  
    54  	// GetExternalMetric gets all the values of a given external metric
    55  	// that match the specified selector.
    56  	GetExternalMetric(metricName string, namespace string, selector labels.Selector) ([]int64, time.Time, error)
    57  }
    58  

View as plain text