mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 06:32:32 +00:00
Move scheduler plugin set and configuration defaulting to component config
This commit is contained in:
@@ -42,10 +42,10 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet, cfg *kubeschedulerconfig
|
||||
return
|
||||
}
|
||||
|
||||
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.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 predicates/priorities defined in this file will take precedence over any profiles define in ComponentConfig.")
|
||||
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 predicates/priorities defined in this file will take precedence over any profiles define in ComponentConfig.", 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. Note: The scheduler will fail if this is combined with Plugin configs")
|
||||
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 predicates/priorities defined in this file will take precedence over any profiles define in ComponentConfig.")
|
||||
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/. This parameter is ignored if a config file is specified in --config.")
|
||||
|
@@ -23,6 +23,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
apiserveroptions "k8s.io/apiserver/pkg/server/options"
|
||||
@@ -175,8 +176,8 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
||||
if len(o.ConfigFile) == 0 {
|
||||
c.ComponentConfig = o.ComponentConfig
|
||||
|
||||
// apply deprecated flags if no config file is loaded (this is the old behaviour).
|
||||
o.Deprecated.ApplyTo(c)
|
||||
|
||||
if err := o.CombinedInsecureServing.ApplyTo(c, &c.ComponentConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -194,18 +195,18 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
||||
// apply any deprecated Policy flags, if applicable
|
||||
o.Deprecated.ApplyTo(c)
|
||||
|
||||
// if the user has set CC profiles and is trying to use a Policy config, error out
|
||||
// these configs are no longer merged and they should not be used simultaneously
|
||||
if !emptySchedulerProfileConfig(c.ComponentConfig.Profiles) && c.LegacyPolicySource != nil {
|
||||
return fmt.Errorf("cannot set a Plugin config and Policy config")
|
||||
}
|
||||
|
||||
// use the loaded config file only, with the exception of --address and --port.
|
||||
if err := o.CombinedInsecureServing.ApplyToFromLoadedConfig(c, &c.ComponentConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// If the user is using the legacy policy config, clear the profiles, they will be set
|
||||
// on scheduler instantiation based on the configurations in the policy file.
|
||||
if c.LegacyPolicySource != nil {
|
||||
c.ComponentConfig.Profiles = nil
|
||||
}
|
||||
|
||||
if err := o.SecureServing.ApplyTo(&c.SecureServing, &c.LoopbackClientConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -222,15 +223,6 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// emptySchedulerProfileConfig returns true if the list of profiles passed to it contains only
|
||||
// the "default-scheduler" profile with no plugins or pluginconfigs registered
|
||||
// (this is the default empty profile initialized by defaults.go)
|
||||
func emptySchedulerProfileConfig(profiles []kubeschedulerconfig.KubeSchedulerProfile) bool {
|
||||
return len(profiles) == 1 &&
|
||||
len(profiles[0].PluginConfig) == 0 &&
|
||||
profiles[0].Plugins == nil
|
||||
}
|
||||
|
||||
// Validate validates all the required options.
|
||||
func (o *Options) Validate() []error {
|
||||
var errs []error
|
||||
@@ -280,7 +272,11 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
|
||||
var leaderElectionConfig *leaderelection.LeaderElectionConfig
|
||||
if c.ComponentConfig.LeaderElection.LeaderElect {
|
||||
// Use the scheduler name in the first profile to record leader election.
|
||||
coreRecorder := c.EventBroadcaster.DeprecatedNewLegacyRecorder(c.ComponentConfig.Profiles[0].SchedulerName)
|
||||
schedulerName := corev1.DefaultSchedulerName
|
||||
if len(c.ComponentConfig.Profiles) != 0 {
|
||||
schedulerName = c.ComponentConfig.Profiles[0].SchedulerName
|
||||
}
|
||||
coreRecorder := c.EventBroadcaster.DeprecatedNewLegacyRecorder(schedulerName)
|
||||
leaderElectionConfig, err = makeLeaderElectionConfig(c.ComponentConfig.LeaderElection, kubeConfig, coreRecorder)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@@ -34,26 +34,15 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
apiserveroptions "k8s.io/apiserver/pkg/server/options"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
"k8s.io/component-base/config/v1alpha1"
|
||||
"k8s.io/component-base/logs"
|
||||
"k8s.io/kube-scheduler/config/v1beta1"
|
||||
"k8s.io/kube-scheduler/config/v1beta2"
|
||||
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
|
||||
configtesting "k8s.io/kubernetes/pkg/scheduler/apis/config/testing"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/testing/defaults"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/names"
|
||||
)
|
||||
|
||||
func newV1beta1DefaultComponentConfig() (*kubeschedulerconfig.KubeSchedulerConfiguration, error) {
|
||||
versionedCfg := v1beta1.KubeSchedulerConfiguration{}
|
||||
versionedCfg.DebuggingConfiguration = *v1alpha1.NewRecommendedDebuggingConfiguration()
|
||||
|
||||
scheme.Scheme.Default(&versionedCfg)
|
||||
cfg := kubeschedulerconfig.KubeSchedulerConfiguration{}
|
||||
if err := scheme.Scheme.Convert(&versionedCfg, &cfg, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func TestSchedulerOptions(t *testing.T) {
|
||||
// temp dir
|
||||
tmpDir, err := ioutil.TempDir("", "scheduler-options")
|
||||
@@ -224,12 +213,12 @@ profiles:
|
||||
- name: foo
|
||||
- name: bar
|
||||
disabled:
|
||||
- name: baz
|
||||
- name: VolumeBinding
|
||||
preBind:
|
||||
enabled:
|
||||
- name: foo
|
||||
disabled:
|
||||
- name: baz
|
||||
- name: VolumeBinding
|
||||
pluginConfig:
|
||||
- name: InterPodAffinity
|
||||
args:
|
||||
@@ -255,12 +244,12 @@ profiles:
|
||||
- name: foo
|
||||
- name: bar
|
||||
disabled:
|
||||
- name: baz
|
||||
- name: VolumeBinding
|
||||
preBind:
|
||||
enabled:
|
||||
- name: foo
|
||||
disabled:
|
||||
- name: baz
|
||||
- name: VolumeBinding
|
||||
pluginConfig:
|
||||
- name: ServiceAffinity
|
||||
args:
|
||||
@@ -286,11 +275,14 @@ profiles:
|
||||
reserve:
|
||||
enabled:
|
||||
- name: foo
|
||||
- name: VolumeBinding
|
||||
disabled:
|
||||
- name: VolumeBinding
|
||||
- schedulerName: "bar-profile"
|
||||
plugins:
|
||||
preBind:
|
||||
disabled:
|
||||
- name: baz
|
||||
- name: VolumeBinding
|
||||
pluginConfig:
|
||||
- name: foo
|
||||
`, configKubeconfig)), os.FileMode(0600)); err != nil {
|
||||
@@ -310,11 +302,14 @@ profiles:
|
||||
reserve:
|
||||
enabled:
|
||||
- name: foo
|
||||
- name: VolumeBinding
|
||||
disabled:
|
||||
- name: VolumeBinding
|
||||
- schedulerName: "bar-profile"
|
||||
plugins:
|
||||
preBind:
|
||||
disabled:
|
||||
- name: baz
|
||||
- name: VolumeBinding
|
||||
pluginConfig:
|
||||
- name: foo
|
||||
`, configKubeconfig)), os.FileMode(0600)); err != nil {
|
||||
@@ -409,7 +404,11 @@ profiles:
|
||||
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
|
||||
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
|
||||
Profiles: []kubeschedulerconfig.KubeSchedulerProfile{
|
||||
{SchedulerName: "default-scheduler"},
|
||||
{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: defaults.PluginsV1beta2,
|
||||
PluginConfig: defaults.PluginConfigs,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -418,10 +417,7 @@ profiles:
|
||||
options: &Options{
|
||||
ConfigFile: v1beta1VersionConfig,
|
||||
ComponentConfig: func() kubeschedulerconfig.KubeSchedulerConfiguration {
|
||||
cfg, err := newV1beta1DefaultComponentConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg := configtesting.V1beta1ToInternalWithDefaults(t, v1beta1.KubeSchedulerConfiguration{})
|
||||
return *cfg
|
||||
}(),
|
||||
SecureServing: (&apiserveroptions.SecureServingOptions{
|
||||
@@ -481,7 +477,11 @@ profiles:
|
||||
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
|
||||
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
|
||||
Profiles: []kubeschedulerconfig.KubeSchedulerProfile{
|
||||
{SchedulerName: "default-scheduler"},
|
||||
{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: defaults.PluginsV1beta1,
|
||||
PluginConfig: defaults.PluginConfigs,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -581,7 +581,11 @@ profiles:
|
||||
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
|
||||
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
|
||||
Profiles: []kubeschedulerconfig.KubeSchedulerProfile{
|
||||
{SchedulerName: "default-scheduler"},
|
||||
{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: defaults.PluginsV1beta2,
|
||||
PluginConfig: defaults.PluginConfigs,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -649,7 +653,11 @@ profiles:
|
||||
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
|
||||
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
|
||||
Profiles: []kubeschedulerconfig.KubeSchedulerProfile{
|
||||
{SchedulerName: "default-scheduler"},
|
||||
{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: defaults.PluginsV1beta2,
|
||||
PluginConfig: defaults.PluginConfigs,
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedUsername: "none, http",
|
||||
@@ -694,23 +702,24 @@ profiles:
|
||||
{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: &kubeschedulerconfig.Plugins{
|
||||
QueueSort: defaults.PluginsV1beta2.QueueSort,
|
||||
PreFilter: defaults.PluginsV1beta2.PreFilter,
|
||||
Filter: defaults.PluginsV1beta2.Filter,
|
||||
PostFilter: defaults.PluginsV1beta2.PostFilter,
|
||||
PreScore: defaults.PluginsV1beta2.PreScore,
|
||||
Score: defaults.PluginsV1beta2.Score,
|
||||
Reserve: kubeschedulerconfig.PluginSet{
|
||||
Enabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "foo"},
|
||||
{Name: "bar"},
|
||||
},
|
||||
Disabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "baz"},
|
||||
},
|
||||
},
|
||||
PreBind: kubeschedulerconfig.PluginSet{
|
||||
Enabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "foo"},
|
||||
},
|
||||
Disabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "baz"},
|
||||
},
|
||||
},
|
||||
Bind: defaults.PluginsV1beta2.Bind,
|
||||
},
|
||||
PluginConfig: []kubeschedulerconfig.PluginConfig{
|
||||
{
|
||||
@@ -726,6 +735,39 @@ profiles:
|
||||
ContentType: "application/json",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "DefaultPreemption",
|
||||
Args: &kubeschedulerconfig.DefaultPreemptionArgs{
|
||||
MinCandidateNodesPercentage: 10,
|
||||
MinCandidateNodesAbsolute: 100,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "NodeAffinity",
|
||||
Args: &kubeschedulerconfig.NodeAffinityArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesFit",
|
||||
Args: &kubeschedulerconfig.NodeResourcesFitArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesLeastAllocated",
|
||||
Args: &kubeschedulerconfig.NodeResourcesLeastAllocatedArgs{
|
||||
Resources: []kubeschedulerconfig.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "PodTopologySpread",
|
||||
Args: &kubeschedulerconfig.PodTopologySpreadArgs{
|
||||
DefaultingType: kubeschedulerconfig.SystemDefaulting,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "VolumeBinding",
|
||||
Args: &kubeschedulerconfig.VolumeBindingArgs{
|
||||
BindTimeoutSeconds: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -771,23 +813,24 @@ profiles:
|
||||
{
|
||||
SchedulerName: "default-scheduler",
|
||||
Plugins: &kubeschedulerconfig.Plugins{
|
||||
QueueSort: defaults.PluginsV1beta1.QueueSort,
|
||||
PreFilter: defaults.PluginsV1beta1.PreFilter,
|
||||
Filter: defaults.PluginsV1beta1.Filter,
|
||||
PostFilter: defaults.PluginsV1beta1.PostFilter,
|
||||
PreScore: defaults.PluginsV1beta1.PreScore,
|
||||
Score: defaults.PluginsV1beta1.Score,
|
||||
Reserve: kubeschedulerconfig.PluginSet{
|
||||
Enabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "foo"},
|
||||
{Name: "bar"},
|
||||
},
|
||||
Disabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "baz"},
|
||||
},
|
||||
},
|
||||
PreBind: kubeschedulerconfig.PluginSet{
|
||||
Enabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "foo"},
|
||||
},
|
||||
Disabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "baz"},
|
||||
},
|
||||
},
|
||||
Bind: defaults.PluginsV1beta1.Bind,
|
||||
},
|
||||
PluginConfig: []kubeschedulerconfig.PluginConfig{
|
||||
{
|
||||
@@ -804,6 +847,45 @@ profiles:
|
||||
ContentType: "application/json",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "DefaultPreemption",
|
||||
Args: &kubeschedulerconfig.DefaultPreemptionArgs{
|
||||
MinCandidateNodesPercentage: 10,
|
||||
MinCandidateNodesAbsolute: 100,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "InterPodAffinity",
|
||||
Args: &kubeschedulerconfig.InterPodAffinityArgs{
|
||||
HardPodAffinityWeight: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "NodeAffinity",
|
||||
Args: &kubeschedulerconfig.NodeAffinityArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesFit",
|
||||
Args: &kubeschedulerconfig.NodeResourcesFitArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesLeastAllocated",
|
||||
Args: &kubeschedulerconfig.NodeResourcesLeastAllocatedArgs{
|
||||
Resources: []kubeschedulerconfig.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "PodTopologySpread",
|
||||
Args: &kubeschedulerconfig.PodTopologySpreadArgs{
|
||||
DefaultingType: kubeschedulerconfig.SystemDefaulting,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "VolumeBinding",
|
||||
Args: &kubeschedulerconfig.VolumeBindingArgs{
|
||||
BindTimeoutSeconds: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -849,26 +931,78 @@ profiles:
|
||||
{
|
||||
SchedulerName: "foo-profile",
|
||||
Plugins: &kubeschedulerconfig.Plugins{
|
||||
QueueSort: defaults.PluginsV1beta2.QueueSort,
|
||||
PreFilter: defaults.PluginsV1beta2.PreFilter,
|
||||
Filter: defaults.PluginsV1beta2.Filter,
|
||||
PostFilter: defaults.PluginsV1beta2.PostFilter,
|
||||
PreScore: defaults.PluginsV1beta2.PreScore,
|
||||
Score: defaults.PluginsV1beta2.Score,
|
||||
Bind: defaults.PluginsV1beta2.Bind,
|
||||
PreBind: defaults.PluginsV1beta2.PreBind,
|
||||
Reserve: kubeschedulerconfig.PluginSet{
|
||||
Enabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "foo"},
|
||||
{Name: names.VolumeBinding},
|
||||
},
|
||||
},
|
||||
},
|
||||
PluginConfig: defaults.PluginConfigs,
|
||||
},
|
||||
{
|
||||
SchedulerName: "bar-profile",
|
||||
Plugins: &kubeschedulerconfig.Plugins{
|
||||
PreBind: kubeschedulerconfig.PluginSet{
|
||||
Disabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "baz"},
|
||||
},
|
||||
},
|
||||
QueueSort: defaults.PluginsV1beta2.QueueSort,
|
||||
PreFilter: defaults.PluginsV1beta2.PreFilter,
|
||||
Filter: defaults.PluginsV1beta2.Filter,
|
||||
PostFilter: defaults.PluginsV1beta2.PostFilter,
|
||||
PreScore: defaults.PluginsV1beta2.PreScore,
|
||||
Score: defaults.PluginsV1beta2.Score,
|
||||
Bind: defaults.PluginsV1beta2.Bind,
|
||||
Reserve: defaults.PluginsV1beta2.Reserve,
|
||||
},
|
||||
PluginConfig: []kubeschedulerconfig.PluginConfig{
|
||||
{
|
||||
Name: "foo",
|
||||
},
|
||||
{
|
||||
Name: "DefaultPreemption",
|
||||
Args: &kubeschedulerconfig.DefaultPreemptionArgs{
|
||||
MinCandidateNodesPercentage: 10,
|
||||
MinCandidateNodesAbsolute: 100,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "InterPodAffinity",
|
||||
Args: &kubeschedulerconfig.InterPodAffinityArgs{
|
||||
HardPodAffinityWeight: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "NodeAffinity",
|
||||
Args: &kubeschedulerconfig.NodeAffinityArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesFit",
|
||||
Args: &kubeschedulerconfig.NodeResourcesFitArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesLeastAllocated",
|
||||
Args: &kubeschedulerconfig.NodeResourcesLeastAllocatedArgs{
|
||||
Resources: []kubeschedulerconfig.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "PodTopologySpread",
|
||||
Args: &kubeschedulerconfig.PodTopologySpreadArgs{
|
||||
DefaultingType: kubeschedulerconfig.SystemDefaulting,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "VolumeBinding",
|
||||
Args: &kubeschedulerconfig.VolumeBindingArgs{
|
||||
BindTimeoutSeconds: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -914,38 +1048,83 @@ profiles:
|
||||
{
|
||||
SchedulerName: "foo-profile",
|
||||
Plugins: &kubeschedulerconfig.Plugins{
|
||||
QueueSort: defaults.PluginsV1beta1.QueueSort,
|
||||
PreFilter: defaults.PluginsV1beta1.PreFilter,
|
||||
Filter: defaults.PluginsV1beta1.Filter,
|
||||
PostFilter: defaults.PluginsV1beta1.PostFilter,
|
||||
PreScore: defaults.PluginsV1beta1.PreScore,
|
||||
Score: defaults.PluginsV1beta1.Score,
|
||||
Bind: defaults.PluginsV1beta1.Bind,
|
||||
PreBind: defaults.PluginsV1beta1.PreBind,
|
||||
Reserve: kubeschedulerconfig.PluginSet{
|
||||
Enabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "foo"},
|
||||
{Name: names.VolumeBinding},
|
||||
},
|
||||
},
|
||||
},
|
||||
PluginConfig: defaults.PluginConfigs,
|
||||
},
|
||||
{
|
||||
SchedulerName: "bar-profile",
|
||||
Plugins: &kubeschedulerconfig.Plugins{
|
||||
PreBind: kubeschedulerconfig.PluginSet{
|
||||
Disabled: []kubeschedulerconfig.Plugin{
|
||||
{Name: "baz"},
|
||||
},
|
||||
},
|
||||
QueueSort: defaults.PluginsV1beta1.QueueSort,
|
||||
PreFilter: defaults.PluginsV1beta1.PreFilter,
|
||||
Filter: defaults.PluginsV1beta1.Filter,
|
||||
PostFilter: defaults.PluginsV1beta1.PostFilter,
|
||||
PreScore: defaults.PluginsV1beta1.PreScore,
|
||||
Score: defaults.PluginsV1beta1.Score,
|
||||
Bind: defaults.PluginsV1beta1.Bind,
|
||||
Reserve: defaults.PluginsV1beta1.Reserve,
|
||||
},
|
||||
PluginConfig: []kubeschedulerconfig.PluginConfig{
|
||||
{
|
||||
Name: "foo",
|
||||
},
|
||||
{
|
||||
Name: "DefaultPreemption",
|
||||
Args: &kubeschedulerconfig.DefaultPreemptionArgs{
|
||||
MinCandidateNodesPercentage: 10,
|
||||
MinCandidateNodesAbsolute: 100,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "InterPodAffinity",
|
||||
Args: &kubeschedulerconfig.InterPodAffinityArgs{
|
||||
HardPodAffinityWeight: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "NodeAffinity",
|
||||
Args: &kubeschedulerconfig.NodeAffinityArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesFit",
|
||||
Args: &kubeschedulerconfig.NodeResourcesFitArgs{},
|
||||
},
|
||||
{
|
||||
Name: "NodeResourcesLeastAllocated",
|
||||
Args: &kubeschedulerconfig.NodeResourcesLeastAllocatedArgs{
|
||||
Resources: []kubeschedulerconfig.ResourceSpec{{Name: "cpu", Weight: 1}, {Name: "memory", Weight: 1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "PodTopologySpread",
|
||||
Args: &kubeschedulerconfig.PodTopologySpreadArgs{
|
||||
DefaultingType: kubeschedulerconfig.SystemDefaulting,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "VolumeBinding",
|
||||
Args: &kubeschedulerconfig.VolumeBindingArgs{
|
||||
BindTimeoutSeconds: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no config",
|
||||
options: &Options{
|
||||
Logs: logs.NewOptions(),
|
||||
},
|
||||
expectedError: "no configuration has been provided",
|
||||
},
|
||||
{
|
||||
name: "Attempting to set Component Config Profiles and Policy config",
|
||||
options: &Options{
|
||||
@@ -953,8 +1132,46 @@ profiles:
|
||||
Deprecated: &DeprecatedOptions{
|
||||
PolicyConfigMapName: "bar",
|
||||
},
|
||||
Logs: logs.NewOptions(),
|
||||
},
|
||||
expectedError: "cannot set a Plugin config and Policy config",
|
||||
expectedUsername: "config",
|
||||
expectedConfig: kubeschedulerconfig.KubeSchedulerConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
EnableProfiling: true,
|
||||
EnableContentionProfiling: true,
|
||||
},
|
||||
LeaderElection: componentbaseconfig.LeaderElectionConfiguration{
|
||||
LeaderElect: true,
|
||||
LeaseDuration: metav1.Duration{Duration: 15 * time.Second},
|
||||
RenewDeadline: metav1.Duration{Duration: 10 * time.Second},
|
||||
RetryPeriod: metav1.Duration{Duration: 2 * time.Second},
|
||||
ResourceLock: "leases",
|
||||
ResourceNamespace: "kube-system",
|
||||
ResourceName: "kube-scheduler",
|
||||
},
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: configKubeconfig,
|
||||
QPS: 50,
|
||||
Burst: 100,
|
||||
ContentType: "application/vnd.kubernetes.protobuf",
|
||||
},
|
||||
PercentageOfNodesToScore: defaultPercentageOfNodesToScore,
|
||||
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
|
||||
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no config",
|
||||
options: &Options{
|
||||
Logs: logs.NewOptions(),
|
||||
},
|
||||
expectedError: "no configuration has been provided",
|
||||
},
|
||||
{
|
||||
name: "unknown field",
|
||||
|
@@ -30,7 +30,8 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/kubernetes/cmd/kube-scheduler/app/options"
|
||||
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/testing/defaults"
|
||||
)
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
@@ -151,143 +152,81 @@ profiles:
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defaultPlugins := map[string][]kubeschedulerconfig.Plugin{
|
||||
"QueueSortPlugin": {
|
||||
{Name: "PrioritySort"},
|
||||
},
|
||||
"PreFilterPlugin": {
|
||||
{Name: "NodeResourcesFit"},
|
||||
{Name: "NodePorts"},
|
||||
{Name: "PodTopologySpread"},
|
||||
{Name: "InterPodAffinity"},
|
||||
{Name: "VolumeBinding"},
|
||||
{Name: "NodeAffinity"},
|
||||
},
|
||||
"FilterPlugin": {
|
||||
{Name: "NodeUnschedulable"},
|
||||
{Name: "NodeName"},
|
||||
{Name: "TaintToleration"},
|
||||
{Name: "NodeAffinity"},
|
||||
{Name: "NodePorts"},
|
||||
{Name: "NodeResourcesFit"},
|
||||
{Name: "VolumeRestrictions"},
|
||||
{Name: "EBSLimits"},
|
||||
{Name: "GCEPDLimits"},
|
||||
{Name: "NodeVolumeLimits"},
|
||||
{Name: "AzureDiskLimits"},
|
||||
{Name: "VolumeBinding"},
|
||||
{Name: "VolumeZone"},
|
||||
{Name: "PodTopologySpread"},
|
||||
{Name: "InterPodAffinity"},
|
||||
},
|
||||
"PostFilterPlugin": {
|
||||
{Name: "DefaultPreemption"},
|
||||
},
|
||||
"PreScorePlugin": {
|
||||
{Name: "InterPodAffinity"},
|
||||
{Name: "PodTopologySpread"},
|
||||
{Name: "TaintToleration"},
|
||||
{Name: "NodeAffinity"},
|
||||
},
|
||||
"ScorePlugin": {
|
||||
{Name: "NodeResourcesBalancedAllocation", Weight: 1},
|
||||
{Name: "ImageLocality", Weight: 1},
|
||||
{Name: "InterPodAffinity", Weight: 1},
|
||||
{Name: "NodeResourcesLeastAllocated", Weight: 1},
|
||||
{Name: "NodeAffinity", Weight: 1},
|
||||
{Name: "NodePreferAvoidPods", Weight: 10000},
|
||||
{Name: "PodTopologySpread", Weight: 2},
|
||||
{Name: "TaintToleration", Weight: 1},
|
||||
},
|
||||
"BindPlugin": {{Name: "DefaultBinder"}},
|
||||
"ReservePlugin": {{Name: "VolumeBinding"}},
|
||||
"PreBindPlugin": {{Name: "VolumeBinding"}},
|
||||
}
|
||||
|
||||
testcases := []struct {
|
||||
name string
|
||||
flags []string
|
||||
wantPlugins map[string]map[string][]kubeschedulerconfig.Plugin
|
||||
wantPlugins map[string]*config.Plugins
|
||||
}{
|
||||
{
|
||||
name: "default config",
|
||||
flags: []string{
|
||||
"--kubeconfig", configKubeconfig,
|
||||
},
|
||||
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
|
||||
"default-scheduler": defaultPlugins,
|
||||
wantPlugins: map[string]*config.Plugins{
|
||||
"default-scheduler": defaults.PluginsV1beta2,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "plugin config with single profile",
|
||||
name: "component configuration",
|
||||
flags: []string{
|
||||
"--config", pluginConfigFile,
|
||||
"--kubeconfig", configKubeconfig,
|
||||
},
|
||||
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
|
||||
wantPlugins: map[string]*config.Plugins{
|
||||
"default-scheduler": {
|
||||
"BindPlugin": {{Name: "DefaultBinder"}},
|
||||
"FilterPlugin": {{Name: "NodeResourcesFit"}, {Name: "NodePorts"}},
|
||||
"PreFilterPlugin": {{Name: "NodeResourcesFit"}, {Name: "NodePorts"}},
|
||||
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
|
||||
"PreScorePlugin": {{Name: "InterPodAffinity"}, {Name: "TaintToleration"}},
|
||||
"QueueSortPlugin": {{Name: "PrioritySort"}},
|
||||
"ScorePlugin": {{Name: "InterPodAffinity", Weight: 1}, {Name: "TaintToleration", Weight: 1}},
|
||||
"ReservePlugin": {{Name: "VolumeBinding"}},
|
||||
"PreBindPlugin": {{Name: "VolumeBinding"}},
|
||||
Bind: config.PluginSet{Enabled: []config.Plugin{{Name: "DefaultBinder"}}},
|
||||
Filter: config.PluginSet{
|
||||
Enabled: []config.Plugin{
|
||||
{Name: "NodeResourcesFit"},
|
||||
{Name: "NodePorts"},
|
||||
},
|
||||
},
|
||||
PreFilter: config.PluginSet{
|
||||
Enabled: []config.Plugin{
|
||||
{Name: "NodeResourcesFit"},
|
||||
{Name: "NodePorts"},
|
||||
},
|
||||
},
|
||||
PostFilter: config.PluginSet{Enabled: []config.Plugin{{Name: "DefaultPreemption"}}},
|
||||
PreScore: config.PluginSet{
|
||||
Enabled: []config.Plugin{
|
||||
{Name: "InterPodAffinity"},
|
||||
{Name: "TaintToleration"},
|
||||
},
|
||||
},
|
||||
QueueSort: config.PluginSet{Enabled: []config.Plugin{{Name: "PrioritySort"}}},
|
||||
Score: config.PluginSet{
|
||||
Enabled: []config.Plugin{
|
||||
{Name: "InterPodAffinity", Weight: 1},
|
||||
{Name: "TaintToleration", Weight: 1},
|
||||
},
|
||||
},
|
||||
Reserve: config.PluginSet{Enabled: []config.Plugin{{Name: "VolumeBinding"}}},
|
||||
PreBind: config.PluginSet{Enabled: []config.Plugin{{Name: "VolumeBinding"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "plugin config with multiple profiles",
|
||||
flags: []string{
|
||||
"--config", multiProfilesConfig,
|
||||
"--kubeconfig", configKubeconfig,
|
||||
},
|
||||
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
|
||||
"profile-default-plugins": defaultPlugins,
|
||||
"profile-disable-all-filter-and-score-plugins": {
|
||||
"BindPlugin": {{Name: "DefaultBinder"}},
|
||||
"QueueSortPlugin": {{Name: "PrioritySort"}},
|
||||
"ReservePlugin": {{Name: "VolumeBinding"}},
|
||||
"PreBindPlugin": {{Name: "VolumeBinding"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "default algorithm provider",
|
||||
flags: []string{
|
||||
"--kubeconfig", configKubeconfig,
|
||||
},
|
||||
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
|
||||
"default-scheduler": defaultPlugins,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "policy config file",
|
||||
flags: []string{
|
||||
"--kubeconfig", configKubeconfig,
|
||||
"--policy-config-file", policyConfigFile,
|
||||
},
|
||||
wantPlugins: map[string]map[string][]kubeschedulerconfig.Plugin{
|
||||
wantPlugins: map[string]*config.Plugins{
|
||||
"default-scheduler": {
|
||||
"QueueSortPlugin": {{Name: "PrioritySort"}},
|
||||
"PreFilterPlugin": {
|
||||
{Name: "InterPodAffinity"},
|
||||
QueueSort: config.PluginSet{Enabled: []config.Plugin{{Name: "PrioritySort"}}},
|
||||
PreFilter: config.PluginSet{Enabled: []config.Plugin{{Name: "InterPodAffinity"}}},
|
||||
Filter: config.PluginSet{
|
||||
Enabled: []config.Plugin{
|
||||
{Name: "NodeUnschedulable"},
|
||||
{Name: "TaintToleration"},
|
||||
{Name: "InterPodAffinity"},
|
||||
},
|
||||
},
|
||||
"FilterPlugin": {
|
||||
{Name: "NodeUnschedulable"},
|
||||
{Name: "TaintToleration"},
|
||||
{Name: "InterPodAffinity"},
|
||||
},
|
||||
"PostFilterPlugin": {{Name: "DefaultPreemption"}},
|
||||
"PreScorePlugin": {
|
||||
{Name: "InterPodAffinity"},
|
||||
},
|
||||
"ScorePlugin": {
|
||||
{Name: "InterPodAffinity", Weight: 2},
|
||||
},
|
||||
"BindPlugin": {{Name: "DefaultBinder"}},
|
||||
PostFilter: config.PluginSet{Enabled: []config.Plugin{{Name: "DefaultPreemption"}}},
|
||||
PreScore: config.PluginSet{Enabled: []config.Plugin{{Name: "InterPodAffinity"}}},
|
||||
Score: config.PluginSet{Enabled: []config.Plugin{{Name: "InterPodAffinity", Weight: 2}}},
|
||||
Bind: config.PluginSet{Enabled: []config.Plugin{{Name: "DefaultBinder"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -332,7 +271,7 @@ profiles:
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
gotPlugins := make(map[string]map[string][]kubeschedulerconfig.Plugin)
|
||||
gotPlugins := make(map[string]*config.Plugins)
|
||||
for n, p := range sched.Profiles {
|
||||
gotPlugins[n] = p.ListPlugins()
|
||||
}
|
||||
|
Reference in New Issue
Block a user