feat: add WATCH_LABEL_SELECTOR env var to filter reconciled objects by label#7816
Open
rossanorbr wants to merge 2 commits into
Open
feat: add WATCH_LABEL_SELECTOR env var to filter reconciled objects by label#7816rossanorbr wants to merge 2 commits into
rossanorbr wants to merge 2 commits into
Conversation
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
…y label
Adds WATCH_LABEL_SELECTOR environment variable that scopes which
ScaledObjects, ScaledJobs, TriggerAuthentications and
ClusterTriggerAuthentications an operator instance reconciles, based on
labels on those resources. Mirrors WATCH_NAMESPACE but filters by label
instead of by namespace.
Empty or unset preserves current behaviour. When set, filtering happens
at the informer cache level (cache.ByObject{Label: selector}) and at the
controller predicate level (predicate.LabelSelectorPredicate). The HPA
cache is filtered too since KEDA copies SO labels onto the HPA and
Owns(HPA) reconciles parent SOs.
Closes kedacore#7738
Signed-off-by: Rossano Bestteti <rossanorbr@gmail.com>
8b8a7b3 to
ffdc215
Compare
rossanorbr
added a commit
to rossanorbr/charts
that referenced
this pull request
Jun 2, 2026
Adds a `watchLabelSelector` chart value that maps to the `WATCH_LABEL_SELECTOR` env var on the operator Deployment. Mirrors the existing `watchNamespace` value, but filters reconciled objects by label instead of by namespace. Default is empty (backward compatible: no label-based filtering). Relates to kedacore/keda#7816 Signed-off-by: Rossano Bestteti <rossanorbr@gmail.com>
This was referenced Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
WATCH_LABEL_SELECTORenvironment variable that scopes whichScaledObjects,ScaledJobs,TriggerAuthenticationsandClusterTriggerAuthenticationsan operator instance reconciles, based on labels on those resources.Mirrors the existing
WATCH_NAMESPACEenv var, but filters by label instead of by namespace. Empty or unset means watch everything (current behaviour, backward compatible). When set, accepts the standard Kubernetes label selector syntax:environment=productiontier in (gold,silver),!canaryFiltering happens at two layers:
cache.ByObject{Label: selector}so non-matching objects never enter the informer cache.predicate.LabelSelectorPredicateon the four controllers so events for non-matching objects are dropped before reconciliation.The HPA cache is filtered too. KEDA copies the ScaledObject labels onto the HPA, and the operator uses
Owns(HPA)to enqueue reconciles, so the HPA cache has to follow the same filter to keep partitioning correct.Checklist
make generate-scalers-schemahas been run to update any outdated generated filesFixes #7738
Relates to kedacore/charts#864
Relates to kedacore/keda-docs#1785