kube-scheduler: allow deprecated options to be set with configfile
This commit is contained in:
@@ -47,12 +47,12 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet, cfg *kubeschedulerconfig
|
||||
return
|
||||
}
|
||||
|
||||
fs.StringVar(&o.AlgorithmProvider, "algorithm-provider", o.AlgorithmProvider, "DEPRECATED: the scheduling algorithm provider to use, one of: "+algorithmprovider.ListAlgorithmProviders())
|
||||
fs.StringVar(&o.PolicyConfigFile, "policy-config-file", o.PolicyConfigFile, "DEPRECATED: file with scheduler policy configuration. This file is used if policy ConfigMap is not provided or --use-legacy-policy-config=true")
|
||||
usage := fmt.Sprintf("DEPRECATED: name of the ConfigMap object that contains scheduler's policy configuration. It must exist in the system namespace before scheduler initialization if --use-legacy-policy-config=false. The config must be provided as the value of an element in 'Data' map with the key='%v'", kubeschedulerconfig.SchedulerPolicyConfigMapKey)
|
||||
fs.StringVar(&o.AlgorithmProvider, "algorithm-provider", o.AlgorithmProvider, "DEPRECATED: the scheduling algorithm provider to use, this sets the default plugins for component config profiles. Choose one of: "+algorithmprovider.ListAlgorithmProviders())
|
||||
fs.StringVar(&o.PolicyConfigFile, "policy-config-file", o.PolicyConfigFile, "DEPRECATED: file with scheduler policy configuration. This file is used if policy ConfigMap is not provided or --use-legacy-policy-config=true. Note: The scheduler will fail if this is combined with Plugin configs")
|
||||
usage := fmt.Sprintf("DEPRECATED: name of the ConfigMap object that contains scheduler's policy configuration. It must exist in the system namespace before scheduler initialization if --use-legacy-policy-config=false. The config must be provided as the value of an element in 'Data' map with the key='%v'. Note: The scheduler will fail if this is combined with Plugin configs", kubeschedulerconfig.SchedulerPolicyConfigMapKey)
|
||||
fs.StringVar(&o.PolicyConfigMapName, "policy-configmap", o.PolicyConfigMapName, usage)
|
||||
fs.StringVar(&o.PolicyConfigMapNamespace, "policy-configmap-namespace", o.PolicyConfigMapNamespace, "DEPRECATED: the namespace where policy ConfigMap is located. The kube-system namespace will be used if this is not provided or is empty.")
|
||||
fs.BoolVar(&o.UseLegacyPolicyConfig, "use-legacy-policy-config", o.UseLegacyPolicyConfig, "DEPRECATED: when set to true, scheduler will ignore policy ConfigMap and uses policy config file")
|
||||
fs.StringVar(&o.PolicyConfigMapNamespace, "policy-configmap-namespace", o.PolicyConfigMapNamespace, "DEPRECATED: the namespace where policy ConfigMap is located. The kube-system namespace will be used if this is not provided or is empty. Note: The scheduler will fail if this is combined with Plugin configs")
|
||||
fs.BoolVar(&o.UseLegacyPolicyConfig, "use-legacy-policy-config", o.UseLegacyPolicyConfig, "DEPRECATED: when set to true, scheduler will ignore policy ConfigMap and uses policy config file. Note: The scheduler will fail if this is combined with Plugin configs")
|
||||
|
||||
fs.BoolVar(&cfg.EnableProfiling, "profiling", cfg.EnableProfiling, "DEPRECATED: enable profiling via web interface host:port/debug/pprof/")
|
||||
fs.BoolVar(&cfg.EnableContentionProfiling, "contention-profiling", cfg.EnableContentionProfiling, "DEPRECATED: enable lock contention profiling, if profiling is enabled")
|
||||
@@ -87,16 +87,14 @@ func (o *DeprecatedOptions) Validate() []error {
|
||||
return errs
|
||||
}
|
||||
|
||||
// ApplyTo sets cfg.AlgorithmSource from flags passed on the command line in the following precedence order:
|
||||
// ApplyAlgorithmSourceTo sets cfg.AlgorithmSource from flags passed on the command line in the following precedence order:
|
||||
//
|
||||
// 1. --use-legacy-policy-config to use a policy file.
|
||||
// 2. --policy-configmap to use a policy config map value.
|
||||
// 3. --algorithm-provider to use a named algorithm provider.
|
||||
//
|
||||
// This function is only called when no config file is provided.
|
||||
func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfiguration) error {
|
||||
func (o *DeprecatedOptions) ApplyAlgorithmSourceTo(cfg *kubeschedulerconfig.KubeSchedulerConfiguration) {
|
||||
if o == nil {
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
switch {
|
||||
@@ -122,10 +120,19 @@ func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfig
|
||||
Provider: &o.AlgorithmProvider,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated flags have an effect iff no config file was provided, in which
|
||||
// case this function expects a default KubeSchedulerConfiguration instance,
|
||||
// which has a single profile.
|
||||
// ApplyTo sets a default profile plugin config if no config file is specified
|
||||
// It also calls ApplyAlgorithmSourceTo to set Policy settings in AlgorithmSource, if applicable.
|
||||
// Deprecated flags have an effect iff no config file was provided, in which
|
||||
// case this function expects a default KubeSchedulerConfiguration instance,
|
||||
// which has a single profile.
|
||||
func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfiguration) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
// The following deprecated options affect the only existing profile that is
|
||||
// added by default.
|
||||
profile := &cfg.Profiles[0]
|
||||
if len(o.SchedulerName) > 0 {
|
||||
profile.SchedulerName = o.SchedulerName
|
||||
@@ -136,6 +143,7 @@ func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfig
|
||||
HardPodAffinityWeight: o.HardPodAffinitySymmetricWeight,
|
||||
},
|
||||
}
|
||||
|
||||
profile.PluginConfig = append(profile.PluginConfig, plCfg)
|
||||
return nil
|
||||
o.ApplyAlgorithmSourceTo(cfg)
|
||||
}
|
||||
|
Reference in New Issue
Block a user