Skip to content

Commit

Permalink
Label hint
Browse files Browse the repository at this point in the history
If the user wants to provide hints to help schedule the client and
server on specific nodes, they can add `netperf=true` label to the nodes
they want tested.

Signed-off-by: Joe Talerico aka rook <joe.talerico@gmail.com>
  • Loading branch information
jtaleric committed Jan 9, 2025
1 parent 0d99424 commit 11888db
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ $ cd k8s-netperf
$ make container-build
```

## Label nodes
k8s-netperf will make the best decision it can to schedule the client and server in your cluster. However,
you can provide hints to ensure the client and server will always land on specific nodes.

To do this, apply a label to the nodes you want the client and server running

```shell
$ oc label nodes node-name netperf=true
```

## Running with Pods
Ensure your `kubeconfig` is properly set to the cluster you would like to run `k8s-netperf` against.

Expand Down
31 changes: 31 additions & 0 deletions pkg/k8s/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,21 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
RequiredDuringSchedulingIgnoredDuringExecution: workerNodeSelectorExpression,
}
}
} else {
affinity := corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.PreferredSchedulingTerm{
{
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"true"}},
},
},
},
},
}
cdpAcross.NodeAffinity = affinity
cdpHostAcross.NodeAffinity = affinity
}

if ncount > 1 {
Expand Down Expand Up @@ -427,6 +442,21 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
}
sdp.NodeAffinity = affinity
sdpHost.NodeAffinity = affinity
} else {
affinity := corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.PreferredSchedulingTerm{
{
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"true"}},
},
},
},
},
}
sdp.NodeAffinity = affinity
sdpHost.NodeAffinity = affinity
}
if ncount > 1 {
antiAffinity := corev1.PodAntiAffinity{
Expand Down Expand Up @@ -583,6 +613,7 @@ func zoneNodeSelectorExpression(zone string) []corev1.PreferredSchedulingTerm {
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "topology.kubernetes.io/zone", Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"true"}},
},
},
},
Expand Down

0 comments on commit 11888db

Please sign in to comment.