Skip to content

Commit ccba9e8

Browse files
committedDec 18, 2024
Added PEAKS plugin code changes
Signed-off-by: Felix George <felixpv007@gmail.com>
1 parent 339af4e commit ccba9e8

15 files changed

+599
-0
lines changed
 

‎apis/config/register.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4444
&TopologicalSortArgs{},
4545
&NetworkOverheadArgs{},
4646
&SySchedArgs{},
47+
&PeaksArgs{},
4748
)
4849
return nil
4950
}

‎apis/config/types.go

+19
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,22 @@ type SySchedArgs struct {
279279
// CR name of the default profile for all system calls
280280
DefaultProfileName string
281281
}
282+
283+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
284+
285+
// PeaksArgs holds arguments used to configure the Peaks plugin
286+
type PeaksArgs struct {
287+
metav1.TypeMeta
288+
289+
// Address of load watcher service
290+
WatcherAddress string
291+
NodePowerModel map[string]PowerModel // Node power model where key is node name and value is power model
292+
}
293+
294+
type PowerModel struct {
295+
K0 float64 `json:"k0"`
296+
K1 float64 `json:"k1"`
297+
K2 float64 `json:"k2"`
298+
// Power = K0 + K1 * e ^(K2 * x) : where x is utilisation
299+
// Idle power of node will be K0 + K1
300+
}

‎apis/config/v1/register.go

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4646
&TopologicalSortArgs{},
4747
&NetworkOverheadArgs{},
4848
&SySchedArgs{},
49+
&PeaksArgs{},
4950
)
5051
return nil
5152
}

‎apis/config/v1/types.go

+20
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,23 @@ type SySchedArgs struct {
277277
// CR name of the default profile for all system calls
278278
DefaultProfileName *string `json:"defaultProfileName,omitempty"`
279279
}
280+
281+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
282+
283+
// PeaksArgs holds arguments used to configure the Peaks plugin
284+
type PeaksArgs struct {
285+
metav1.TypeMeta `json:",inline"`
286+
287+
// Address of load watcher service
288+
WatcherAddress string `json:watcherAddress",inline"`
289+
// Associating power models to nodes using node labels will be added as a functionality in a future PR.
290+
NodePowerModel map[string]PowerModel `json:nodePowerModel",inline"`
291+
}
292+
293+
type PowerModel struct {
294+
K0 float64 `json:"k0"`
295+
K1 float64 `json:"k1"`
296+
K2 float64 `json:"k2"`
297+
// Power = K0 + K1 * e ^(K2 * x) : where x is utilisation
298+
// Idle power of node will be K0 + K1
299+
}

‎apis/config/v1/zz_generated.conversion.go

+66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apis/config/v1/zz_generated.deepcopy.go

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apis/config/zz_generated.deepcopy.go

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cmd/scheduler/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"sigs.k8s.io/scheduler-plugins/pkg/sysched"
3737
"sigs.k8s.io/scheduler-plugins/pkg/trimaran/loadvariationriskbalancing"
3838
"sigs.k8s.io/scheduler-plugins/pkg/trimaran/lowriskovercommitment"
39+
"sigs.k8s.io/scheduler-plugins/pkg/trimaran/peaks"
3940
"sigs.k8s.io/scheduler-plugins/pkg/trimaran/targetloadpacking"
4041

4142
// Ensure scheme package is initialized.
@@ -58,6 +59,7 @@ func main() {
5859
app.WithPlugin(targetloadpacking.Name, targetloadpacking.New),
5960
app.WithPlugin(lowriskovercommitment.Name, lowriskovercommitment.New),
6061
app.WithPlugin(sysched.Name, sysched.New),
62+
app.WithPlugin(peaks.Name, peaks.New),
6163
// Sample plugins below.
6264
// app.WithPlugin(crossnodepreemption.Name, crossnodepreemption.New),
6365
app.WithPlugin(podstate.Name, podstate.New),
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Getting Started
2+
3+
## Configuring load-watcher on a Kubernetes cluster
4+
5+
#### Clone repository.
6+
7+
We use the available manifest file to create load-watcher pod and service.
8+
9+
```bash
10+
git clone https://github.com/paypal/load-watcher.git
11+
```
12+
13+
Building image
14+
15+
```bash
16+
docker build -t load-watcher:local .
17+
docker tag load-watcher:local <replace_with_image_registry>/loadwatcher:latest
18+
docker push <replace_with_image_registry>/loadwatcher:latest
19+
```
20+
21+
Deploy load-watcher
22+
Follow https://github.com/paypal/load-watcher?tab=readme-ov-file#deploy-load-watcher-as-a-service
23+
24+
## Configure PEAKS scheduler plugin
25+
26+
Building image
27+
28+
```bash
29+
make release-image.amd64
30+
docker tag <image tag> <new image tag>
31+
docker push <new image tag>
32+
```
33+
34+
Configuring power model
35+
36+
```bash
37+
kubectl create configmap peaks-node-power-model --from-file=peaks-power-model-config.json -n kube-system
38+
```
39+
40+
Deploy peaks RBAC configurations
41+
42+
```bash
43+
kubectl apply -f peaks.yaml
44+
```
45+
46+
Deploy peaks plugin
47+
48+
```bash
49+
kubectl apply -f deployment.yaml
50+
```
51+
52+
Test peaks plugin
53+
54+
```bash
55+
kubectl apply -f test-po.yaml
56+
```
57+
58+
## Running the unit test cases
59+
To run the `go` unit test cases, set the environment variable `NODE_POWER_MODEL` appropriately, as below example.
60+
```bash
61+
export NODE_POWER_MODEL=./power_model/node_power_model
62+
```
63+
64+
## Peaks Power Model JSON schema
65+
The power model typically is a mathematical expression (e.g., `NodePower = K0 + K1 * e^(K2 * x)`, where `x` is node utilisation and each `K` is a constant)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
component: scheduler
6+
tier: control-plane
7+
name: peaks
8+
namespace: kube-system
9+
spec:
10+
selector:
11+
matchLabels:
12+
component: scheduler
13+
tier: control-plane
14+
replicas: 1
15+
template:
16+
metadata:
17+
labels:
18+
component: scheduler
19+
tier: control-plane
20+
version: second
21+
spec:
22+
serviceAccountName: peaks
23+
hostNetwork: true
24+
containers:
25+
- name: peaks
26+
command:
27+
- /bin/kube-scheduler
28+
- --bind-address=0.0.0.0
29+
- --leader-elect=false
30+
- --config=/home/scheduler-config.yaml
31+
- -v=6
32+
image: <REPLACE_ME_WITH_PEAKS_IMAGE>
33+
imagePullPolicy: Always
34+
resources:
35+
requests:
36+
cpu: '0.1'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"node_1":{"k0":"<replace with node 1 k0>","k1":"<replace with node 1 k1>","k2":"<replace with node 1 k2>"},"node_2":{"k0":"<replace with node 2 k0>","k1":"<replace with node 2 k1>","k2":"<replace with node 2 k2>"}}

0 commit comments

Comments
 (0)
Please sign in to comment.