11package controller
22
33import (
4- "fmt"
5- "io/ioutil"
6- "os"
7-
8- "k8s.io/apimachinery/pkg/runtime"
9- kerrors "k8s.io/apimachinery/pkg/util/errors"
104 kubecontroller "k8s.io/kubernetes/cmd/kube-controller-manager/app"
11- scheduleroptions "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app/options"
12- schedulerapi "k8s.io/kubernetes/plugin/pkg/scheduler/api"
13- latestschedulerapi "k8s.io/kubernetes/plugin/pkg/scheduler/api/latest"
145
156 configapi "github.com/openshift/origin/pkg/cmd/server/api"
16- cmdflags "github.com/openshift/origin/pkg/cmd/util/flags"
177 "github.com/openshift/origin/pkg/cmd/util/variable"
188 "k8s.io/kubernetes/pkg/volume"
199)
@@ -22,9 +12,6 @@ import (
2212// launch the set of kube (not openshift) controllers.
2313type KubeControllerConfig struct {
2414 HorizontalPodAutoscalerControllerConfig HorizontalPodAutoscalerControllerConfig
25-
26- // TODO the scheduler should move out into its own logical component
27- SchedulerControllerConfig SchedulerControllerConfig
2815}
2916
3017// GetControllerInitializers return the controller initializer functions for kube controllers
@@ -36,48 +23,14 @@ func (c KubeControllerConfig) GetControllerInitializers() (map[string]kubecontro
3623 // in openshift-infra, and pass it a scale client that knows how to scale DCs
3724 ret ["horizontalpodautoscaling" ] = c .HorizontalPodAutoscalerControllerConfig .RunController
3825
39- // FIXME: Move this under openshift controller intialization once we figure out
40- // deployment (options).
41- ret ["openshift.io/scheduler" ] = c .SchedulerControllerConfig .RunController
42-
4326 return ret , nil
4427}
4528
4629// BuildKubeControllerConfig builds the struct to create the controller initializers. Eventually we want this to be fully
4730// stock kube with no modification.
4831func BuildKubeControllerConfig (options configapi.MasterConfig ) (* KubeControllerConfig , error ) {
49- var err error
5032 ret := & KubeControllerConfig {}
5133
52- kubeExternal , _ , err := configapi .GetExternalKubeClient (options .MasterClients .OpenShiftLoopbackKubeConfig , options .MasterClients .OpenShiftLoopbackClientConnectionOverrides )
53- if err != nil {
54- return nil , err
55- }
56-
57- var schedulerPolicy * schedulerapi.Policy
58- if _ , err := os .Stat (options .KubernetesMasterConfig .SchedulerConfigFile ); err == nil {
59- schedulerPolicy = & schedulerapi.Policy {}
60- configData , err := ioutil .ReadFile (options .KubernetesMasterConfig .SchedulerConfigFile )
61- if err != nil {
62- return nil , fmt .Errorf ("unable to read scheduler config: %v" , err )
63- }
64- if err := runtime .DecodeInto (latestschedulerapi .Codec , configData , schedulerPolicy ); err != nil {
65- return nil , fmt .Errorf ("invalid scheduler configuration: %v" , err )
66- }
67- }
68- // resolve extended arguments
69- // TODO: this should be done in config validation (along with the above) so we can provide
70- // proper errors
71- schedulerserver := scheduleroptions .NewSchedulerServer ()
72- schedulerserver .PolicyConfigFile = options .KubernetesMasterConfig .SchedulerConfigFile
73- if err := cmdflags .Resolve (options .KubernetesMasterConfig .SchedulerArguments , schedulerserver .AddFlags ); len (err ) > 0 {
74- return nil , kerrors .NewAggregate (err )
75- }
76- ret .SchedulerControllerConfig = SchedulerControllerConfig {
77- PrivilegedClient : kubeExternal ,
78- SchedulerServer : schedulerserver ,
79- }
80-
8134 imageTemplate := variable .NewDefaultImageTemplate ()
8235 imageTemplate .Format = options .ImageConfig .Format
8336 imageTemplate .Latest = options .ImageConfig .Latest
0 commit comments