mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #25313 from davidopp/fix-pod-affinity
Automatic merge from submit-queue Move inter-pod affinity predicate and priority functions from default to non-default due to negative performance effects even when not using the feature Also disable e2e's that assume the feature is enabled. cc/ @gmarek @wojtek-t @kevin-wangzefeng
This commit is contained in:
commit
c04ba0912d
@ -93,6 +93,24 @@ func init() {
|
|||||||
factory.RegisterFitPredicate("HostName", predicates.PodFitsHost)
|
factory.RegisterFitPredicate("HostName", predicates.PodFitsHost)
|
||||||
// Fit is determined by node selector query.
|
// Fit is determined by node selector query.
|
||||||
factory.RegisterFitPredicate("MatchNodeSelector", predicates.PodSelectorMatches)
|
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 {
|
func defaultPredicates() sets.String {
|
||||||
@ -127,13 +145,6 @@ func defaultPredicates() sets.String {
|
|||||||
// GeneralPredicates are the predicates that are enforced by all Kubernetes components
|
// GeneralPredicates are the predicates that are enforced by all Kubernetes components
|
||||||
// (e.g. kubelet and all schedulers)
|
// (e.g. kubelet and all schedulers)
|
||||||
factory.RegisterFitPredicate("GeneralPredicates", predicates.GeneralPredicates),
|
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,
|
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,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// 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.")
|
By("Trying to schedule Pod with nonempty Pod Affinity.")
|
||||||
podName := "without-label-" + string(util.NewUUID())
|
podName := "without-label-" + string(util.NewUUID())
|
||||||
|
|
||||||
@ -831,7 +831,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// test the pod affinity successful matching scenario.
|
// 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
|
// 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
|
// 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
|
// 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.
|
// 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
|
// 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
|
// 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
|
// 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.
|
// 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
|
// 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
|
// 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
|
// 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.
|
// 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
|
// 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
|
// 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
|
// cluster and the scheduler it might be that a "normal" pod cannot be
|
||||||
|
Loading…
Reference in New Issue
Block a user