metricprovider

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0, BSD-2-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCronTargetMetricValue is used to construct a default external cron metric targetValue.
	// So the hpa may scale workload to DefaultCronTargetMetricValue. And finally scale replica depends on the HPA min max replica count the user set.
	DefaultCronTargetMetricValue int32 = 1
)

Variables

This section is empty.

Functions

func CronEnabled added in v0.4.0

func EHPACronMetricName added in v0.3.0

func EHPACronMetricName(namespace, name string, cronScale autoscalingapi.CronSpec) string

EHPACronMetricName return the hpa cron external metric name from ehpa cron scale spec construct the cron metric name by ehpa namespace, name, cron name, cron timezone, cron start, cron end make sure each ehpa cron scale metric name is unique.

func GetCronScaleLocation added in v0.3.0

func GetCronScaleLocation(cronScale autoscalingapi.CronSpec) *time.Location

GetCronScaleLocation return the cronScale location, default is UTC when it is not specified in spec

func GetPredictions added in v0.8.0

func GetPredictions(ctx context.Context, kubeclient client.Client, namespace string, metricSelector labels.Selector) ([]predictionapi.TimeSeriesPrediction, error)

func IsLocalExternalMetric added in v0.6.0

func IsLocalExternalMetric(metricInfo provider.ExternalMetricInfo, client client.Client) bool

func NewCustomMetricProvider added in v0.3.0

func NewCustomMetricProvider(client client.Client, remoteAdapter *RemoteAdapter, recorder record.EventRecorder) provider.CustomMetricsProvider

NewCustomMetricProvider returns an instance of CustomMetricProvider

func NormalizeString added in v0.3.0

func NormalizeString(s string) string

Types

type CronScaler added in v0.3.0

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

func GetCronScalersForEHPA added in v0.3.0

func GetCronScalersForEHPA(ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler) []*CronScaler

func NewCronScaler added in v0.3.0

func NewCronScaler(trigger *CronTrigger, ref *autoscalingapi.EffectiveHorizontalPodAutoscaler, targetReplicas int32) *CronScaler

func (*CronScaler) IsActive added in v0.3.0

func (cs *CronScaler) IsActive(ctx context.Context, now time.Time) (bool, error)

func (*CronScaler) Name added in v0.3.0

func (cs *CronScaler) Name() string

func (*CronScaler) TargetSize added in v0.3.0

func (cs *CronScaler) TargetSize() int32

type CronTrigger added in v0.3.0

type CronTrigger struct {
	Name     string
	Location *time.Location
	Start    string
	End      string
}

func (*CronTrigger) IsActive added in v0.3.0

func (c *CronTrigger) IsActive(ctx context.Context, now time.Time) (bool, error)

IsActive return true if the now is in cron trigger schedule start and end, false if else

type CustomMetricProvider added in v0.3.0

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

CustomMetricProvider is an implementation of provider.CustomMetricProvider which provide predictive metric for resource

func (*CustomMetricProvider) GetMetricByName added in v0.3.0

func (*CustomMetricProvider) GetMetricBySelector added in v0.3.0

func (p *CustomMetricProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error)

GetMetricBySelector fetches metric for custom resources, get predictive metric from giving selector

func (*CustomMetricProvider) ListAllMetrics added in v0.3.0

func (p *CustomMetricProvider) ListAllMetrics() []provider.CustomMetricInfo

ListAllMetrics returns all available custom metrics.

type ExternalMetricProvider added in v0.3.0

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

ExternalMetricProvider implements ehpa external metric as external metric provider which now support cron metric

func NewExternalMetricProvider added in v0.3.0

func NewExternalMetricProvider(client client.Client, remoteAdapter *RemoteAdapter, recorder record.EventRecorder, scaleClient scale.ScalesGetter, restMapper meta.RESTMapper) *ExternalMetricProvider

NewExternalMetricProvider returns an instance of ExternalMetricProvider

func (*ExternalMetricProvider) GetCronExternalMetrics added in v0.6.0

func (p *ExternalMetricProvider) GetCronExternalMetrics(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error)

GetCronExternalMetrics get desired metric value from cron spec

func (*ExternalMetricProvider) GetExternalMetric added in v0.3.0

GetExternalMetric get external metric according to metric type

func (*ExternalMetricProvider) ListAllExternalMetrics added in v0.3.0

func (p *ExternalMetricProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo

ListAllExternalMetrics return external cron metrics Fetch metrics from cache directly to avoid the performance issue for apiserver when the metrics is large, because this api is called frequently.

type RemoteAdapter added in v0.2.0

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

func NewRemoteAdapter added in v0.2.0

func NewRemoteAdapter(namespace string, name string, port int, config *rest.Config, client client.Client) (*RemoteAdapter, error)

func (*RemoteAdapter) GetExternalMetric added in v0.6.0

func (r *RemoteAdapter) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error)

GetExternalMetric get external metric from remote

func (*RemoteAdapter) GetMetricByName added in v0.2.0

func (r *RemoteAdapter) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error)

GetMetricByName get custom metric from remote adapter

func (*RemoteAdapter) GetMetricBySelector added in v0.2.0

func (r *RemoteAdapter) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error)

GetMetricBySelector get custom metric from remote

func (*RemoteAdapter) ListAllExternalMetrics added in v0.6.0

func (r *RemoteAdapter) ListAllExternalMetrics() []provider.ExternalMetricInfo

ListAllExternalMetrics list all external metric from remote

func (*RemoteAdapter) ListAllMetrics added in v0.2.0

func (r *RemoteAdapter) ListAllMetrics() []provider.CustomMetricInfo

ListAllMetrics returns all available custom metrics.

Jump to

Keyboard shortcuts

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