mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #42961 from wanghaoran1988/fix_39032
Automatic merge from submit-queue leader election lock based on scheduler name **What this PR does / why we need it**: This pr changed the leader election lock based on scheduler name. **Which issue this PR fixes** : fixes #39032 **Special notes for your reviewer**: **Release note**: ``` [scheduling]Fix a bug for multiple-schedulers that you cannot start a second scheduler without disabling leader-elect if the default scheduler has leader-elect enabled(default). We changed the leader election lock based on scheduler name. ```
This commit is contained in:
commit
54f38688d7
@ -702,5 +702,7 @@ windows-line-endings
|
|||||||
www-prefix
|
www-prefix
|
||||||
zone-id
|
zone-id
|
||||||
zone-name
|
zone-name
|
||||||
|
lock-object-name
|
||||||
|
lock-object-namespace
|
||||||
|
|
||||||
horizontal-pod-autoscaler-use-rest-clients
|
horizontal-pod-autoscaler-use-rest-clients
|
||||||
|
@ -595,6 +595,10 @@ type KubeSchedulerConfiguration struct {
|
|||||||
FailureDomains string
|
FailureDomains string
|
||||||
// leaderElection defines the configuration of leader election client.
|
// leaderElection defines the configuration of leader election client.
|
||||||
LeaderElection LeaderElectionConfiguration
|
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
|
// LeaderElectionConfiguration defines the configuration of leader election
|
||||||
@ -904,3 +908,11 @@ func (m *ConfigurationMap) Set(value string) error {
|
|||||||
func (*ConfigurationMap) Type() string {
|
func (*ConfigurationMap) Type() string {
|
||||||
return "mapStringString"
|
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"
|
||||||
|
)
|
||||||
|
@ -158,6 +158,12 @@ func SetDefaults_KubeSchedulerConfiguration(obj *KubeSchedulerConfiguration) {
|
|||||||
if obj.FailureDomains == "" {
|
if obj.FailureDomains == "" {
|
||||||
obj.FailureDomains = api.DefaultFailureDomains
|
obj.FailureDomains = api.DefaultFailureDomains
|
||||||
}
|
}
|
||||||
|
if obj.LockObjectNamespace == "" {
|
||||||
|
obj.LockObjectNamespace = SchedulerDefaultLockObjectNamespace
|
||||||
|
}
|
||||||
|
if obj.LockObjectName == "" {
|
||||||
|
obj.LockObjectName = SchedulerDefaultLockObjectName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDefaults_LeaderElectionConfiguration(obj *LeaderElectionConfiguration) {
|
func SetDefaults_LeaderElectionConfiguration(obj *LeaderElectionConfiguration) {
|
||||||
|
@ -130,6 +130,10 @@ type KubeSchedulerConfiguration struct {
|
|||||||
FailureDomains string `json:"failureDomains"`
|
FailureDomains string `json:"failureDomains"`
|
||||||
// leaderElection defines the configuration of leader election client.
|
// leaderElection defines the configuration of leader election client.
|
||||||
LeaderElection LeaderElectionConfiguration `json:"leaderElection"`
|
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
|
// 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.
|
// Anonymous requests have a username of system:anonymous, and a group name of system:unauthenticated.
|
||||||
Enabled *bool `json:"enabled"`
|
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"
|
||||||
|
)
|
||||||
|
@ -137,6 +137,8 @@ func autoConvert_v1alpha1_KubeSchedulerConfiguration_To_componentconfig_KubeSche
|
|||||||
if err := Convert_v1alpha1_LeaderElectionConfiguration_To_componentconfig_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil {
|
if err := Convert_v1alpha1_LeaderElectionConfiguration_To_componentconfig_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.LockObjectNamespace = in.LockObjectNamespace
|
||||||
|
out.LockObjectName = in.LockObjectName
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,6 +164,8 @@ func autoConvert_componentconfig_KubeSchedulerConfiguration_To_v1alpha1_KubeSche
|
|||||||
if err := Convert_componentconfig_LeaderElectionConfiguration_To_v1alpha1_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil {
|
if err := Convert_componentconfig_LeaderElectionConfiguration_To_v1alpha1_LeaderElectionConfiguration(&in.LeaderElection, &out.LeaderElection, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
out.LockObjectNamespace = in.LockObjectNamespace
|
||||||
|
out.LockObjectName = in.LockObjectName
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12878,8 +12878,22 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
|
|||||||
Ref: ref("k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1.LeaderElectionConfiguration"),
|
Ref: ref("k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1.LeaderElectionConfiguration"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"lockObjectNamespace": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "LockObjectNamespace defines the namespace of the lock object",
|
||||||
|
Type: []string{"string"},
|
||||||
|
Format: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"lockObjectName": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "LockObjectName defines the lock object name",
|
||||||
|
Type: []string{"string"},
|
||||||
|
Format: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Required: []string{"port", "address", "algorithmProvider", "policyConfigFile", "enableProfiling", "enableContentionProfiling", "contentType", "kubeAPIQPS", "kubeAPIBurst", "schedulerName", "hardPodAffinitySymmetricWeight", "failureDomains", "leaderElection"},
|
Required: []string{"port", "address", "algorithmProvider", "policyConfigFile", "enableProfiling", "enableContentionProfiling", "contentType", "kubeAPIQPS", "kubeAPIBurst", "schedulerName", "hardPodAffinitySymmetricWeight", "failureDomains", "leaderElection", "lockObjectNamespace", "lockObjectName"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Dependencies: []string{
|
Dependencies: []string{
|
||||||
|
@ -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.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.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.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,
|
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 "+
|
"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.")
|
"to every RequiredDuringScheduling affinity rule. --hard-pod-affinity-symmetric-weight represents the weight of implicit PreferredDuringScheduling affinity rule.")
|
||||||
|
@ -113,8 +113,8 @@ func Run(s *options.SchedulerServer) error {
|
|||||||
// TODO: enable other lock types
|
// TODO: enable other lock types
|
||||||
rl := &resourcelock.EndpointsLock{
|
rl := &resourcelock.EndpointsLock{
|
||||||
EndpointsMeta: metav1.ObjectMeta{
|
EndpointsMeta: metav1.ObjectMeta{
|
||||||
Namespace: "kube-system",
|
Namespace: s.LockObjectNamespace,
|
||||||
Name: "kube-scheduler",
|
Name: s.LockObjectName,
|
||||||
},
|
},
|
||||||
Client: kubecli,
|
Client: kubecli,
|
||||||
LockConfig: resourcelock.ResourceLockConfig{
|
LockConfig: resourcelock.ResourceLockConfig{
|
||||||
|
Loading…
Reference in New Issue
Block a user