kedacore / keda

KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes
https://keda.sh
Apache License 2.0
8.11k stars 1.02k forks source link

Provide CloudEvents when scaling workload(s) from/to 0 #3527

Open tomkerkhove opened 1 year ago

tomkerkhove commented 1 year ago

Proposal

Event Types

Payload:

{
    "specversion" : "1.0",
    "type" : "keda.workload.scaletozero.v1",
    "subject" : "/{kubernetes-cluster-name}/{namespace}/workload/{resource-name}/",
    "time" : "2018-04-05T17:31:00Z",
    "datacontenttype" : "application/json",
    "data" : {
      "scaleTarget": {
         "name": "sample-workload",
         "apiVersion": "Deployment",
         "kind": "apps/v1",
      }
   }
}

Use-Case

Allow end-users to get notified when workloads are scaling to/from 0.

Anything else?

Relates to https://github.com/kedacore/keda/issues/479

tomkerkhove commented 4 months ago

@neelanjan00 will look in to this

neelanjan00 commented 4 months ago

A question, do we want to emit an event for a ScaledJob scaling from/to 0? If yes, can you suggest at which point during the reconciliation we can check if the runningJobCount has become zero?

Sorry if it's a dumb question. As far as I understood KEDA doesn't actively scale the ScaledJob workloads to zero since Kubernetes Jobs are not meant to keep executing, and after they complete executing the number of pods becomes zero.

CC: @tomkerkhove

neelanjan00 commented 4 months ago

Hi @tomkerkhove can you PTAL at the above comment? Thanks!

tomkerkhove commented 4 months ago

There are no stupid questions so no worries =) Let's leave out ScaledJobs indeed given we do not scale to 0 but only activate new instances when need be

tomkerkhove commented 3 weeks ago

Re-assigned to @SpiritZhou after @neelanjan00's comment on PR - Thanks for effort anyway!