Skip to content

Commit 8c53df9

Browse files
committed
fix some bugs, integration test passed.
TODO: add unit tests Signed-off-by: KunWuLuan <[email protected]>
1 parent ef224db commit 8c53df9

File tree

12 files changed

+431
-67
lines changed

12 files changed

+431
-67
lines changed

cmd/scheduler/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"sigs.k8s.io/scheduler-plugins/pkg/podstate"
3434
"sigs.k8s.io/scheduler-plugins/pkg/preemptiontoleration"
3535
"sigs.k8s.io/scheduler-plugins/pkg/qos"
36+
"sigs.k8s.io/scheduler-plugins/pkg/resourcepolicy"
3637
"sigs.k8s.io/scheduler-plugins/pkg/sysched"
3738
"sigs.k8s.io/scheduler-plugins/pkg/trimaran/loadvariationriskbalancing"
3839
"sigs.k8s.io/scheduler-plugins/pkg/trimaran/lowriskovercommitment"
@@ -60,6 +61,7 @@ func main() {
6061
app.WithPlugin(lowriskovercommitment.Name, lowriskovercommitment.New),
6162
app.WithPlugin(sysched.Name, sysched.New),
6263
app.WithPlugin(peaks.Name, peaks.New),
64+
app.WithPlugin(resourcepolicy.Name, resourcepolicy.New),
6365
// Sample plugins below.
6466
// app.WithPlugin(crossnodepreemption.Name, crossnodepreemption.New),
6567
app.WithPlugin(podstate.Name, podstate.New),

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ module sigs.k8s.io/scheduler-plugins
33
go 1.24.2
44

55
require (
6-
github.com/KunWuLuan/resourcepolicyapi v0.0.0-20250429133120-0b5462735cdc
6+
github.com/KunWuLuan/resourcepolicyapi v0.0.0-20250615030143-8529fd048210
77
github.com/containers/common v0.46.0
88
github.com/diktyo-io/appgroup-api v1.0.1-alpha
99
github.com/diktyo-io/networktopology-api v1.0.1-alpha
1010
github.com/dustin/go-humanize v1.0.1
1111
github.com/go-logr/logr v1.4.2
12-
github.com/google/go-cmp v0.6.0
12+
github.com/google/go-cmp v0.7.0
1313
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.1.2
1414
github.com/k8stopologyawareschedwg/podfingerprint v0.2.2
1515
github.com/patrickmn/go-cache v2.1.0+incompatible
1616
github.com/paypal/load-watcher v0.2.4
1717
github.com/spf13/pflag v1.0.5
1818
github.com/stretchr/testify v1.9.0
1919
gonum.org/v1/gonum v0.12.0
20-
k8s.io/api v0.33.0
21-
k8s.io/apimachinery v0.33.0
20+
k8s.io/api v0.33.1
21+
k8s.io/apimachinery v0.33.1
2222
k8s.io/apiserver v0.31.8
23-
k8s.io/client-go v0.31.8
23+
k8s.io/client-go v0.33.1
2424
k8s.io/code-generator v0.33.0
2525
k8s.io/component-base v0.31.8
2626
k8s.io/component-helpers v0.31.8
@@ -116,12 +116,12 @@ require (
116116
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
117117
golang.org/x/mod v0.21.0 // indirect
118118
golang.org/x/net v0.38.0 // indirect
119-
golang.org/x/oauth2 v0.21.0 // indirect
119+
golang.org/x/oauth2 v0.27.0 // indirect
120120
golang.org/x/sync v0.12.0 // indirect
121121
golang.org/x/sys v0.31.0 // indirect
122122
golang.org/x/term v0.30.0 // indirect
123123
golang.org/x/text v0.23.0 // indirect
124-
golang.org/x/time v0.5.0 // indirect
124+
golang.org/x/time v0.9.0 // indirect
125125
golang.org/x/tools v0.26.0 // indirect
126126
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
127127
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect

go.sum

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,8 +1338,8 @@ github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
13381338
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
13391339
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab/go.mod h1:3VYc5hodBMJ5+l/7J4xAyMeuM2PNuepvHlGs8yilUCA=
13401340
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
1341-
github.com/KunWuLuan/resourcepolicyapi v0.0.0-20250429133120-0b5462735cdc h1:tQ0XOIup39emiznGpxgV+PQAeqKvr0DeLfZf9ReqQfc=
1342-
github.com/KunWuLuan/resourcepolicyapi v0.0.0-20250429133120-0b5462735cdc/go.mod h1:6G5vMUV/xm+IEwNrNaxvZZr6WiqAHq+o+YsU0TiwXO0=
1341+
github.com/KunWuLuan/resourcepolicyapi v0.0.0-20250615030143-8529fd048210 h1:rcciPC0OF5eUcAs5GD1XmU8YvwNMFlY9RGi6z2sXJCM=
1342+
github.com/KunWuLuan/resourcepolicyapi v0.0.0-20250615030143-8529fd048210/go.mod h1:X8G9vQ4SKajDrD0WeM++XmFvNMSUL0bi2DOwVhiIw9g=
13431343
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
13441344
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
13451345
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
@@ -1918,8 +1918,9 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
19181918
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
19191919
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
19201920
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1921-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
19221921
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1922+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1923+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
19231924
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
19241925
github.com/google/go-github/v33 v33.0.0/go.mod h1:GMdDnVZY/2TsWgp/lkYnpSAh6TrzhANBBwm6k6TTEXg=
19251926
github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y=
@@ -3036,8 +3037,9 @@ golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2
30363037
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
30373038
golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8=
30383039
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
3039-
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
30403040
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
3041+
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
3042+
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
30413043
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw=
30423044
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
30433045
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -3285,8 +3287,9 @@ golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxb
32853287
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
32863288
golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
32873289
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
3288-
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
32893290
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
3291+
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
3292+
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
32903293
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
32913294
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
32923295
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.18.1-0.20250610061224-4cb7e87f3b45
7+
name: resourcepolicies.scheduling.x-k8s.io
8+
spec:
9+
group: scheduling.x-k8s.io
10+
names:
11+
kind: ResourcePolicy
12+
listKind: ResourcePolicyList
13+
plural: resourcepolicies
14+
shortNames:
15+
- rsp
16+
singular: resourcepolicy
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha1
20+
schema:
21+
openAPIV3Schema:
22+
properties:
23+
apiVersion:
24+
description: |-
25+
APIVersion defines the versioned schema of this representation of an object.
26+
Servers should convert recognized schemas to the latest internal value, and
27+
may reject unrecognized values.
28+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
29+
type: string
30+
kind:
31+
description: |-
32+
Kind is a string value representing the REST resource this object represents.
33+
Servers may infer this from the endpoint the client submits requests to.
34+
Cannot be updated.
35+
In CamelCase.
36+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
37+
type: string
38+
metadata:
39+
type: object
40+
spec:
41+
properties:
42+
matchLabelKeys:
43+
items:
44+
type: string
45+
type: array
46+
selector:
47+
additionalProperties:
48+
type: string
49+
type: object
50+
units:
51+
items:
52+
properties:
53+
max:
54+
format: int32
55+
type: integer
56+
maxResources:
57+
additionalProperties:
58+
anyOf:
59+
- type: integer
60+
- type: string
61+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
62+
x-kubernetes-int-or-string: true
63+
description: ResourceList is a set of (resource name, quantity)
64+
pairs.
65+
type: object
66+
nodeSelector:
67+
additionalProperties:
68+
type: string
69+
type: object
70+
podAnnotations:
71+
additionalProperties:
72+
type: string
73+
type: object
74+
podLabels:
75+
additionalProperties:
76+
type: string
77+
type: object
78+
type: object
79+
nullable: true
80+
type: array
81+
x-kubernetes-list-type: atomic
82+
type: object
83+
status:
84+
properties:
85+
lastUpdateTime:
86+
format: date-time
87+
type: string
88+
pods:
89+
items:
90+
format: int64
91+
type: integer
92+
type: array
93+
type: object
94+
required:
95+
- spec
96+
type: object
97+
served: true
98+
storage: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-deployment
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: nginx
10+
template:
11+
metadata:
12+
labels:
13+
app: nginx
14+
spec:
15+
schedulerName: custom-scheduler
16+
containers:
17+
- name: nginx-container
18+
resources:
19+
limits:
20+
cpu: 50m
21+
memory: 50Mi
22+
image: nginx:latest
23+
ports:
24+
- containerPort: 80
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: scheduling.x-k8s.io/v1alpha1
2+
kind: ResourcePolicy
3+
metadata:
4+
name: resourcepolicy-sample
5+
namespace: default
6+
spec:
7+
selector:
8+
app: nginx
9+
units:
10+
- max: 1
11+
nodeSelector:
12+
unit: first
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: kubescheduler.config.k8s.io/v1
2+
kind: KubeSchedulerConfiguration
3+
leaderElection:
4+
leaderElect: false
5+
clientConnection:
6+
kubeconfig: /home/kunwu1997/.kube/config
7+
profiles:
8+
- schedulerName: custom-scheduler
9+
plugins:
10+
multiPoint:
11+
enabled:
12+
- name: ResourcePolicy

0 commit comments

Comments
 (0)