@@ -41,6 +41,7 @@ import (
41
41
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
42
42
"k8s.io/kubernetes/pkg/scheduler/core"
43
43
"k8s.io/kubernetes/pkg/scheduler/factory"
44
+ frameworkplugins "k8s.io/kubernetes/pkg/scheduler/framework/plugins"
44
45
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
45
46
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
46
47
internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue"
@@ -116,11 +117,15 @@ func (sched *Scheduler) Cache() internalcache.Cache {
116
117
}
117
118
118
119
type schedulerOptions struct {
119
- schedulerName string
120
- hardPodAffinitySymmetricWeight int32
121
- disablePreemption bool
122
- percentageOfNodesToScore int32
123
- bindTimeoutSeconds int64
120
+ schedulerName string
121
+ hardPodAffinitySymmetricWeight int32
122
+ disablePreemption bool
123
+ percentageOfNodesToScore int32
124
+ bindTimeoutSeconds int64
125
+ frameworkRegistry framework.Registry
126
+ frameworkConfigProducerRegistry * frameworkplugins.ConfigProducerRegistry
127
+ frameworkPlugins * kubeschedulerconfig.Plugins
128
+ frameworkPluginConfig []kubeschedulerconfig.PluginConfig
124
129
}
125
130
126
131
// Option configures a Scheduler
@@ -161,12 +166,51 @@ func WithBindTimeoutSeconds(bindTimeoutSeconds int64) Option {
161
166
}
162
167
}
163
168
169
+ // WithFrameworkRegistry sets the framework registry.
170
+ func WithFrameworkRegistry (registry framework.Registry ) Option {
171
+ return func (o * schedulerOptions ) {
172
+ o .frameworkRegistry = registry
173
+ }
174
+ }
175
+
176
+ // WithFrameworkConfigProducerRegistry sets the framework plugin producer registry.
177
+ func WithFrameworkConfigProducerRegistry (registry * frameworkplugins.ConfigProducerRegistry ) Option {
178
+ return func (o * schedulerOptions ) {
179
+ o .frameworkConfigProducerRegistry = registry
180
+ }
181
+ }
182
+
183
+ // WithFrameworkPlugins sets the plugins that the framework should be configured with.
184
+ func WithFrameworkPlugins (plugins * kubeschedulerconfig.Plugins ) Option {
185
+ return func (o * schedulerOptions ) {
186
+ o .frameworkPlugins = plugins
187
+ }
188
+ }
189
+
190
+ // WithFrameworkPluginConfig sets the PluginConfig slice that the framework should be configured with.
191
+ func WithFrameworkPluginConfig (pluginConfig []kubeschedulerconfig.PluginConfig ) Option {
192
+ return func (o * schedulerOptions ) {
193
+ o .frameworkPluginConfig = pluginConfig
194
+ }
195
+ }
196
+
164
197
var defaultSchedulerOptions = schedulerOptions {
165
- schedulerName : v1 .DefaultSchedulerName ,
166
- hardPodAffinitySymmetricWeight : v1 .DefaultHardPodAffinitySymmetricWeight ,
167
- disablePreemption : false ,
168
- percentageOfNodesToScore : schedulerapi .DefaultPercentageOfNodesToScore ,
169
- bindTimeoutSeconds : BindTimeoutSeconds ,
198
+ schedulerName : v1 .DefaultSchedulerName ,
199
+ hardPodAffinitySymmetricWeight : v1 .DefaultHardPodAffinitySymmetricWeight ,
200
+ disablePreemption : false ,
201
+ percentageOfNodesToScore : schedulerapi .DefaultPercentageOfNodesToScore ,
202
+ bindTimeoutSeconds : BindTimeoutSeconds ,
203
+ frameworkRegistry : frameworkplugins .NewDefaultRegistry (),
204
+ frameworkConfigProducerRegistry : frameworkplugins .NewDefaultConfigProducerRegistry (),
205
+ // The plugins and pluginConfig options are currently nil because we currently don't have
206
+ // "default" plugins. All plugins that we run through the framework currently come from two
207
+ // sources: 1) specified in component config, in which case those two options should be
208
+ // set using their corresponding With* functions, 2) predicate/priority-mapped plugins, which
209
+ // pluginConfigProducerRegistry contains a mapping for and produces their configurations.
210
+ // TODO(ahg-g) Once predicates and priorities are migrated to natively run as plugins, the
211
+ // below two parameters will be populated accordingly.
212
+ frameworkPlugins : nil ,
213
+ frameworkPluginConfig : nil ,
170
214
}
171
215
172
216
// New returns a Scheduler
@@ -185,9 +229,6 @@ func New(client clientset.Interface,
185
229
recorder events.EventRecorder ,
186
230
schedulerAlgorithmSource kubeschedulerconfig.SchedulerAlgorithmSource ,
187
231
stopCh <- chan struct {},
188
- registry framework.Registry ,
189
- plugins * kubeschedulerconfig.Plugins ,
190
- pluginConfig []kubeschedulerconfig.PluginConfig ,
191
232
opts ... Option ) (* Scheduler , error ) {
192
233
193
234
options := defaultSchedulerOptions
@@ -212,9 +253,10 @@ func New(client clientset.Interface,
212
253
DisablePreemption : options .disablePreemption ,
213
254
PercentageOfNodesToScore : options .percentageOfNodesToScore ,
214
255
BindTimeoutSeconds : options .bindTimeoutSeconds ,
215
- Registry : registry ,
216
- Plugins : plugins ,
217
- PluginConfig : pluginConfig ,
256
+ Registry : options .frameworkRegistry ,
257
+ PluginConfigProducerRegistry : options .frameworkConfigProducerRegistry ,
258
+ Plugins : options .frameworkPlugins ,
259
+ PluginConfig : options .frameworkPluginConfig ,
218
260
})
219
261
var config * factory.Config
220
262
source := schedulerAlgorithmSource
0 commit comments