Skip to content

Commit 1a7a756

Browse files
jm-franck8s-publishing-bot
authored andcommitted
Add the HorizontalPodAutoscaler tolerance field.
Includes v2beta2 HPA round-trip conversion, defaulting, and validation. Kubernetes-commit: a41284d9fa3a3d5a5e8760db6e9fd4f7e5e6fca6
1 parent 71f613b commit 1a7a756

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

autoscaling/v2/types.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,18 @@ const (
171171
DisabledPolicySelect ScalingPolicySelect = "Disabled"
172172
)
173173

174-
// HPAScalingRules configures the scaling behavior for one direction.
175-
// These Rules are applied after calculating DesiredReplicas from metrics for the HPA.
174+
// HPAScalingRules configures the scaling behavior for one direction via
175+
// scaling Policy Rules and a configurable metric tolerance.
176+
//
177+
// Scaling Policy Rules are applied after calculating DesiredReplicas from metrics for the HPA.
176178
// They can limit the scaling velocity by specifying scaling policies.
177179
// They can prevent flapping by specifying the stabilization window, so that the
178180
// number of replicas is not set instantly, instead, the safest value from the stabilization
179181
// window is chosen.
182+
//
183+
// The tolerance is applied to the metric values and prevents scaling too
184+
// eagerly for small metric variations. (Note that setting a tolerance requires
185+
// enabling the alpha HPAConfigurableTolerance feature gate.)
180186
type HPAScalingRules struct {
181187
// stabilizationWindowSeconds is the number of seconds for which past recommendations should be
182188
// considered while scaling up or scaling down.
@@ -193,10 +199,24 @@ type HPAScalingRules struct {
193199
SelectPolicy *ScalingPolicySelect `json:"selectPolicy,omitempty" protobuf:"bytes,1,opt,name=selectPolicy"`
194200

195201
// policies is a list of potential scaling polices which can be used during scaling.
196-
// At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid
202+
// If not set, use the default values:
203+
// - For scale up: allow doubling the number of pods, or an absolute change of 4 pods in a 15s window.
204+
// - For scale down: allow all pods to be removed in a 15s window.
197205
// +listType=atomic
198206
// +optional
199207
Policies []HPAScalingPolicy `json:"policies,omitempty" listType:"atomic" protobuf:"bytes,2,rep,name=policies"`
208+
209+
// tolerance is the tolerance on the ratio between the current and desired
210+
// metric value under which no updates are made to the desired number of
211+
// replicas (e.g. 0.01 for 1%). Must be greater than or equal to zero. If not
212+
// set, the default cluster-wide tolerance is applied (by default 10%).
213+
//
214+
// This is an alpha field and requires enabling the HPAConfigurableTolerance
215+
// feature gate.
216+
//
217+
// +featureGate=HPAConfigurableTolerance
218+
// +optional
219+
Tolerance *resource.Quantity `json:"tolerance,omitempty" protobuf:"bytes,4,opt,name=tolerance"`
200220
}
201221

202222
// HPAScalingPolicyType is the type of the policy which could be used while making scaling decisions.

0 commit comments

Comments
 (0)