Surface kube config in scheduler framework handle

This commit is contained in:
Wei Huang
2021-03-29 12:27:27 -07:00
parent 3d48f0d1dd
commit e7f67b1a63
11 changed files with 55 additions and 14 deletions

View File

@@ -32,6 +32,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"
@@ -89,6 +90,7 @@ type Scheduler struct {
}
type schedulerOptions struct {
kubeConfig *restclient.Config
schedulerAlgorithmSource schedulerapi.SchedulerAlgorithmSource
percentageOfNodesToScore int32
podInitialBackoffSeconds int64
@@ -104,6 +106,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 {
@@ -214,6 +223,7 @@ func New(client clientset.Interface,
configurator := &Configurator{
client: client,
kubeConfig: options.kubeConfig,
recorderFactory: recorderFactory,
informerFactory: informerFactory,
schedulerCache: schedulerCache,