-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Task 2: Schedule DaemonSet Pods by default scheduler. #59862
Conversation
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.
Thanks, @k82cn!
Your change looks correct to me and given that we want to keep the old behavior and enable the new behavior with a flag, your change is OK, but in the future when we remove the scheduling logic of the DS controller, we can refactor and simplify the logic.
// Predicates checks if a DaemonSet's pod can be scheduled on a node using GeneralPredicates | ||
// and PodToleratesNodeTaints predicate | ||
func Predicates(pod *v1.Pod, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) { | ||
var predicateFails []algorithm.PredicateFailureReason | ||
critical := utilfeature.DefaultFeatureGate.Enabled(features.ExperimentalCriticalPodAnnotation) && kubelettypes.IsCriticalPod(pod) | ||
|
||
// If NoDaemonSetScheduler is enable, only check nodeSelector and nodeAffinity. |
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.
s/enable/enabled/
@@ -1327,11 +1342,48 @@ func NewPod(ds *extensions.DaemonSet, nodeName string) *v1.Pod { | |||
return newPod | |||
} | |||
|
|||
// nodeSelectPredicates are the predicates that used to select node candidates for DaemonSet | |||
func nodeSelectPredicates(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) { |
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.
I would suggest renaming to nodeSelectionPredicates
.
@@ -1327,11 +1342,48 @@ func NewPod(ds *extensions.DaemonSet, nodeName string) *v1.Pod { | |||
return newPod | |||
} | |||
|
|||
// nodeSelectPredicates are the predicates that used to select node candidates for DaemonSet |
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.
Please change to:
nodeSelectionPredicates runs a set of predicates that select candidate nodes for the DaemonSet.
|
||
// If NoDaemonSetScheduler is enable, only check nodeSelector and nodeAffinity. | ||
if utilfeature.DefaultFeatureGate.Enabled(features.NoDaemonSetScheduler) { | ||
// EssentialPredicates includes PodFitsHost, PodFitsHostPorts and PodMatchNodeSelector |
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.
We don't need to run PodFitsHostPorts and actually your function does not run it. Please remove it from the comment.
Please add a release note. |
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.
// Clearup hostname, default scheduler will handle it. | ||
hostname = "" | ||
podTemplate = template.DeepCopy() | ||
podTemplate.Spec.Affinity = util.AppendDaemonSetPodNodeAffinity( |
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.
Please combine this and #59798 into one PR (ok to be separate commits)
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.
sure; let me combine them :)
// Predicates checks if a DaemonSet's pod can be scheduled on a node using GeneralPredicates | ||
// and PodToleratesNodeTaints predicate | ||
func Predicates(pod *v1.Pod, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) { | ||
var predicateFails []algorithm.PredicateFailureReason | ||
critical := utilfeature.DefaultFeatureGate.Enabled(features.ExperimentalCriticalPodAnnotation) && kubelettypes.IsCriticalPod(pod) | ||
|
||
// If NoDaemonSetScheduler is enabled, only check nodeSelector and nodeAffinity. |
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.
So we can't remove all predicates in DS controller even when switching to default scheduler?
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.
As daemonset can use NodeAffinity
and NodeSelector
to define a subset of cluster to stat the Daemon Pods, we re-use those predicates.
The advantage is that we can choose which predicate we'd like to re-use according to DaemonSet's requirement instead of keep it align with default scheduler when a new feature introduced.
8f13c7e
to
3b9650b
Compare
/lgtm |
/assign @smarterclayton |
|
||
if utilfeature.DefaultFeatureGate.Enabled(features.ScheduleDaemonSetPods) { | ||
podTemplate = template.DeepCopy() | ||
podTemplate.Spec.Affinity = util.ReplaceDaemonSetPodHostnameNodeAffinity( |
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.
will this deal with existing daemonset pods during migration? or the daemonset have to be recreated/rescaled?
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.
This only affects Daemon pod creation. Existing pods won't be affected. Existing DaemonSet might be affected when, for example, their pods are killed/dead or new nodes are added.
Feature name approved /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: janetkuo, k82cn, smarterclayton The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind feature |
/priority critical-urgent |
and ping for milestone approve :) |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process @janetkuo @k82cn @smarterclayton Pull Request Labels
|
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Signed-off-by: Da K. Ma klaus1982.cn@gmail.com
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):part of #59194
kubernetes/enhancements#548
Release note: