keda icon indicating copy to clipboard operation
keda copied to clipboard

Field selector support on Scaled object scale target ref

Open kelvien-microsoft opened this issue 1 year ago • 7 comments

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

kelvien-microsoft avatar Apr 18 '24 14:04 kelvien-microsoft

I think this is a good idea

SpiritZhou avatar Apr 22 '24 06:04 SpiritZhou

Agree, I like this.

zroubalik avatar Apr 22 '24 19:04 zroubalik

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

tomkerkhove avatar Apr 24 '24 06:04 tomkerkhove

I can work on this.

SpiritZhou avatar Apr 24 '24 08:04 SpiritZhou

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

SpiritZhou avatar May 07 '24 02:05 SpiritZhou

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

zroubalik avatar May 17 '24 09:05 zroubalik