mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-26 04:36:00 +00:00
create external api for scheduler config
move defaulting into external pacakge
This commit is contained in:
@@ -45,7 +45,9 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
|||||||
// TODO this will get cleaned up with the scheme types are fixed
|
// TODO this will get cleaned up with the scheme types are fixed
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&KubeProxyConfiguration{},
|
&KubeProxyConfiguration{},
|
||||||
|
&KubeSchedulerConfiguration{},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *KubeProxyConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
func (obj *KubeProxyConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||||
|
func (obj *KubeSchedulerConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||||
|
@@ -291,6 +291,8 @@ type KubeletConfiguration struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KubeSchedulerConfiguration struct {
|
type KubeSchedulerConfiguration struct {
|
||||||
|
unversioned.TypeMeta
|
||||||
|
|
||||||
// port is the port that the scheduler's http service runs on.
|
// port is the port that the scheduler's http service runs on.
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
// address is the IP address to serve on.
|
// address is the IP address to serve on.
|
||||||
|
@@ -19,8 +19,10 @@ package v1alpha1
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/qos"
|
"k8s.io/kubernetes/pkg/kubelet/qos"
|
||||||
|
"k8s.io/kubernetes/pkg/master/ports"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,5 +46,37 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
|
|||||||
obj.IPTablesSyncPeriod = unversioned.Duration{5 * time.Second}
|
obj.IPTablesSyncPeriod = unversioned.Duration{5 * time.Second}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
func(obj *KubeSchedulerConfiguration) {
|
||||||
|
if obj.Port == 0 {
|
||||||
|
obj.Port = ports.SchedulerPort
|
||||||
|
}
|
||||||
|
if obj.Address == "" {
|
||||||
|
obj.Address = "0.0.0.0"
|
||||||
|
}
|
||||||
|
if obj.AlgorithmProvider == "" {
|
||||||
|
obj.AlgorithmProvider = "DefaultProvider"
|
||||||
|
}
|
||||||
|
if obj.KubeAPIQPS == 0 {
|
||||||
|
obj.KubeAPIQPS = 50.0
|
||||||
|
}
|
||||||
|
if obj.KubeAPIBurst == 0 {
|
||||||
|
obj.KubeAPIBurst = 100
|
||||||
|
}
|
||||||
|
if obj.SchedulerName == "" {
|
||||||
|
obj.SchedulerName = api.DefaultSchedulerName
|
||||||
|
}
|
||||||
|
},
|
||||||
|
func(obj *LeaderElectionConfiguration) {
|
||||||
|
zero := unversioned.Duration{}
|
||||||
|
if obj.LeaseDuration == zero {
|
||||||
|
obj.LeaseDuration = unversioned.Duration{15 * time.Second}
|
||||||
|
}
|
||||||
|
if obj.RenewDeadline == zero {
|
||||||
|
obj.RenewDeadline = unversioned.Duration{10 * time.Second}
|
||||||
|
}
|
||||||
|
if obj.RetryPeriod == zero {
|
||||||
|
obj.RetryPeriod = unversioned.Duration{2 * time.Second}
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,9 @@ func AddToScheme(scheme *runtime.Scheme) {
|
|||||||
func addKnownTypes(scheme *runtime.Scheme) {
|
func addKnownTypes(scheme *runtime.Scheme) {
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&KubeProxyConfiguration{},
|
&KubeProxyConfiguration{},
|
||||||
|
&KubeSchedulerConfiguration{},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *KubeProxyConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
func (obj *KubeProxyConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||||
|
func (obj *KubeSchedulerConfiguration) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||||
|
@@ -74,3 +74,53 @@ const (
|
|||||||
ProxyModeUserspace ProxyMode = "userspace"
|
ProxyModeUserspace ProxyMode = "userspace"
|
||||||
ProxyModeIPTables ProxyMode = "iptables"
|
ProxyModeIPTables ProxyMode = "iptables"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type KubeSchedulerConfiguration struct {
|
||||||
|
unversioned.TypeMeta
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
// leaderElect enables a leader election client to gain leadership
|
||||||
|
// before executing the main loop. Enable this when running replicated
|
||||||
|
// components for high availability.
|
||||||
|
LeaderElect *bool `json:"leaderElect"`
|
||||||
|
// leaseDuration is the duration that non-leader candidates will wait
|
||||||
|
// after observing a leadership renewal until attempting to acquire
|
||||||
|
// leadership of a led but unrenewed leader slot. This is effectively the
|
||||||
|
// maximum duration that a leader can be stopped before it is replaced
|
||||||
|
// by another candidate. This is only applicable if leader election is
|
||||||
|
// enabled.
|
||||||
|
LeaseDuration unversioned.Duration `json:"leaseDuration"`
|
||||||
|
// renewDeadline is the interval between attempts by the acting master to
|
||||||
|
// renew a leadership slot before it stops leading. This must be less
|
||||||
|
// than or equal to the lease duration. This is only applicable if leader
|
||||||
|
// election is enabled.
|
||||||
|
RenewDeadline unversioned.Duration `json:"renewDeadline"`
|
||||||
|
// retryPeriod is the duration the clients should wait between attempting
|
||||||
|
// acquisition and renewal of a leadership. This is only applicable if
|
||||||
|
// leader election is enabled.
|
||||||
|
RetryPeriod unversioned.Duration `json:"retryPeriod"`
|
||||||
|
}
|
||||||
|
@@ -20,8 +20,8 @@ package options
|
|||||||
import (
|
import (
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
|
||||||
"k8s.io/kubernetes/pkg/client/leaderelection"
|
"k8s.io/kubernetes/pkg/client/leaderelection"
|
||||||
"k8s.io/kubernetes/pkg/master/ports"
|
|
||||||
"k8s.io/kubernetes/plugin/pkg/scheduler/factory"
|
"k8s.io/kubernetes/plugin/pkg/scheduler/factory"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@@ -40,16 +40,10 @@ type SchedulerServer struct {
|
|||||||
|
|
||||||
// NewSchedulerServer creates a new SchedulerServer with default parameters
|
// NewSchedulerServer creates a new SchedulerServer with default parameters
|
||||||
func NewSchedulerServer() *SchedulerServer {
|
func NewSchedulerServer() *SchedulerServer {
|
||||||
|
config := componentconfig.KubeSchedulerConfiguration{}
|
||||||
|
api.Scheme.Convert(&v1alpha1.KubeSchedulerConfiguration{}, &config)
|
||||||
s := SchedulerServer{
|
s := SchedulerServer{
|
||||||
KubeSchedulerConfiguration: componentconfig.KubeSchedulerConfiguration{
|
KubeSchedulerConfiguration: config,
|
||||||
Port: ports.SchedulerPort,
|
|
||||||
Address: "0.0.0.0",
|
|
||||||
AlgorithmProvider: factory.DefaultProvider,
|
|
||||||
KubeAPIQPS: 50.0,
|
|
||||||
KubeAPIBurst: 100,
|
|
||||||
SchedulerName: api.DefaultSchedulerName,
|
|
||||||
LeaderElection: leaderelection.DefaultLeaderElectionConfiguration(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user