Support scaling to zero
jjhuff opened this issue · comments
This code seems to be preventing me from scaling a deployment to zero replicas:
custom-pod-autoscaler/scale/scale.go
Line 112 in 7b1d427
My use case is a queue-based processing system with a bunch of GPUs, so scale to zero is rather important (and also why I can't use the build in HorizontalPodAutoscaler)
Ah OK, thanks for the feedback, helpful to hear a use case. So the way the current code works is if the current replica count is 0
scaling is disabled on the resource, so a resource can be scaled down to 0
replicas, but it cannot be scaled again after it has been set to 0
. In your use case you need to be able to scale down to 0
and then afterwards scale upwards from 0
- is that right?
It seems reasonable to me, I think the way to do this would be to have a boolean configuration option allowScaleFromZero
, if this is true
you can scale upwards from 0
, if it is false
you can't scale upwards from 0
- would that be suitable for you? If so I'll add in that flag and get it in a new release (v0.12.0
), thanks for finding that!
Yup, that's exactly right. I'm curious about the use case of 0
being disabled? Seems like a label on the deployment might be cleaner to mark it as 'autoscale disabled' might be cleaner?
Hmm that's a good point, I'm not sure if there actually is a use case for disabling autoscaling, I was basing it off the Horizontal Pod Autoscaler's behaviour:
But I think I implemented this incorrectly, autoscaling here is only disabled if minReplicas is > 0
so behaviour should be the same as you have laid out, if minReplicas is set to 0
scaling down to and up from 0
should be allowed - I think this is better.
I think the HPA behavior might have changed when they added the ability to scale to zero.
Thanks!
This is now available in version v0.12.0
, there's an example here and some documentation here.
Hope that helps with your use case!