Create componentconfig object for scheduler configuration.

Signed-off-by: Mike Danese <mikedanese@google.com>
This commit is contained in:
Mike Danese 2016-01-14 14:00:23 -08:00
parent 6e6974a38f
commit 126b1df879
3 changed files with 45 additions and 26 deletions

View File

@ -290,6 +290,29 @@ type KubeletConfiguration struct {
NonMasqueradeCIDR string `json:"nonMasqueradeCIDR"`
}
type KubeSchedulerConfiguration struct {
// port is the port that the scheduler's http service runs on.
Port int `json:"port"`
// address is the IP address to serve on.
Address string `json:"address"`
// algorithmProvider is the scheduling algorithm provider to use.
AlgorithmProvider string `json:"algorithmProvider"`
// policyConfigFile is the filepath to the scheduler policy configuration.
PolicyConfigFile string `json:"policyConfigFile"`
// enableProfiling enables profiling via web interface.
EnableProfiling bool `json:"enableProfiling"`
// kubeAPIQPS is the QPS to use while talking with kubernetes apiserver.
KubeAPIQPS float32 `json:"kubeAPIQPS"`
// kubeAPIBurst is the QPS burst to use while talking with kubernetes apiserver.
KubeAPIBurst int `json:"kubeAPIBurst"`
// schedulerName is name of the scheduler, used to select which pods
// will be processed by this scheduler, based on pod's annotation with
// key 'scheduler.alpha.kubernetes.io/name'.
SchedulerName string `json:"schedulerName"`
// leaderElection defines the configuration of leader election client.
LeaderElection LeaderElectionConfiguration `json:"leaderElection"`
}
// LeaderElectionConfiguration defines the configuration of leader election
// clients for components that can run with leader election enabled.
type LeaderElectionConfiguration struct {

View File

@ -18,8 +18,6 @@ limitations under the License.
package options
import (
"net"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/componentconfig"
"k8s.io/kubernetes/pkg/client/leaderelection"
@ -31,31 +29,27 @@ import (
// SchedulerServer has all the context and params needed to run a Scheduler
type SchedulerServer struct {
Port int
Address net.IP
AlgorithmProvider string
PolicyConfigFile string
EnableProfiling bool
Master string
Kubeconfig string
BindPodsQPS float32
BindPodsBurst int
KubeAPIQPS float32
KubeAPIBurst int
SchedulerName string
LeaderElection componentconfig.LeaderElectionConfiguration
componentconfig.KubeSchedulerConfiguration
// Master is the address of the Kubernetes API server (overrides any
// value in kubeconfig).
Master string
// Kubeconfig is Path to kubeconfig file with authorization and master
// location information.
Kubeconfig string
}
// NewSchedulerServer creates a new SchedulerServer with default parameters
func NewSchedulerServer() *SchedulerServer {
s := SchedulerServer{
Port: ports.SchedulerPort,
Address: net.ParseIP("0.0.0.0"),
AlgorithmProvider: factory.DefaultProvider,
KubeAPIQPS: 50.0,
KubeAPIBurst: 100,
SchedulerName: api.DefaultSchedulerName,
LeaderElection: leaderelection.DefaultLeaderElectionConfiguration(),
KubeSchedulerConfiguration: componentconfig.KubeSchedulerConfiguration{
Port: ports.SchedulerPort,
Address: "0.0.0.0",
AlgorithmProvider: factory.DefaultProvider,
KubeAPIQPS: 50.0,
KubeAPIBurst: 100,
SchedulerName: api.DefaultSchedulerName,
LeaderElection: leaderelection.DefaultLeaderElectionConfiguration(),
},
}
return &s
}
@ -63,15 +57,17 @@ func NewSchedulerServer() *SchedulerServer {
// AddFlags adds flags for a specific SchedulerServer to the specified FlagSet
func (s *SchedulerServer) AddFlags(fs *pflag.FlagSet) {
fs.IntVar(&s.Port, "port", s.Port, "The port that the scheduler's http service runs on")
fs.IPVar(&s.Address, "address", s.Address, "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
fs.StringVar(&s.Address, "address", s.Address, "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
fs.StringVar(&s.AlgorithmProvider, "algorithm-provider", s.AlgorithmProvider, "The scheduling algorithm provider to use, one of: "+factory.ListAlgorithmProviders())
fs.StringVar(&s.PolicyConfigFile, "policy-config-file", s.PolicyConfigFile, "File with scheduler policy configuration")
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
fs.Float32Var(&s.BindPodsQPS, "bind-pods-qps", s.BindPodsQPS, "Number of bindings per second scheduler is allowed to continuously make")
var unusedBindPodsQPS float32
fs.Float32Var(&unusedBindPodsQPS, "bind-pods-qps", 0, "unused, use --kube-api-qps")
fs.MarkDeprecated("bind-pods-qps", "flag is unused and will be removed. Use kube-api-qps instead.")
fs.IntVar(&s.BindPodsBurst, "bind-pods-burst", s.BindPodsBurst, "Number of bindings per second scheduler is allowed to make during bursts")
var unusedBindPodsBurst int
fs.IntVar(&unusedBindPodsBurst, "bind-pods-burst", 0, "unused, use --kube-api-burst")
fs.MarkDeprecated("bind-pods-burst", "flag is unused and will be removed. Use kube-api-burst instead.")
fs.Float32Var(&s.KubeAPIQPS, "kube-api-qps", s.KubeAPIQPS, "QPS to use while talking with kubernetes apiserver")
fs.IntVar(&s.KubeAPIBurst, "kube-api-burst", s.KubeAPIBurst, "Burst to use while talking with kubernetes apiserver")

View File

@ -93,7 +93,7 @@ func Run(s *options.SchedulerServer) error {
mux.Handle("/metrics", prometheus.Handler())
server := &http.Server{
Addr: net.JoinHostPort(s.Address.String(), strconv.Itoa(s.Port)),
Addr: net.JoinHostPort(s.Address, strconv.Itoa(s.Port)),
Handler: mux,
}
glog.Fatal(server.ListenAndServe())