Multiple scheduler leader election support

This commit is contained in:
Haoran Wang 2017-03-27 11:05:26 +08:00
parent 2db4affb9d
commit fcc73d355d
6 changed files with 36 additions and 2 deletions

View File

@ -702,5 +702,7 @@ windows-line-endings
www-prefix
zone-id
zone-name
lock-object-name
lock-object-namespace
horizontal-pod-autoscaler-use-rest-clients

View File

@ -595,6 +595,10 @@ type KubeSchedulerConfiguration struct {
FailureDomains string
// leaderElection defines the configuration of leader election client.
LeaderElection LeaderElectionConfiguration
// LockObjectNamespace defines the namespace of the lock object
LockObjectNamespace string
// LockObjectName defines the lock object name
LockObjectName string
}
// LeaderElectionConfiguration defines the configuration of leader election
@ -904,3 +908,11 @@ func (m *ConfigurationMap) Set(value string) error {
func (*ConfigurationMap) Type() string {
return "mapStringString"
}
const (
// "kube-system" is the default scheduler lock object namespace
SchedulerDefaultLockObjectNamespace string = "kube-system"
// "kube-scheduler" is the default scheduler lock object name
SchedulerDefaultLockObjectName = "kube-scheduler"
)

View File

@ -158,6 +158,12 @@ func SetDefaults_KubeSchedulerConfiguration(obj *KubeSchedulerConfiguration) {
if obj.FailureDomains == "" {
obj.FailureDomains = api.DefaultFailureDomains
}
if obj.LockObjectNamespace == "" {
obj.LockObjectNamespace = SchedulerDefaultLockObjectNamespace
}
if obj.LockObjectName == "" {
obj.LockObjectName = SchedulerDefaultLockObjectName
}
}
func SetDefaults_LeaderElectionConfiguration(obj *LeaderElectionConfiguration) {

View File

@ -130,6 +130,10 @@ type KubeSchedulerConfiguration struct {
FailureDomains string `json:"failureDomains"`
// leaderElection defines the configuration of leader election client.
LeaderElection LeaderElectionConfiguration `json:"leaderElection"`
// LockObjectNamespace defines the namespace of the lock object
LockObjectNamespace string `json:"lockObjectNamespace"`
// LockObjectName defines the lock object name
LockObjectName string `json:"lockObjectName"`
}
// HairpinMode denotes how the kubelet should configure networking to handle
@ -600,3 +604,11 @@ type KubeletAnonymousAuthentication struct {
// Anonymous requests have a username of system:anonymous, and a group name of system:unauthenticated.
Enabled *bool `json:"enabled"`
}
const (
// "kube-system" is the default scheduler lock object namespace
SchedulerDefaultLockObjectNamespace string = "kube-system"
// "kube-scheduler" is the default scheduler lock object name
SchedulerDefaultLockObjectName = "kube-scheduler"
)

View File

@ -72,6 +72,8 @@ func (s *SchedulerServer) AddFlags(fs *pflag.FlagSet) {
fs.Float32Var(&s.KubeAPIQPS, "kube-api-qps", s.KubeAPIQPS, "QPS to use while talking with kubernetes apiserver")
fs.Int32Var(&s.KubeAPIBurst, "kube-api-burst", s.KubeAPIBurst, "Burst to use while talking with kubernetes apiserver")
fs.StringVar(&s.SchedulerName, "scheduler-name", s.SchedulerName, "Name of the scheduler, used to select which pods will be processed by this scheduler, based on pod's \"spec.SchedulerName\".")
fs.StringVar(&s.LockObjectNamespace, "lock-object-namespace", s.LockObjectNamespace, "Define the namespace of the lock object.")
fs.StringVar(&s.LockObjectName, "lock-object-name", s.LockObjectName, "Define the name of the lock object.")
fs.IntVar(&s.HardPodAffinitySymmetricWeight, "hard-pod-affinity-symmetric-weight", api.DefaultHardPodAffinitySymmetricWeight,
"RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule corresponding "+
"to every RequiredDuringScheduling affinity rule. --hard-pod-affinity-symmetric-weight represents the weight of implicit PreferredDuringScheduling affinity rule.")

View File

@ -113,8 +113,8 @@ func Run(s *options.SchedulerServer) error {
// TODO: enable other lock types
rl := &resourcelock.EndpointsLock{
EndpointsMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "kube-scheduler",
Namespace: s.LockObjectNamespace,
Name: s.LockObjectName,
},
Client: kubecli,
LockConfig: resourcelock.ResourceLockConfig{