You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-autoscaling/2021-scale-from-zero/README.md
+22-31Lines changed: 22 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -262,7 +262,10 @@ As `replicas: 0` is now a possible state when using `minReplicas: 0` it can no l
262
262
Additionally the `replicas: 0` state is problematic as updating a HPA object `minReplicas` from `0` to `1` has different behavior. If `replicas` was `0` during the update, HPA
263
263
will be disabled for the resource, if it was `> 0`, HPA will continue with the new `minReplicas` value.
264
264
265
-
To resolve this issue the KEP is introducing an explicit `enableScaleToZero` property to explicitly enable/disable scale from/to zero.
265
+
To resolve this issue the KEP is introducing an explicit `ScaledToZero` condition inside the `HorizontalPodAutoscalerStatus`. When `ScaledToZero=True` was recorded the HPA will scale
266
+
up a workload from `0 ~> 1` and otherwise maintain the current behavior of performing no change.
267
+
268
+
When the HPA scales a workload from `1 ~> 0`, it records the `ScaledToZero=True` condition inside the status.
266
269
267
270
### Risks and Mitigations
268
271
@@ -278,8 +281,11 @@ How will UX be reviewed, and by whom?
278
281
Consider including folks who also work outside the SIG or subproject.
279
282
-->
280
283
281
-
From an UX perspective the two stage opt-out / opt-in from scale to zero might feel a bit tedious, but the only other available option seems to be deprecating the implicit HPA pause on `replicas: 0`. While this might provide an improved
282
-
UX, it would require a full deprecation cycle (12 months) before graduating this feature from alpha to beta.
284
+
As `ScaledToZero` is no explicit property, applying a new Deployment with `replicas: 0` and HPA `minReplicas: 0` can be confusing as the Deployment will never scale.
285
+
286
+
This needs should be documented and is detectable by looking at the existing `ScalingActive` condition.
287
+
288
+
In the future pausing the HPA can become an explicit feature and the implicit pausing via `replicas: 0` can be deprecate to remove this confusing.
283
289
284
290
## Design Details
285
291
@@ -290,28 +296,14 @@ required) or even code snippets. If there's any ambiguity about HOW your
290
296
proposal will be implemented, this is the place to discuss them.
291
297
-->
292
298
293
-
We would add `EnableScaleToZero *bool` to the HPA `spec.behavior`.
299
+
Add `ScaledToZero` as HPA `HorizontalPodAutoscalerConditionType`
294
300
295
301
```golang
296
-
typeHorizontalPodAutoscalerBehaviorstruct {
297
-
ScaleUp *HPAScalingRules
298
-
ScaleDown *HPAScalingRules
299
-
EnableScaleToZero *bool
300
-
}
301
-
302
-
typeHorizontalPodAutoscalerSpecstruct {
303
-
ScaleTargetRefCrossVersionObjectReference
304
-
MinReplicas *int32
305
-
MaxReplicasint32
306
-
Metrics []MetricSpec
307
-
Behavior *HorizontalPodAutoscalerBehavior
308
-
}
309
-
```
310
-
311
-
The `EnableScaleToZero` controls whether the `MinReplicas` can set to `>=0` (`true`, new behavior) or `>=1` (`false`, current behavior). The default will be `false` to preserve the current behavior.
312
302
313
-
If `EnableScaleToZero` has been enabled, it can only be disabled when the scaled resource has at least one replica
314
-
running and `MinReplicas` is `>=1`.
303
+
const (
304
+
// ScaledToZero indicates that the HPA controller scaled the workload to zero.
@@ -338,10 +330,10 @@ existing tests to make this code solid enough prior to committing the changes ne
338
330
to implement this enhancement.
339
331
340
332
Most logic related to this KEP is contained in the HPA controller so the testing of
341
-
the various `minReplicas`, `replicas` and `enableScaleToZero` should be achievable with unit tests.
333
+
the various `minReplicas`, `replicas` and `ScaledToZero` should be achievable with unit tests.
342
334
343
335
Additionally integration tests should be added for enable scale to zero by, setting
344
-
`enableScaleToZero: true`, setting `minReplicas: 1` and waiting for `replicas` to become `0` and another test for increasing `minReplicas: 1` and observing that `replicas` became `1` again and , setting `enableScaleToZero: false` afterwards.
336
+
`ScaledToZero: true`, setting `minReplicas: 1` and waiting for`replicas` to become `0` and another test for increasing `minReplicas: 1` and observing that `replicas` became `1` again and confirming that `ScaledToZero: true` has been removed.
345
337
346
338
##### Prerequisite testing updates
347
339
@@ -475,7 +467,7 @@ in back-to-back releases.
475
467
476
468
#### Alpha
477
469
478
-
- Implement the `enableScaleToZero` property
470
+
- Implement the `ScaleToZero` condition recording
479
471
- Ensure that all `minReplicas` state transitions from `0` to `1` are working as expected
480
472
- E2E tests are passing without flakiness
481
473
@@ -503,9 +495,7 @@ enhancement:
503
495
504
496
As this KEP changes the allowed values for `minReplicas`, special care is required for the downgrade case to not prevent any kind of updates for HPA objects using `minReplicas: 0`. The alpha code already accepts `minReplicas: 0` with the flag enabled or disabled since Kubernetes version 1.16 downgrades to any version >= 1.16 aren't an issue.
505
497
506
-
The new flag `enableScaleToZero` defaults to `false`, which was has been the previous behavior. The flag should be disabled before downgrading as otherwise the
507
-
HPA for deployments with zero replicas will be disabled until replicas have been
508
-
raised explicitly to at least `1`.
498
+
Before downgrading all HPAs need to be set to `minReplicas: 1` to avoid any deployments being stuck at `replicas: 1`.
509
499
510
500
### VersionSkewStrategy
511
501
@@ -590,7 +580,7 @@ Any change of default behavior may be surprising to users or break existing
590
580
automations, so be extremely careful here.
591
581
-->
592
582
593
-
HPA creation/update with `minReplicas: 0` is no longer rejected, if the `enableScaleToZero` field is set to true.
583
+
HPA creation/update with `minReplicas: 0` is no longer rejected.
594
584
595
585
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
596
586
@@ -649,9 +639,10 @@ rollout. Similarly, consider large clusters and how enablement/disablement
649
639
will rollout across nodes.
650
640
-->
651
641
652
-
There are no expected side-effects when the rollout fails as the new `enableScaleToZero` flag should only be enabled once the version upgraded completed and should be disabled before attempting a rollback.
642
+
There are no expected side-effects when the rollout fails as the new `ScaleToZero` condition should only be enabled once the version upgraded completed.
653
643
654
-
In case this is missed, HPA for deployments with zero replicas will be disabled until replicas have been raised explicitly to at least `1`.
644
+
If an rollback is attempted, all HPAs should be updated to `minReplicas: 1` as otherwise HPAfor deployments with zero replicas will be disabled until
645
+
replicas have been raised explicitly to at least `1`.
655
646
656
647
###### What specific metrics should inform a rollback?
0 commit comments