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.58k stars 1.09k forks source link

Field selector support on Scaled object scale target ref #5707

Open kelvien-microsoft opened 7 months ago

kelvien-microsoft commented 7 months ago

Proposal

Field selector is used in K8s to filter out objects based on the resource fields. I'm proposing that we support a field selector on the Scaled object's .spec.scaleTargetRef.name so that we can find scaled object's with the specified scale target easily and quicker.

There is a validation on the backend to ensure that scaled object is not created on top of an existing deployment that has been targeted by existing scaled object. Error from server (Forbidden): error when creating "so.yaml": admission webhook "vscaledobject.kb.io" denied the request: the workload 'test' of type 'apps/v1.Deployment' is already managed by the ScaledObject 'test-so' I think we can use the same logic in that validation to return the scaled object that fits into the filtering criteria.

Use-Case

As the number of scaled objects and deployment grows, it is hard to keep track of which deployments have a scaler. And having this field-selector allows us to quickly find out if a deployment is valid to be scaled out or not.

Is this a feature you are interested in implementing yourself?

No

Anything else?

No response

SpiritZhou commented 7 months ago

I think this is a good idea

zroubalik commented 7 months ago

Agree, I like this.

tomkerkhove commented 7 months ago

@SpiritZhou is this something you want to your list of things to work on?

SpiritZhou commented 7 months ago

I can work on this.

SpiritZhou commented 6 months ago

Currently, the validation in webhook compares the scaleTargetRef.Name directly from two ScaledObjects instead of listing the scaling target first. Adding a field-selector in scaleTargetRef is not effective. Maybe supporting a field-selector in ScaledObject will be better? WDYT @zroubalik

zroubalik commented 6 months ago

@SpiritZhou I don't have objections, would it solve the original request though?