-
Notifications
You must be signed in to change notification settings - Fork 680
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
Add namespace label selector #1501
base: master
Are you sure you want to change the base?
Add namespace label selector #1501
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @RomanenkoDenys! |
Hi @RomanenkoDenys. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test would you please squash your commits? |
@RomanenkoDenys great feature! would you be open to adding an e2e test for this? |
@@ -157,6 +159,25 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug | |||
}) | |||
} | |||
|
|||
// check pod by namespace label filter | |||
if defaultEvictorArgs.NamespaceLabelSelector != nil { |
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.
E.g. LowNodeUtilization plugin will not like it:
WithFilter(handle.Evictor().Filter). |
This needs to go under PreEvictionFilter
extension point. In the case of having each plugin to decide whether it wants to perform namespace filtering before balancing/descheduling pods the filtering needs to be added in each plugin's New
function. Or in case namespaces are iterated explicitly in the corresponding methods (if it can not be done as part of pod filtering). E.g.
Lines 124 to 128 in a3146a1
var includedNamespaces, excludedNamespaces sets.Set[string] | |
if d.args.Namespaces != nil { | |
includedNamespaces = sets.New(d.args.Namespaces.Include...) | |
excludedNamespaces = sets.New(d.args.Namespaces.Exclude...) | |
} |
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.
Hi, I think you are right. But i have one question. In front of my code there is a constraint for podLabelSelector. And this selector theoretically does not allow to compute all pods, because we can label pods and remove them from the computation using pod label selector.
Icluding/excluding namespaces by name list is not acceptable for us, because in this case we cannot work with dynamically created namespaces (e.g. for dev environments). Using a label selector is our preferred method.
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.
Is this part of #1499? Or, is your PR a parallel/independent effort?
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.
But i have one question.
Which question is it? I see only statements.
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.
Yes, it's a part of #1499. The question is, if you can select pods using a label selector, how will the computational resources of all pods work? And why selecting pods by namespace label selector differs from pod label selector in that case ?
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.
Code moved to the preEvictionFilter
. Please check it again.
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.
@ingvagabund hello. Can you help me ? Now namespaces list by label selector calculated for every pod which is passed to the PreEvictionFilter. I think we can calculate namespaces name list and pass it to the PreEvictionFilter to reduce cpu usage (i think we can calculate it on every Descheduler Loop). Please advise where this can be done.
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.
You could create a new namespace indexer storing namespaces based on a label selector. Which will give you all the namespaces at any given point for free.
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.
Hello, i rebased to current main and add indexer. Can you please check implementation ? If all ok, i'll add tests.
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.
@ingvagabund hi, please check implementation if you have time.
35f4eba
to
056805f
Compare
a619cfc
to
1b6910e
Compare
Yes, when i stabilize code, i will squash commits. Thank you ! |
@RomanenkoDenys do you need help ? we will soon need that feature, I'm happy to take this PR to completion and fix the open points. |
3d0cee3
to
bfacd76
Compare
Hello, no, thanks. Today i pushed new implementation as we discussed with @ingvagabundand and rebase to current master branch. I need one more day to do some tests. Can you check PR after that ? If implementation is ok i'll write tests for it. |
@clementnuss can you please check implementation ? |
I could but I'm not a contributor of the repo, sorry if my comment implied that. I think it's best if the assigned people have a chance to look at it, I'd have to first get familiar with the codebase. sorry! |
/test all |
@RomanenkoDenys: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
||
// check pod by namespace label filter | ||
indexName := "namespaceWithLabelSelector" | ||
indexer, err := getNamespacesListByLabelSelector(indexName, d.args.NamespaceLabelSelector, d.handle) |
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.
The indexer needs to be created before any of the plugins start running. Otherwise, the indexer cache might not get populated properly. In New
function. In the same manner as getPodIndexerByOwnerRefs
is.
Added namespace label selector for filtering pods in the DefaultEvictor plugin.
This is useful when descheduler uses only, for example, in the stage or dev namespaces.