mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Enable PodAffinity by default in scheduler
This commit is contained in:
parent
ca7ad6896b
commit
022719b323
@ -812,7 +812,7 @@ func (c *PodAffinityChecker) InterPodAffinityMatches(pod *api.Pod, meta interfac
|
|||||||
return false, fmt.Errorf("node not found")
|
return false, fmt.Errorf("node not found")
|
||||||
}
|
}
|
||||||
if !c.satisfiesExistingPodsAntiAffinity(pod, meta, node) {
|
if !c.satisfiesExistingPodsAntiAffinity(pod, meta, node) {
|
||||||
return false, nil
|
return false, ErrPodAffinityNotMatch
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now check if <pod> requirements will be satisfied on this node.
|
// Now check if <pod> requirements will be satisfied on this node.
|
||||||
@ -824,7 +824,7 @@ func (c *PodAffinityChecker) InterPodAffinityMatches(pod *api.Pod, meta interfac
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if !c.satisfiesPodsAffinityAntiAffinity(pod, node, affinity) {
|
if !c.satisfiesPodsAffinityAntiAffinity(pod, node, affinity) {
|
||||||
return false, nil
|
return false, ErrPodAffinityNotMatch
|
||||||
}
|
}
|
||||||
|
|
||||||
if glog.V(10) {
|
if glog.V(10) {
|
||||||
|
@ -93,24 +93,6 @@ 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 {
|
||||||
@ -154,6 +136,14 @@ func defaultPredicates() sets.String {
|
|||||||
|
|
||||||
// Fit is determined by node disk pressure condition.
|
// Fit is determined by node disk pressure condition.
|
||||||
factory.RegisterFitPredicate("CheckNodeDiskPressure", predicates.CheckNodeDiskPressurePredicate),
|
factory.RegisterFitPredicate("CheckNodeDiskPressure", predicates.CheckNodeDiskPressurePredicate),
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,5 +176,16 @@ func defaultPriorities() sets.String {
|
|||||||
),
|
),
|
||||||
factory.RegisterPriorityFunction("NodeAffinityPriority", priorities.CalculateNodeAffinityPriority, 1),
|
factory.RegisterPriorityFunction("NodeAffinityPriority", priorities.CalculateNodeAffinityPriority, 1),
|
||||||
factory.RegisterPriorityFunction("TaintTolerationPriority", priorities.ComputeTaintTolerationPriority, 1),
|
factory.RegisterPriorityFunction("TaintTolerationPriority", priorities.ComputeTaintTolerationPriority, 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,
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -976,7 +976,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
|
|||||||
framework.Logf("Sleeping 10 seconds and crossing our fingers that scheduler will run in that time.")
|
framework.Logf("Sleeping 10 seconds and crossing our fingers that scheduler will run in that time.")
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
|
||||||
verifyResult(c, labelPodName, 1, 1, ns)
|
verifyResult(c, labelPodName, 1, 0, ns)
|
||||||
})
|
})
|
||||||
|
|
||||||
// test the pod affinity successful matching scenario with multiple Label Operators.
|
// test the pod affinity successful matching scenario with multiple Label Operators.
|
||||||
|
Loading…
Reference in New Issue
Block a user