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