diff --git a/plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go b/plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go index 9e9ddb3be8f..b9304cc7bc4 100644 --- a/plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go +++ b/plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go @@ -93,6 +93,24 @@ func init() { factory.RegisterFitPredicate("HostName", predicates.PodFitsHost) // Fit is determined by node selector query. factory.RegisterFitPredicate("MatchNodeSelector", predicates.PodSelectorMatches) + // Fit is determined by inter-pod affinity. + factory.RegisterFitPredicateFactory( + "MatchInterPodAffinity", + func(args factory.PluginFactoryArgs) algorithm.FitPredicate { + return predicates.NewPodAffinityPredicate(args.NodeInfo, args.PodLister, args.FailureDomains) + }, + ) + //pods should be placed in the same topological domain (e.g. same node, same rack, same zone, same power domain, etc.) + //as some other pods, or, conversely, should not be placed in the same topological domain as some other pods. + factory.RegisterPriorityConfigFactory( + "InterPodAffinityPriority", + factory.PriorityConfigFactory{ + Function: func(args factory.PluginFactoryArgs) algorithm.PriorityFunction { + return priorities.NewInterPodAffinityPriority(args.NodeInfo, args.NodeLister, args.PodLister, args.HardPodAffinitySymmetricWeight, args.FailureDomains) + }, + Weight: 1, + }, + ) } func defaultPredicates() sets.String { @@ -127,13 +145,6 @@ func defaultPredicates() sets.String { // GeneralPredicates are the predicates that are enforced by all Kubernetes components // (e.g. kubelet and all schedulers) factory.RegisterFitPredicate("GeneralPredicates", predicates.GeneralPredicates), - // Fit is determined by inter-pod affinity. - factory.RegisterFitPredicateFactory( - "MatchInterPodAffinity", - func(args factory.PluginFactoryArgs) algorithm.FitPredicate { - return predicates.NewPodAffinityPredicate(args.NodeInfo, args.PodLister, args.FailureDomains) - }, - ), ) } @@ -162,16 +173,5 @@ func defaultPriorities() sets.String { Weight: 1, }, ), - //pods should be placed in the same topological domain (e.g. same node, same rack, same zone, same power domain, etc.) - //as some other pods, or, conversely, should not be placed in the same topological domain as some other pods. - factory.RegisterPriorityConfigFactory( - "InterPodAffinityPriority", - factory.PriorityConfigFactory{ - Function: func(args factory.PluginFactoryArgs) algorithm.PriorityFunction { - return priorities.NewInterPodAffinityPriority(args.NodeInfo, args.NodeLister, args.PodLister, args.HardPodAffinitySymmetricWeight, args.FailureDomains) - }, - Weight: 1, - }, - ), ) } diff --git a/test/e2e/scheduler_predicates.go b/test/e2e/scheduler_predicates.go index 56d3ed6fa62..ad2ae2306aa 100644 --- a/test/e2e/scheduler_predicates.go +++ b/test/e2e/scheduler_predicates.go @@ -783,7 +783,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { }) // Test Nodes does not have any pod, hence it should be impossible to schedule a Pod with pod affinity. - It("validates that Inter-pod-Affinity is respected if not matching", func() { + It("validates that Inter-pod-Affinity is respected if not matching [Feature:PodAffinity]", func() { By("Trying to schedule Pod with nonempty Pod Affinity.") podName := "without-label-" + string(util.NewUUID()) @@ -831,7 +831,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { }) // test the pod affinity successful matching scenario. - It("validates that InterPodAffinity is respected if matching", func() { + It("validates that InterPodAffinity is respected if matching [Feature:PodAffinity]", func() { // launch a pod to find a node which can launch a pod. We intentionally do // not just take the node list and choose the first of them. Depending on the // cluster and the scheduler it might be that a "normal" pod cannot be @@ -923,7 +923,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { }) // test when the pod anti affinity rule is not satisfied, the pod would stay pending. - It("validates that InterPodAntiAffinity is respected if matching", func() { + It("validates that InterPodAntiAffinity is respected if matching 2 [Feature:PodAffinity]", func() { // launch a pod to find a node which can launch a pod. We intentionally do // not just take the node list and choose the first of them. Depending on the // cluster and the scheduler it might be that a "normal" pod cannot be @@ -1011,7 +1011,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { }) // test the pod affinity successful matching scenario with multiple Label Operators. - It("validates that InterPodAffinity is respected if matching with multiple Affinities", func() { + It("validates that InterPodAffinity is respected if matching with multiple Affinities [Feature:PodAffinity]", func() { // launch a pod to find a node which can launch a pod. We intentionally do // not just take the node list and choose the first of them. Depending on the // cluster and the scheduler it might be that a "normal" pod cannot be @@ -1111,7 +1111,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() { }) // test the pod affinity and anti affinity successful matching scenario. - It("validates that InterPod Affinity and AntiAffinity is respected if matching", func() { + It("validates that InterPod Affinity and AntiAffinity is respected if matching [Feature:PodAffinity]", func() { // launch a pod to find a node which can launch a pod. We intentionally do // not just take the node list and choose the first of them. Depending on the // cluster and the scheduler it might be that a "normal" pod cannot be