vmware-archive / kubeless

Kubernetes Native Serverless Framework
https://kubeless.io
Apache License 2.0
6.86k stars 754 forks source link

Autoscale delete should remove extra instances #959

Open mmindenhall opened 5 years ago

mmindenhall commented 5 years ago

Is this a BUG REPORT or FEATURE REQUEST?:

Bug.

What happened:

I created a bunch of instances of a function to do some benchmarking:

$ kubeless autoscale create my-func --min 20 --max 20 --metric cpu --value 20

This scaled up to 20 pods, and I completed my benchmarking.

Then, I deleted the autoscale rule:

$ kubeless autoscale delete my-func

About 30 minutes later, all 20 pods were still running. In order to bring this back down to a single pod, I had to:

  1. $ kubeless autoscale create my-func --min 1 --max 1 --metric cpu --value 20
  2. Wait for pods to terminate.
  3. $ kubeless autoscale delete my-func

What you expected to happen:

When an autoscale rule is deleted, any additional scaled pods should be removed.

How to reproduce it (as minimally and precisely as possible):

See above.

Anything else we need to know?:

Environment:

andresmgot commented 5 years ago

Hi @mmindenhall,

In this case what we do is leverage the Kubernetes Horizontal Pod Autoscale: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ When you delete an autoscaler there is no way to know the original value for the number of replicas that a Deployment had (because it may be more than one). That's why the deployment is left with the number of replicas that it has at that moment.

If after deleting the autoscaler you want to set a fix number of replicas you can also execute:

kubectl scale --replicas 1 deployment my-func