package podautoscaler
import "k8s.io/kubernetes/pkg/controller/podautoscaler"
Package podautoscaler contains logic for autoscaling number of pods based on metrics observed.
Index ¶
- func NewDefaultHPARateLimiter(interval time.Duration) workqueue.TypedRateLimiter[string]
- func NewFixedItemIntervalRateLimiter(interval time.Duration) workqueue.TypedRateLimiter[string]
- type FixedItemIntervalRateLimiter
- func (r *FixedItemIntervalRateLimiter) Forget(item string)
- func (r *FixedItemIntervalRateLimiter) NumRequeues(item string) int
- func (r *FixedItemIntervalRateLimiter) When(item string) time.Duration
- type HorizontalController
- func NewHorizontalController( ctx context.Context, evtNamespacer v1core.EventsGetter, scaleNamespacer scaleclient.ScalesGetter, hpaNamespacer autoscalingclient.HorizontalPodAutoscalersGetter, mapper apimeta.RESTMapper, metricsClient metricsclient.MetricsClient, hpaInformer autoscalinginformers.HorizontalPodAutoscalerInformer, podInformer coreinformers.PodInformer, resyncPeriod time.Duration, downscaleStabilisationWindow time.Duration, tolerance float64, cpuInitializationPeriod, delayOfInitialReadinessStatus time.Duration, ) *HorizontalController
- func (a *HorizontalController) Run(ctx context.Context, workers int)
- type NormalizationArg
- type ReplicaCalculator
- func NewReplicaCalculator(metricsClient metricsclient.MetricsClient, podLister corelisters.PodLister, cpuInitializationPeriod, delayOfInitialReadinessStatus time.Duration) *ReplicaCalculator
- func (c *ReplicaCalculator) GetExternalMetricReplicas(currentReplicas int32, targetUsage int64, metricName string, tolerances Tolerances, namespace string, metricSelector *metav1.LabelSelector, podSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetExternalPerPodMetricReplicas(statusReplicas int32, targetUsagePerPod int64, metricName string, tolerances Tolerances, namespace string, metricSelector *metav1.LabelSelector) (replicaCount int32, usage int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUsage int64, metricName string, tolerances Tolerances, namespace string, selector labels.Selector, metricSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetObjectMetricReplicas(currentReplicas int32, targetUsage int64, metricName string, tolerances Tolerances, namespace string, objectRef *autoscaling.CrossVersionObjectReference, selector labels.Selector, metricSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetObjectPerPodMetricReplicas(statusReplicas int32, targetAverageUsage int64, metricName string, tolerances Tolerances, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetRawResourceReplicas(ctx context.Context, currentReplicas int32, targetUsage int64, resource v1.ResourceName, tolerances Tolerances, namespace string, selector labels.Selector, container string) (replicaCount int32, usage int64, timestamp time.Time, err error)
- func (c *ReplicaCalculator) GetResourceReplicas(ctx context.Context, currentReplicas int32, targetUtilization int32, resource v1.ResourceName, tolerances Tolerances, namespace string, selector labels.Selector, container string) (replicaCount int32, utilization int32, rawUtilization int64, timestamp time.Time, err error)
- type Tolerances
Functions ¶
func NewDefaultHPARateLimiter ¶
func NewDefaultHPARateLimiter(interval time.Duration) workqueue.TypedRateLimiter[string]
NewDefaultHPARateLimiter creates a rate limiter which limits overall (as per the default controller rate limiter), as well as per the resync interval
func NewFixedItemIntervalRateLimiter ¶
func NewFixedItemIntervalRateLimiter(interval time.Duration) workqueue.TypedRateLimiter[string]
NewFixedItemIntervalRateLimiter creates a new instance of a RateLimiter using a fixed interval
Types ¶
type FixedItemIntervalRateLimiter ¶
type FixedItemIntervalRateLimiter struct {
// contains filtered or unexported fields
}
FixedItemIntervalRateLimiter limits items to a fixed-rate interval
func (*FixedItemIntervalRateLimiter) Forget ¶
func (r *FixedItemIntervalRateLimiter) Forget(item string)
Forget indicates that an item is finished being retried.
func (*FixedItemIntervalRateLimiter) NumRequeues ¶
func (r *FixedItemIntervalRateLimiter) NumRequeues(item string) int
NumRequeues returns back how many failures the item has had
func (*FixedItemIntervalRateLimiter) When ¶
func (r *FixedItemIntervalRateLimiter) When(item string) time.Duration
When returns the interval of the rate limiter
type HorizontalController ¶
type HorizontalController struct {
// contains filtered or unexported fields
}
HorizontalController is responsible for the synchronizing HPA objects stored in the system with the actual deployments/replication controllers they control.
func NewHorizontalController ¶
func NewHorizontalController( ctx context.Context, evtNamespacer v1core.EventsGetter, scaleNamespacer scaleclient.ScalesGetter, hpaNamespacer autoscalingclient.HorizontalPodAutoscalersGetter, mapper apimeta.RESTMapper, metricsClient metricsclient.MetricsClient, hpaInformer autoscalinginformers.HorizontalPodAutoscalerInformer, podInformer coreinformers.PodInformer, resyncPeriod time.Duration, downscaleStabilisationWindow time.Duration, tolerance float64, cpuInitializationPeriod, delayOfInitialReadinessStatus time.Duration, ) *HorizontalController
NewHorizontalController creates a new HorizontalController.
func (*HorizontalController) Run ¶
func (a *HorizontalController) Run(ctx context.Context, workers int)
Run begins watching and syncing.
type NormalizationArg ¶
type NormalizationArg struct { Key string ScaleUpBehavior *autoscalingv2.HPAScalingRules ScaleDownBehavior *autoscalingv2.HPAScalingRules MinReplicas int32 MaxReplicas int32 CurrentReplicas int32 DesiredReplicas int32 }
NormalizationArg is used to pass all needed information between functions as one structure
type ReplicaCalculator ¶
type ReplicaCalculator struct {
// contains filtered or unexported fields
}
ReplicaCalculator bundles all needed information to calculate the target amount of replicas
func NewReplicaCalculator ¶
func NewReplicaCalculator(metricsClient metricsclient.MetricsClient, podLister corelisters.PodLister, cpuInitializationPeriod, delayOfInitialReadinessStatus time.Duration) *ReplicaCalculator
NewReplicaCalculator creates a new ReplicaCalculator and passes all necessary information to the new instance
func (*ReplicaCalculator) GetExternalMetricReplicas ¶
func (c *ReplicaCalculator) GetExternalMetricReplicas(currentReplicas int32, targetUsage int64, metricName string, tolerances Tolerances, namespace string, metricSelector *metav1.LabelSelector, podSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
GetExternalMetricReplicas calculates the desired replica count based on a target metric value (as a milli-value) for the external metric in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetExternalPerPodMetricReplicas ¶
func (c *ReplicaCalculator) GetExternalPerPodMetricReplicas(statusReplicas int32, targetUsagePerPod int64, metricName string, tolerances Tolerances, namespace string, metricSelector *metav1.LabelSelector) (replicaCount int32, usage int64, timestamp time.Time, err error)
GetExternalPerPodMetricReplicas calculates the desired replica count based on a target metric value per pod (as a milli-value) for the external metric in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetMetricReplicas ¶
func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUsage int64, metricName string, tolerances Tolerances, namespace string, selector labels.Selector, metricSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
GetMetricReplicas calculates the desired replica count based on a target metric usage (as a milli-value) for pods matching the given selector in the given namespace, and the current replica count
func (*ReplicaCalculator) GetObjectMetricReplicas ¶
func (c *ReplicaCalculator) GetObjectMetricReplicas(currentReplicas int32, targetUsage int64, metricName string, tolerances Tolerances, namespace string, objectRef *autoscaling.CrossVersionObjectReference, selector labels.Selector, metricSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
GetObjectMetricReplicas calculates the desired replica count based on a target metric usage (as a milli-value) for the given object in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetObjectPerPodMetricReplicas ¶
func (c *ReplicaCalculator) GetObjectPerPodMetricReplicas(statusReplicas int32, targetAverageUsage int64, metricName string, tolerances Tolerances, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (replicaCount int32, usage int64, timestamp time.Time, err error)
GetObjectPerPodMetricReplicas calculates the desired replica count based on a target metric usage (as a milli-value) for the given object in the given namespace, and the current replica count.
func (*ReplicaCalculator) GetRawResourceReplicas ¶
func (c *ReplicaCalculator) GetRawResourceReplicas(ctx context.Context, currentReplicas int32, targetUsage int64, resource v1.ResourceName, tolerances Tolerances, namespace string, selector labels.Selector, container string) (replicaCount int32, usage int64, timestamp time.Time, err error)
GetRawResourceReplicas calculates the desired replica count based on a target resource usage (as a raw milli-value) for pods matching the given selector in the given namespace, and the current replica count
func (*ReplicaCalculator) GetResourceReplicas ¶
func (c *ReplicaCalculator) GetResourceReplicas(ctx context.Context, currentReplicas int32, targetUtilization int32, resource v1.ResourceName, tolerances Tolerances, namespace string, selector labels.Selector, container string) (replicaCount int32, utilization int32, rawUtilization int64, timestamp time.Time, err error)
GetResourceReplicas calculates the desired replica count based on a target resource utilization percentage of the given resource for pods matching the given selector in the given namespace, and the current replica count
type Tolerances ¶
type Tolerances struct {
// contains filtered or unexported fields
}
Tolerances contains metric usage ratio scale-up and scale-down tolerances.
func (Tolerances) String ¶
func (t Tolerances) String() string
Source Files ¶
doc.go horizontal.go rate_limiters.go replica_calculator.go
Directories ¶
Path | Synopsis |
---|---|
pkg/controller/podautoscaler/config | |
pkg/controller/podautoscaler/config/v1alpha1 | |
pkg/controller/podautoscaler/metrics | |
pkg/controller/podautoscaler/monitor | metrics packages contains metrics which are exposed from the HPA controller. |
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 39 packages
- Last checked
- 3 hours ago –
Tools for package owners.