Merge pull request #100644 from Huang-Wei/sched-fwk-config

Surface kube config in scheduler framework handle
This commit is contained in:
Kubernetes Prow Robot
2021-04-12 19:12:49 -07:00
committed by GitHub
11 changed files with 55 additions and 14 deletions

View File

@@ -33,6 +33,7 @@ import (
"k8s.io/client-go/informers"
coreinformers "k8s.io/client-go/informers/core/v1"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
@@ -90,6 +91,7 @@ type Scheduler struct {
}
type schedulerOptions struct {
kubeConfig *restclient.Config
schedulerAlgorithmSource schedulerapi.SchedulerAlgorithmSource
percentageOfNodesToScore int32
podInitialBackoffSeconds int64
@@ -105,6 +107,13 @@ type schedulerOptions struct {
// Option configures a Scheduler
type Option func(*schedulerOptions)
// WithKubeConfig sets the kube config for Scheduler.
func WithKubeConfig(cfg *restclient.Config) Option {
return func(o *schedulerOptions) {
o.kubeConfig = cfg
}
}
// WithProfiles sets profiles for Scheduler. By default, there is one profile
// with the name "default-scheduler".
func WithProfiles(p ...schedulerapi.KubeSchedulerProfile) Option {
@@ -215,6 +224,7 @@ func New(client clientset.Interface,
configurator := &Configurator{
client: client,
kubeConfig: options.kubeConfig,
recorderFactory: recorderFactory,
informerFactory: informerFactory,
schedulerCache: schedulerCache,