Skip to content

Commit

Permalink
Modifying label
Browse files Browse the repository at this point in the history
Allow the user to pick the server and client hosts individually.

Signed-off-by: Joe Talerico aka rook <[email protected]>
  • Loading branch information
jtaleric committed Jan 10, 2025
1 parent 11888db commit 75fcc0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ $ 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.
you can provide hints to ensure the client and server lands 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
$ oc label nodes node-name netperf=client
$ oc label nodes node-name netperf=server
```

## Running with Pods
Expand Down
18 changes: 9 additions & 9 deletions pkg/k8s/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
}
if z != "" && numNodes > 1 {
cdp.NodeAffinity = corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z),
PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z, "client"),
}
}

Expand Down Expand Up @@ -334,7 +334,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
if z != "" {
if numNodes > 1 {
cdpAcross.NodeAffinity = corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z),
PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z, "client"),
RequiredDuringSchedulingIgnoredDuringExecution: workerNodeSelectorExpression,
}
} else {
Expand All @@ -349,7 +349,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"true"}},
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"client"}},
},
},
},
Expand All @@ -362,7 +362,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
if ncount > 1 {
if s.HostNetwork {
cdpHostAcross.NodeAffinity = corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z),
PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z, "client"),
RequiredDuringSchedulingIgnoredDuringExecution: workerNodeSelectorExpression,
}
cdpHostAcross.PodAntiAffinity = corev1.PodAntiAffinity{
Expand Down Expand Up @@ -427,9 +427,9 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
if z != "" {
var affinity corev1.NodeAffinity
if numNodes > 1 {
nodeZone := zoneNodeSelectorExpression(z)
nodeZone := zoneNodeSelectorExpression(z, "server")
if s.AcrossAZ {
nodeZone = zoneNodeSelectorExpression(acrossZone)
nodeZone = zoneNodeSelectorExpression(acrossZone, "server")
}
affinity = corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: nodeZone,
Expand All @@ -449,7 +449,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error {
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"true"}},
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{"server"}},
},
},
},
Expand Down Expand Up @@ -606,14 +606,14 @@ func launchClientVM(perf *config.PerfScenarios, name string, podAff *corev1.PodA
return nil
}

func zoneNodeSelectorExpression(zone string) []corev1.PreferredSchedulingTerm {
func zoneNodeSelectorExpression(zone string, role string) []corev1.PreferredSchedulingTerm {
return []corev1.PreferredSchedulingTerm{
{
Weight: 100,
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"}},
{Key: "netperf", Operator: corev1.NodeSelectorOpIn, Values: []string{role}},
},
},
},
Expand Down

0 comments on commit 75fcc0e

Please sign in to comment.