Skip to content

Commit cb9d7f8

Browse files
Feedback
1 parent 5785bfd commit cb9d7f8

File tree

1 file changed

+20
-1
lines changed
  • keps/sig-autoscaling/2021-scale-from-zero

1 file changed

+20
-1
lines changed

keps/sig-autoscaling/2021-scale-from-zero/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,14 @@ This section must be completed when targeting beta to a release.
627627
As this is a new field every usage is opt-in. In case the kubernetes version is downgraded, currently scaled to 0 workloads might need to be manually scaled to 1 as the controller would treat them as
628628
paused otherwise.
629629

630+
If a rollback is planned, the following steps should be performed before downgrading the kubernetes version:
631+
632+
1. Make sure there are no hpa objects with minReplicas=0 and maxReplicas=0. Here is a oneliner to update it to 1:
633+
634+
`$ kubectl get hpa --all-namespaces --no-headers=true | awk '{if($6==0) printf "kubectl patch hpa/%s --namespace=%s -p \"{\\\"spec\\\":{\\\"minReplicas\\\":1,\\\"maxReplicas\\\":1}}\"\n", $2, $1 }' | sh`
635+
2. Disable `HPAScaleToZero` feature gate
636+
3. Downgrade the Kubernetes version
637+
630638
###### How can a rollout or rollback fail? Can it impact already running workloads?
631639

632640
<!--
@@ -641,6 +649,15 @@ will rollout across nodes.
641649

642650
There are no expected side-effects when the rollout fails as the new `ScaleToZero` condition should only be enabled once the version upgraded completed.
643651

652+
If the `kube-apiserver` has been upgraded before the `kube-controller-manager`, an HPA object has been updated to `minReplicas: 0` and the workload is already scaled down to 0 replicas, you must manually scale the workload to at least one replica.
653+
654+
You can detect this situation in one of two ways:
655+
656+
- Manually, by checking the HPA status and verifying that all entries show ScalingActive set to true and do not mention ScalingDisabled, or
657+
658+
- Automatically, by using the `kube_horizontalpodautoscaler_status_condition` metric provided by [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics)
659+
to ensure the `ScalingActive` condition is `true.`
660+
644661
If an rollback is attempted, all HPAs should be updated to `minReplicas: 1` as otherwise HPA for deployments with zero replicas will be disabled until
645662
replicas have been raised explicitly to at least `1`.
646663

@@ -651,7 +668,9 @@ What signals should users be paying attention to when the feature is young
651668
that might indicate a serious problem?
652669
-->
653670

654-
If workloads aren't scaled up from 0 despite the scaling condition being meet, an operator should rollback this feature and manually scale an affected workload back to `1`.
671+
If workloads an unexpected number of HPA entities contain a the status `ScalingActive` `false` and mention `ScalingDisable` the feature isn't working as desired and all HPA objects should be updated to > 0 again and their managed workloads should be scaled to at least 1.
672+
673+
This condition can also be detected using the `kube_horizontalpodautoscaler_status_condition` metric provided by [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics), but reason should be manually confirmed for flagged HPA objects.
655674

656675
###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
657676

0 commit comments

Comments
 (0)