Skip to content

Commit e322da5

Browse files
authored
Merge pull request kubernetes#88585 from pancernik/plugin-args-api-config
Add types for Scheduler plugin args to kube-scheduler.config.k8s.io
2 parents 08e1fd3 + c4d20ca commit e322da5

File tree

29 files changed

+971
-110
lines changed

29 files changed

+971
-110
lines changed

api/api-rules/violation_exceptions.list

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@ API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,V
597597
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,VolumeConfiguration,PersistentVolumeRecyclerConfiguration
598598
API rule violation: names_match,k8s.io/kube-proxy/config/v1alpha1,KubeProxyConfiguration,IPTables
599599
API rule violation: names_match,k8s.io/kube-scheduler/config/v1,Extender,EnableHTTPS
600+
API rule violation: names_match,k8s.io/kube-scheduler/config/v1alpha2,ResourceSpec,Name
601+
API rule violation: names_match,k8s.io/kube-scheduler/config/v1alpha2,ResourceSpec,Weight
602+
API rule violation: names_match,k8s.io/kube-scheduler/config/v1alpha2,UtilizationShapePoint,Score
603+
API rule violation: names_match,k8s.io/kube-scheduler/config/v1alpha2,UtilizationShapePoint,Utilization
600604
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,IPTablesDropBit
601605
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,IPTablesMasqueradeBit
602606
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,ResolverConfig

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/spf13/pflag"
2323
"k8s.io/apimachinery/pkg/util/validation/field"
24+
kubeschedulerv1alpha2 "k8s.io/kube-scheduler/config/v1alpha2"
2425
"k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
2526
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
2627
"k8s.io/kubernetes/pkg/scheduler/framework/plugins"
@@ -128,11 +129,10 @@ func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfig
128129
profile.SchedulerName = o.SchedulerName
129130
}
130131
if o.HardPodAffinitySymmetricWeight != interpodaffinity.DefaultHardPodAffinityWeight {
131-
args := interpodaffinity.Args{
132+
args := kubeschedulerv1alpha2.InterPodAffinityArgs{
132133
HardPodAffinityWeight: &o.HardPodAffinitySymmetricWeight,
133134
}
134135
profile.PluginConfig = append(profile.PluginConfig, plugins.NewPluginConfig(interpodaffinity.Name, args))
135136
}
136-
137137
return nil
138138
}

pkg/scheduler/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ go_library(
2020
"//pkg/scheduler/core:go_default_library",
2121
"//pkg/scheduler/framework/plugins:go_default_library",
2222
"//pkg/scheduler/framework/plugins/defaultbinder:go_default_library",
23-
"//pkg/scheduler/framework/plugins/interpodaffinity:go_default_library",
2423
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
2524
"//pkg/scheduler/framework/plugins/queuesort:go_default_library",
2625
"//pkg/scheduler/framework/v1alpha1:go_default_library",
@@ -46,6 +45,7 @@ go_library(
4645
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
4746
"//staging/src/k8s.io/client-go/listers/policy/v1beta1:go_default_library",
4847
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
48+
"//staging/src/k8s.io/kube-scheduler/config/v1alpha2:go_default_library",
4949
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
5050
"//vendor/k8s.io/klog:go_default_library",
5151
],

pkg/scheduler/apis/config/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ go_library(
77
"legacy_types.go",
88
"register.go",
99
"types.go",
10+
"types_pluginargs.go",
1011
"zz_generated.deepcopy.go",
1112
],
1213
importpath = "k8s.io/kubernetes/pkg/scheduler/apis/config",

pkg/scheduler/apis/config/legacy_types.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,6 @@ type RequestedToCapacityRatioArguments struct {
136136
Resources []ResourceSpec `json:"resources,omitempty"`
137137
}
138138

139-
// UtilizationShapePoint represents single point of priority function shape
140-
type UtilizationShapePoint struct {
141-
// Utilization (x axis). Valid values are 0 to 100. Fully utilized node maps to 100.
142-
Utilization int32
143-
// Score assigned to given utilization (y axis). Valid values are 0 to 10.
144-
Score int32
145-
}
146-
147-
// ResourceSpec represents single resource for bin packing of priority RequestedToCapacityRatioArguments.
148-
type ResourceSpec struct {
149-
// Name of the resource to be managed by RequestedToCapacityRatio function.
150-
Name string
151-
// Weight of the resource.
152-
Weight int64
153-
}
154-
155139
// ExtenderManagedResource describes the arguments of extended resources
156140
// managed by an extender.
157141
type ExtenderManagedResource struct {

pkg/scheduler/apis/config/register.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3939
scheme.AddKnownTypes(SchemeGroupVersion,
4040
&KubeSchedulerConfiguration{},
4141
&Policy{},
42+
&InterPodAffinityArgs{},
43+
&NodeLabelArgs{},
44+
&NodeResourcesFitArgs{},
45+
&RequestedToCapacityRatioArgs{},
46+
&ServiceAffinityArgs{},
4247
)
4348
scheme.AddKnownTypes(schema.GroupVersion{Group: "", Version: runtime.APIVersionInternal}, &Policy{})
4449
return nil
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package config
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
24+
25+
// InterPodAffinityArgs holds arguments used to configure the InterPodAffinity plugin.
26+
type InterPodAffinityArgs struct {
27+
metav1.TypeMeta
28+
29+
// HardPodAffinityWeight is the scoring weight for existing pods with a
30+
// matching hard affinity to the incoming pod.
31+
HardPodAffinityWeight int32
32+
}
33+
34+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
35+
36+
// NodeLabelArgs holds arguments that used to configure the NodeLabel plugin.
37+
type NodeLabelArgs struct {
38+
metav1.TypeMeta
39+
40+
// PresentLabels should be present for the node to be considered a fit for hosting the pod
41+
PresentLabels []string
42+
// AbsentLabels should be absent for the node to be considered a fit for hosting the pod
43+
AbsentLabels []string
44+
// Nodes that have labels in the list will get a higher score.
45+
PresentLabelsPreference []string
46+
// Nodes that don't have labels in the list will get a higher score.
47+
AbsentLabelsPreference []string
48+
}
49+
50+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
51+
52+
// NodeResourcesFitArgs holds arguments used to configure the NodeResourcesFit plugin.
53+
type NodeResourcesFitArgs struct {
54+
metav1.TypeMeta
55+
56+
// IgnoredResources is the list of resources that NodeResources fit filter
57+
// should ignore.
58+
IgnoredResources []string
59+
}
60+
61+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
62+
63+
// RequestedToCapacityRatioArgs holds arguments used to configure RequestedToCapacityRatio plugin.
64+
type RequestedToCapacityRatioArgs struct {
65+
metav1.TypeMeta
66+
67+
// Points defining priority function shape
68+
Shape []UtilizationShapePoint
69+
// Resources to be managed
70+
Resources []ResourceSpec
71+
}
72+
73+
// UtilizationShapePoint represents a single point of a priority function shape.
74+
type UtilizationShapePoint struct {
75+
// Utilization (x axis). Valid values are 0 to 100. Fully utilized node maps to 100.
76+
Utilization int32
77+
// Score assigned to a given utilization (y axis). Valid values are 0 to 10.
78+
Score int32
79+
}
80+
81+
// ResourceSpec represents single resource for bin packing of priority RequestedToCapacityRatioArgs.
82+
type ResourceSpec struct {
83+
// Name of the resource to be managed by RequestedToCapacityRatio function.
84+
Name string
85+
// Weight of the resource.
86+
Weight int64
87+
}
88+
89+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
90+
91+
// ServiceAffinityArgs holds arguments used to configure the ServiceAffinity plugin.
92+
type ServiceAffinityArgs struct {
93+
metav1.TypeMeta
94+
95+
// AffinityLabels are homogeneous for pods that are scheduled to a node.
96+
// (i.e. it returns true IFF this pod can be added to this node such that all other pods in
97+
// the same service are running on nodes with the exact same values for Labels).
98+
AffinityLabels []string
99+
// AntiAffinityLabelsPreference are the labels to consider for service anti affinity scoring.
100+
AntiAffinityLabelsPreference []string
101+
}

0 commit comments

Comments
 (0)