mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Pass InformerFactory instead of indivisual informers in scheduler configuration logic
This commit is contained in:
@@ -55,40 +55,63 @@ func init() {
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.NoVolumeZoneConflictPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewVolumeZonePredicate(args.PVLister, args.PVCLister, args.StorageClassLister)
|
||||
pvLister := args.InformerFactory.Core().V1().PersistentVolumes().Lister()
|
||||
pvcLister := args.InformerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||
storageClassLister := args.InformerFactory.Storage().V1().StorageClasses().Lister()
|
||||
return predicates.NewVolumeZonePredicate(pvLister, pvcLister, storageClassLister)
|
||||
},
|
||||
)
|
||||
// Fit is determined by whether or not there would be too many AWS EBS volumes attached to the node
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.MaxEBSVolumeCountPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.EBSVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||
csiNodeLister := scheduler.GetCSINodeLister(args.InformerFactory)
|
||||
pvLister := args.InformerFactory.Core().V1().PersistentVolumes().Lister()
|
||||
pvcLister := args.InformerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||
storageClassLister := args.InformerFactory.Storage().V1().StorageClasses().Lister()
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.EBSVolumeFilterType, csiNodeLister, storageClassLister, pvLister, pvcLister)
|
||||
},
|
||||
)
|
||||
// Fit is determined by whether or not there would be too many GCE PD volumes attached to the node
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.MaxGCEPDVolumeCountPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||
csiNodeLister := scheduler.GetCSINodeLister(args.InformerFactory)
|
||||
pvLister := args.InformerFactory.Core().V1().PersistentVolumes().Lister()
|
||||
pvcLister := args.InformerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||
storageClassLister := args.InformerFactory.Storage().V1().StorageClasses().Lister()
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilterType, csiNodeLister, storageClassLister, pvLister, pvcLister)
|
||||
},
|
||||
)
|
||||
// Fit is determined by whether or not there would be too many Azure Disk volumes attached to the node
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.MaxAzureDiskVolumeCountPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||
csiNodeLister := scheduler.GetCSINodeLister(args.InformerFactory)
|
||||
pvLister := args.InformerFactory.Core().V1().PersistentVolumes().Lister()
|
||||
pvcLister := args.InformerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||
storageClassLister := args.InformerFactory.Storage().V1().StorageClasses().Lister()
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilterType, csiNodeLister, storageClassLister, pvLister, pvcLister)
|
||||
},
|
||||
)
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.MaxCSIVolumeCountPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewCSIMaxVolumeLimitPredicate(args.CSINodeLister, args.PVLister, args.PVCLister, args.StorageClassLister)
|
||||
csiNodeLister := scheduler.GetCSINodeLister(args.InformerFactory)
|
||||
pvLister := args.InformerFactory.Core().V1().PersistentVolumes().Lister()
|
||||
pvcLister := args.InformerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||
storageClassLister := args.InformerFactory.Storage().V1().StorageClasses().Lister()
|
||||
return predicates.NewCSIMaxVolumeLimitPredicate(csiNodeLister, pvLister, pvcLister, storageClassLister)
|
||||
},
|
||||
)
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.MaxCinderVolumeCountPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.CinderVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||
csiNodeLister := scheduler.GetCSINodeLister(args.InformerFactory)
|
||||
pvLister := args.InformerFactory.Core().V1().PersistentVolumes().Lister()
|
||||
pvcLister := args.InformerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||
storageClassLister := args.InformerFactory.Storage().V1().StorageClasses().Lister()
|
||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.CinderVolumeFilterType, csiNodeLister, storageClassLister, pvLister, pvcLister)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -96,7 +119,7 @@ func init() {
|
||||
scheduler.RegisterFitPredicateFactory(
|
||||
predicates.MatchInterPodAffinityPred,
|
||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||
return predicates.NewPodAffinityPredicate(args.NodeInfoLister, args.PodLister)
|
||||
return predicates.NewPodAffinityPredicate(args.SharedLister.NodeInfos(), args.SharedLister.Pods())
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -26,7 +26,11 @@ func init() {
|
||||
// Register functions that extract metadata used by priorities computations.
|
||||
scheduler.RegisterPriorityMetadataProducerFactory(
|
||||
func(args scheduler.PluginFactoryArgs) priorities.MetadataProducer {
|
||||
return priorities.NewMetadataFactory(args.ServiceLister, args.ControllerLister, args.ReplicaSetLister, args.StatefulSetLister, args.HardPodAffinitySymmetricWeight)
|
||||
serviceLister := args.InformerFactory.Core().V1().Services().Lister()
|
||||
controllerLister := args.InformerFactory.Core().V1().ReplicationControllers().Lister()
|
||||
replicaSetLister := args.InformerFactory.Apps().V1().ReplicaSets().Lister()
|
||||
statefulSetLister := args.InformerFactory.Apps().V1().StatefulSets().Lister()
|
||||
return priorities.NewMetadataFactory(serviceLister, controllerLister, replicaSetLister, statefulSetLister, args.HardPodAffinitySymmetricWeight)
|
||||
})
|
||||
|
||||
// ServiceSpreadingPriority is a priority config factory that spreads pods by minimizing
|
||||
@@ -37,7 +41,8 @@ func init() {
|
||||
priorities.ServiceSpreadingPriority,
|
||||
scheduler.PriorityConfigFactory{
|
||||
MapReduceFunction: func(args scheduler.PluginFactoryArgs) (priorities.PriorityMapFunction, priorities.PriorityReduceFunction) {
|
||||
return priorities.NewSelectorSpreadPriority(args.ServiceLister, algorithm.EmptyControllerLister{}, algorithm.EmptyReplicaSetLister{}, algorithm.EmptyStatefulSetLister{})
|
||||
serviceLister := args.InformerFactory.Core().V1().Services().Lister()
|
||||
return priorities.NewSelectorSpreadPriority(serviceLister, algorithm.EmptyControllerLister{}, algorithm.EmptyReplicaSetLister{}, algorithm.EmptyStatefulSetLister{})
|
||||
},
|
||||
Weight: 1,
|
||||
},
|
||||
@@ -54,7 +59,11 @@ func init() {
|
||||
priorities.SelectorSpreadPriority,
|
||||
scheduler.PriorityConfigFactory{
|
||||
MapReduceFunction: func(args scheduler.PluginFactoryArgs) (priorities.PriorityMapFunction, priorities.PriorityReduceFunction) {
|
||||
return priorities.NewSelectorSpreadPriority(args.ServiceLister, args.ControllerLister, args.ReplicaSetLister, args.StatefulSetLister)
|
||||
serviceLister := args.InformerFactory.Core().V1().Services().Lister()
|
||||
controllerLister := args.InformerFactory.Core().V1().ReplicationControllers().Lister()
|
||||
replicaSetLister := args.InformerFactory.Apps().V1().ReplicaSets().Lister()
|
||||
statefulSetLister := args.InformerFactory.Apps().V1().StatefulSets().Lister()
|
||||
return priorities.NewSelectorSpreadPriority(serviceLister, controllerLister, replicaSetLister, statefulSetLister)
|
||||
},
|
||||
Weight: 1,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user