-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: Add controller sharding capability based on label selector #525
Merged
Conversation
This file contains 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
stefanprodan
added
enhancement
New feature or request
area/runtime
Controller runtime related issues and pull requests
labels
Mar 28, 2023
hiddeco
reviewed
Mar 28, 2023
stefanprodan
force-pushed
the
watch-label-selector
branch
2 times, most recently
from
March 28, 2023 12:49
0e79601
to
b04bc0c
Compare
stefanprodan
changed the title
runtime: Add reconciler sharding capability based on label selector
runtime: Add controller sharding capability based on label selector
Mar 28, 2023
makkes
reviewed
Mar 28, 2023
stefanprodan
force-pushed
the
watch-label-selector
branch
from
March 28, 2023 13:56
b04bc0c
to
978f119
Compare
makkes
approved these changes
Mar 28, 2023
I've tested this with source-controller and passing the label selector to the cache manager works flawlessly 🎉 |
hiddeco
reviewed
Mar 28, 2023
hiddeco
reviewed
Mar 28, 2023
stefanprodan
force-pushed
the
watch-label-selector
branch
from
March 28, 2023 17:04
978f119
to
f6e8e6c
Compare
hiddeco
reviewed
Mar 28, 2023
Add `--watch-label-selector` flag to runtime. When specified the reconcilers will only watch for changes of those resources with matching labels. This enables horizontal scaling of Flux controller, where each controller can be deployed multiple times with a unique label selector which is used as the sharding key. Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
stefanprodan
force-pushed
the
watch-label-selector
branch
from
March 28, 2023 17:28
f6e8e6c
to
909e778
Compare
hiddeco
approved these changes
Mar 28, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for following through with the nits 🙇
This was referenced Mar 29, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Add
--watch-label-selector
flag to controller runtime. When specified the controller's reconcilers will only watch for changes of those resources with matching labels.To restrict the controller watch, the selector exposed by this package must be wired in each controller's cache manager.
This enables horizontal scaling of Flux controllers, where each controller can be deployed multiple times with a unique label selector which is used as the sharding key.
For example, to shard the reconciliation of HelmReleases in a cluster, user will deploy two extra helm-controller instances:
--watch-label-selector=sharding.fluxcd.io/shard notin (shard1, shard2)
--watch-label-selector=sharding.fluxcd.io/shard=shard1
--watch-label-selector=sharding.fluxcd.io/shard=shard2
By labeling HelmReleases with
sharding.fluxcd.io/shard
, users can spread the load betweenhelm-controller-1
andhelm-controller-2
by setting the label value toshard1
orshard2
. HelmReleases which don't have thesharding.fluxcd.io/shard
label, will be reconcile by thehelm-controller
default instance.Sharding source-controller works the same but users will have to create a matching Kubernetes Service for each SC deployment, then set the Service name in storage address flag. Example: