runtime: Add controller sharding capability based on label selector#525
Merged
stefanprodan merged 1 commit intomainfrom Mar 28, 2023
Merged
runtime: Add controller sharding capability based on label selector#525stefanprodan merged 1 commit intomainfrom
stefanprodan merged 1 commit intomainfrom
Conversation
hiddeco
reviewed
Mar 28, 2023
0e79601 to
b04bc0c
Compare
makkes
reviewed
Mar 28, 2023
b04bc0c to
978f119
Compare
makkes
approved these changes
Mar 28, 2023
Member
Author
|
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
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>
f6e8e6c to
909e778
Compare
hiddeco
approved these changes
Mar 28, 2023
Member
hiddeco
left a comment
There was a problem hiding this comment.
Awesome, thanks for following through with the nits 🙇
This was referenced Mar 29, 2023
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.
Add
--watch-label-selectorflag 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=shard2By labeling HelmReleases with
sharding.fluxcd.io/shard, users can spread the load betweenhelm-controller-1andhelm-controller-2by setting the label value toshard1orshard2. HelmReleases which don't have thesharding.fluxcd.io/shardlabel, will be reconcile by thehelm-controllerdefault 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: