@@ -58,10 +58,6 @@ tags, and then generate with `hack/update-toc.sh`.
58
58
- [ Goals] ( #goals )
59
59
- [ Non-Goals] ( #non-goals )
60
60
- [ Proposal] ( #proposal )
61
- - [ User Stories (Optional)] ( #user-stories-optional )
62
- - [ Story 1] ( #story-1 )
63
- - [ Story 2] ( #story-2 )
64
- - [ Notes/Constraints/Caveats (Optional)] ( #notesconstraintscaveats-optional )
65
61
- [ Risks and Mitigations] ( #risks-and-mitigations )
66
62
- [ Design Details] ( #design-details )
67
63
- [ Test Plan] ( #test-plan )
@@ -216,38 +212,47 @@ type HPAScalingRules struct {
216
212
// tolerance is the tolerance on the ratio between the current and desired
217
213
// metric value under which no updates are made to the desired number of
218
214
// replicas.
219
- // +optional
215
+ // +optional
220
216
Tolerance *resource.Quantity
221
217
222
218
// Existing fields.
223
- StabilizationWindowSeconds *int32
224
- SelectPolicy *ScalingPolicySelect
225
- Policies []HPAScalingPolicy
219
+ StabilizationWindowSeconds *int32
220
+ SelectPolicy *ScalingPolicySelect
221
+ Policies []HPAScalingPolicy
226
222
}
227
223
```
228
224
229
- This new tolerance will be taken into account in [ replica_calculator.go ] [ ] . The
230
- existing logic is:
225
+ This new tolerance will be taken into account in the autoscaling controller
226
+ [ replica_calculator.go ] [ ] . The update to the logic is:
231
227
232
228
``` golang
233
229
if math.Abs (1.0 -usageRatio) <= c.tolerance { /* ... */ }
234
230
```
235
231
236
232
It will be replaced by:
237
233
238
- ``` golang
239
- // Down and Up scaling tolerances default to c.tolerance if unset.
240
- downTolerance , upTolerance := c.tolerance , c.tolerance
241
- if scaleDown.tolerance != nil {
242
- downTolerance = scaleDown.tolerance .AsApproximateFloat64 ()
243
- }
244
- if scaleUp.tolerance != nil {
245
- upTolerance = scaleUp.tolerance .AsApproximateFloat64 ()
246
- }
247
-
248
- if (1.0 -downTolerance) < usageRatio && usageRatio < (1.0 +upTolerance) { /* ... */ }
234
+ ``` diff
235
+ - if math.Abs(1.0-usageRatio) <= c.tolerance { /* ... */ }
236
+ + // Down and Up scaling tolerances default to c.tolerance if unset.
237
+ + downTolerance, upTolerance := c.tolerance, c.tolerance
238
+ + if scaleDown.tolerance != nil {
239
+ + downTolerance = scaleDown.tolerance.AsApproximateFloat64()
240
+ + }
241
+ + if scaleUp.tolerance != nil {
242
+ + upTolerance = scaleUp.tolerance.AsApproximateFloat64()
243
+ + }
244
+ +
245
+ + if (1.0-downTolerance) <= usageRatio && usageRatio <= (1.0+upTolerance) { /* ... */ }
249
246
```
250
247
248
+ Since the added field is optional and has a default value compatible with the
249
+ current autoscaling behavior, this feature can be added to the current API
250
+ version ` pkg/apis/autoscaling/v2 ` .
251
+
252
+ The feature presented in this KEP only allows to tune an existing parameter, and
253
+ as such doesn't require any new HPA Events or modify any Status. A new error is
254
+ emitted if a ` tolerance ` field is set to a negative value.
255
+
251
256
[ replica_calculator.go ] : https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/podautoscaler/replica_calculator.go
252
257
253
258
### Test Plan
@@ -396,32 +401,18 @@ in back-to-back releases.
396
401
397
402
### Upgrade / Downgrade Strategy
398
403
399
- <!--
400
- If applicable, how will the component be upgraded and downgraded? Make sure
401
- this is in the test plan .
404
+ Upgrades present no particular issue: the new field won't be set and the HPA
405
+ will behave like it does today. Users can use the new feature by setting the
406
+ new ` tolerance ` field (provided the Feature Gate is enabled) .
402
407
403
- Consider the following in developing an upgrade/downgrade strategy for this
404
- enhancement:
405
- - What changes (in invocations, configurations, API use, etc.) is an existing
406
- cluster required to make on upgrade, in order to maintain previous behavior?
407
- - What changes (in invocations, configurations, API use, etc.) is an existing
408
- cluster required to make on upgrade, in order to make use of the enhancement?
409
- -->
408
+ On downgrades to a version that does not support this functionality, an HPA will
409
+ ignore any configured ` tolerance ` field, and use the default (as specified by
410
+ ` --horizontal-pod-autoscaler-tolerance ` ).
410
411
411
412
### Version Skew Strategy
412
413
413
- <!--
414
- If applicable, how will the component handle version skew with other
415
- components? What are the guarantees? Make sure this is in the test plan.
416
-
417
- Consider the following in developing a version skew strategy for this
418
- enhancement:
419
- - Does this enhancement involve coordinating behavior in the control plane and nodes?
420
- - How does an n-3 kubelet or kube-proxy without this feature available behave when this feature is used?
421
- - How does an n-1 kube-controller-manager or kube-scheduler without this feature available behave when this feature is used?
422
- - Will any other components on the node change? For example, changes to CSI,
423
- CRI or CNI may require updating that component before the kubelet.
424
- -->
414
+ This feature is entirely implemented in the horizontal autoscaling controller
415
+ and does not introduce any changes that would be impacted by version skews.
425
416
426
417
## Production Readiness Review Questionnaire
427
418
0 commit comments