Skip to content

Commit f6525db

Browse files
authored
Merge pull request kubernetes#88087 from alculquicondor/mutiprofiles-api
Add Schedulings Profiles to kubescheduler.config.k8s.io/v1alpha2
2 parents 4cadaf2 + 9e71741 commit f6525db

File tree

18 files changed

+712
-225
lines changed

18 files changed

+712
-225
lines changed

cmd/kube-scheduler/app/options/deprecated.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type DeprecatedOptions struct {
3838
UseLegacyPolicyConfig bool
3939
AlgorithmProvider string
4040
HardPodAffinitySymmetricWeight int32
41+
SchedulerName string
4142
}
4243

4344
// AddFlags adds flags for the deprecated options.
@@ -59,14 +60,14 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet, cfg *kubeschedulerconfig
5960
fs.StringVar(&cfg.ClientConnection.ContentType, "kube-api-content-type", cfg.ClientConnection.ContentType, "DEPRECATED: content type of requests sent to apiserver.")
6061
fs.Float32Var(&cfg.ClientConnection.QPS, "kube-api-qps", cfg.ClientConnection.QPS, "DEPRECATED: QPS to use while talking with kubernetes apiserver")
6162
fs.Int32Var(&cfg.ClientConnection.Burst, "kube-api-burst", cfg.ClientConnection.Burst, "DEPRECATED: burst to use while talking with kubernetes apiserver")
62-
fs.StringVar(&cfg.SchedulerName, "scheduler-name", cfg.SchedulerName, "DEPRECATED: name of the scheduler, used to select which pods will be processed by this scheduler, based on pod's \"spec.schedulerName\".")
6363
fs.StringVar(&cfg.LeaderElection.ResourceNamespace, "lock-object-namespace", cfg.LeaderElection.ResourceNamespace, "DEPRECATED: define the namespace of the lock object. Will be removed in favor of leader-elect-resource-namespace.")
6464
fs.StringVar(&cfg.LeaderElection.ResourceName, "lock-object-name", cfg.LeaderElection.ResourceName, "DEPRECATED: define the name of the lock object. Will be removed in favor of leader-elect-resource-name")
6565

66-
fs.Int32Var(&o.HardPodAffinitySymmetricWeight, "hard-pod-affinity-symmetric-weight", interpodaffinity.DefaultHardPodAffinityWeight,
66+
fs.Int32Var(&o.HardPodAffinitySymmetricWeight, "hard-pod-affinity-symmetric-weight", o.HardPodAffinitySymmetricWeight,
6767
"DEPRECATED: RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule corresponding "+
6868
"to every RequiredDuringScheduling affinity rule. --hard-pod-affinity-symmetric-weight represents the weight of implicit PreferredDuringScheduling affinity rule. Must be in the range 0-100."+
6969
"This option was moved to the policy configuration file")
70+
fs.StringVar(&o.SchedulerName, "scheduler-name", o.SchedulerName, "DEPRECATED: name of the scheduler, used to select which pods will be processed by this scheduler, based on pod's \"spec.schedulerName\".")
7071
// MarkDeprecated hides the flag from the help. We don't want that:
7172
// fs.MarkDeprecated("hard-pod-affinity-symmetric-weight", "This option was moved to the policy configuration file")
7273
}
@@ -120,11 +121,17 @@ func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfig
120121
}
121122
}
122123

124+
// The following deprecated options affect the only existing profile that is
125+
// added by default.
126+
profile := &cfg.Profiles[0]
127+
if len(o.SchedulerName) > 0 {
128+
profile.SchedulerName = o.SchedulerName
129+
}
123130
if o.HardPodAffinitySymmetricWeight != interpodaffinity.DefaultHardPodAffinityWeight {
124131
args := interpodaffinity.Args{
125132
HardPodAffinityWeight: &o.HardPodAffinitySymmetricWeight,
126133
}
127-
cfg.PluginConfig = append(cfg.PluginConfig, plugins.NewPluginConfig(interpodaffinity.Name, args))
134+
profile.PluginConfig = append(profile.PluginConfig, plugins.NewPluginConfig(interpodaffinity.Name, args))
128135
}
129136

130137
return nil

cmd/kube-scheduler/app/options/options.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
4949
kubeschedulerscheme "k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
5050
"k8s.io/kubernetes/pkg/scheduler/apis/config/validation"
51+
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/interpodaffinity"
5152
)
5253

5354
// Options has all the params needed to run a Scheduler
@@ -98,8 +99,10 @@ func NewOptions() (*Options, error) {
9899
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
99100
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
100101
Deprecated: &DeprecatedOptions{
101-
UseLegacyPolicyConfig: false,
102-
PolicyConfigMapNamespace: metav1.NamespaceSystem,
102+
UseLegacyPolicyConfig: false,
103+
PolicyConfigMapNamespace: metav1.NamespaceSystem,
104+
SchedulerName: corev1.DefaultSchedulerName,
105+
HardPodAffinitySymmetricWeight: interpodaffinity.DefaultHardPodAffinityWeight,
103106
},
104107
}
105108

@@ -239,11 +242,12 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
239242
}
240243

241244
coreBroadcaster := record.NewBroadcaster()
242-
coreRecorder := coreBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: c.ComponentConfig.SchedulerName})
243245

244246
// Set up leader election if enabled.
245247
var leaderElectionConfig *leaderelection.LeaderElectionConfig
246248
if c.ComponentConfig.LeaderElection.LeaderElect {
249+
// Use the scheduler name in the first profile to record leader election.
250+
coreRecorder := coreBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: c.ComponentConfig.Profiles[0].SchedulerName})
247251
leaderElectionConfig, err = makeLeaderElectionConfig(c.ComponentConfig.LeaderElection, leaderElectionClient, coreRecorder)
248252
if err != nil {
249253
return nil, err

0 commit comments

Comments
 (0)