custom_metrics

package
v0.32.0-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 18 Imported by: 177

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MetricVersions is the set of metric versions accepted by the converter.
	MetricVersions = []schema.GroupVersion{
		cmv1beta2.SchemeGroupVersion,
		cmv1beta1.SchemeGroupVersion,
		cmint.SchemeGroupVersion,
	}
)

Functions

func PeriodicallyInvalidate

func PeriodicallyInvalidate(cache AvailableAPIsGetter, interval time.Duration, stopCh <-chan struct{})

PeriodicallyInvalidate periodically invalidates the preferred version cache until told to stop.

Types

type AvailableAPIsGetter

type AvailableAPIsGetter interface {
	PreferredVersion() (schema.GroupVersion, error)
	Invalidate()
}

AvailableAPIsGetter knows how to fetch and cache the preferred custom metrics API version, and invalidate that cache when asked.

func NewAvailableAPIsGetter

func NewAvailableAPIsGetter(client discovery.DiscoveryInterface) AvailableAPIsGetter

NewAvailableAPIsGetter creates an AvailableAPIsGetter that checks discovery to find the available versions of the custom metrics api.

type CustomMetricsClient

type CustomMetricsClient interface {
	RootScopedMetricsGetter
	NamespacedMetricsGetter
}

CustomMetricsClient is a client for fetching metrics describing both root-scoped and namespaced resources.

func NewForConfig

func NewForConfig(baseConfig *rest.Config, mapper meta.RESTMapper, availableAPIs AvailableAPIsGetter) CustomMetricsClient

NewForConfig creates a new custom metrics client which delegates to a client which uses the preferred api version.

func NewForVersion

func NewForVersion(client rest.Interface, mapper meta.RESTMapper, version schema.GroupVersion) CustomMetricsClient

NewForVersion returns a new CustomMetricsClient for a particular api version.

func NewForVersionForConfig

func NewForVersionForConfig(c *rest.Config, mapper meta.RESTMapper, version schema.GroupVersion) (CustomMetricsClient, error)

NewForVersionForConfig returns a new CustomMetricsClient for a particular api version and base configuration.

type MetricConverter

type MetricConverter struct {
	// contains filtered or unexported fields
}

MetricConverter knows how to convert between external MetricValue versions.

func NewMetricConverter

func NewMetricConverter() *MetricConverter

NewMetricConverter creates a MetricConverter which knows how to convert objects between different versions of the custom metrics api.

func (*MetricConverter) Codecs

Codecs returns the codecs used by this metric converter

func (*MetricConverter) ConvertListOptionsToVersion

func (c *MetricConverter) ConvertListOptionsToVersion(opts *cmint.MetricListOptions, version schema.GroupVersion) (runtime.Object, error)

ConvertListOptionsToVersion converts converts a set of MetricListOptions to the provided GroupVersion.

func (*MetricConverter) ConvertResultToVersion

func (c *MetricConverter) ConvertResultToVersion(res rest.Result, gv schema.GroupVersion) (runtime.Object, error)

ConvertResultToVersion converts a Result to the provided GroupVersion

func (*MetricConverter) Scheme

func (c *MetricConverter) Scheme() *runtime.Scheme

Scheme returns the scheme used by this metric converter.

func (*MetricConverter) UnsafeConvertToVersionVia

func (c *MetricConverter) UnsafeConvertToVersionVia(obj runtime.Object, externalVersion schema.GroupVersion) (runtime.Object, error)

UnsafeConvertToVersionVia is like Scheme.UnsafeConvertToVersion, but it does so via an internal version first. We use it here to work with the v1beta2 client internally, while preserving backwards compatibility for existing custom metrics adapters

type MetricsInterface

type MetricsInterface interface {
	// GetForObject fetchs the given metric describing the given object.
	GetForObject(groupKind schema.GroupKind, name string, metricName string, metricSelector labels.Selector) (*v1beta2.MetricValue, error)

	// GetForObjects fetches the given metric describing all objects of the given
	// type matching the given label selector (or simply all objects of the given type
	// if the selector is nil).
	GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string, metricSelector labels.Selector) (*v1beta2.MetricValueList, error)
}

MetricsInterface provides access to metrics describing Kubernetes objects.

type NamespacedMetricsGetter

type NamespacedMetricsGetter interface {
	NamespacedMetrics(namespace string) MetricsInterface
}

NamespacedMetricsGetter provides access to an interface for fetching metrics describing resources in a particular namespace.

type RootScopedMetricsGetter

type RootScopedMetricsGetter interface {
	RootScopedMetrics() MetricsInterface
}

RootScopedMetricsGetter provides access to an interface for fetching metrics describing root-scoped objects. Note that metrics describing a namespace are simply considered a special case of root-scoped metrics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL