Documentation ¶
Index ¶
- Constants
- func CronEnabled(ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler) bool
- func EHPACronMetricName(namespace, name string, cronScale autoscalingapi.CronSpec) string
- func GetCronScaleLocation(cronScale autoscalingapi.CronSpec) *time.Location
- func GetPredictions(ctx context.Context, kubeclient client.Client, namespace string, ...) ([]predictionapi.TimeSeriesPrediction, error)
- func IsLocalExternalMetric(metricInfo provider.ExternalMetricInfo, client client.Client) bool
- func NewCustomMetricProvider(client client.Client, remoteAdapter *RemoteAdapter, ...) provider.CustomMetricsProvider
- func NormalizeString(s string) string
- type CronScaler
- type CronTrigger
- type CustomMetricProvider
- func (p *CustomMetricProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, ...) (*custom_metrics.MetricValue, error)
- func (p *CustomMetricProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, ...) (*custom_metrics.MetricValueList, error)
- func (p *CustomMetricProvider) ListAllMetrics() []provider.CustomMetricInfo
- type ExternalMetricProvider
- func (p *ExternalMetricProvider) GetCronExternalMetrics(ctx context.Context, namespace string, metricSelector labels.Selector, ...) (*external_metrics.ExternalMetricValueList, error)
- func (p *ExternalMetricProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, ...) (*external_metrics.ExternalMetricValueList, error)
- func (p *ExternalMetricProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo
- type RemoteAdapter
- func (r *RemoteAdapter) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, ...) (*external_metrics.ExternalMetricValueList, error)
- func (r *RemoteAdapter) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, ...) (*custom_metrics.MetricValue, error)
- func (r *RemoteAdapter) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, ...) (*custom_metrics.MetricValueList, error)
- func (r *RemoteAdapter) ListAllExternalMetrics() []provider.ExternalMetricInfo
- func (r *RemoteAdapter) ListAllMetrics() []provider.CustomMetricInfo
Constants ¶
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 CronEnabled(ehpa *autoscalingapi.EffectiveHorizontalPodAutoscaler) bool
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
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) 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 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 (p *CustomMetricProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error)
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
func (p *ExternalMetricProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error)
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 (*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.