Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/kperf/commands/runnergroup/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var runCommand = cli.Command{
},
cli.StringSliceFlag{
Name: "affinity",
Usage: "Deploy server to the node with a specific labels (FORMAT: KEY=VALUE[,VALUE])",
Usage: "Deploy server and runners to the node with a specific labels (FORMAT: KEY=VALUE[,VALUE])",
},
cli.IntFlag{
Name: "runner-verbosity",
Expand Down Expand Up @@ -76,6 +76,8 @@ var runCommand = cli.Command{
return fmt.Errorf("only support one runner group right now. will support it after https://github.com/Azure/kperf/issues/25")
}

specs[0].NodeAffinity = affinityLabels

kubeCfgPath := cliCtx.GlobalString("kubeconfig")
return runner.CreateRunnerGroupServer(context.Background(),
kubeCfgPath,
Expand Down
18 changes: 18 additions & 0 deletions runner/group/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job {
job.OwnerReferences = append(job.OwnerReferences, *h.ownerRef)
}

job.Spec.Template.ObjectMeta = metav1.ObjectMeta{
Labels: map[string]string{
"app-name-job": h.name,
},
}
job.Spec.Template.Spec = corev1.PodSpec{
Affinity: &corev1.Affinity{},
Containers: []corev1.Container{
Expand Down Expand Up @@ -430,6 +435,19 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job {
},
},
RestartPolicy: corev1.RestartPolicyNever,
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{
{
MaxSkew: 1,
TopologyKey: "kubernetes.io/hostname",
WhenUnsatisfiable: corev1.ScheduleAnyway,
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app-name-job": h.name,
},
},
},
},

Volumes: []corev1.Volume{
{
Name: "config",
Expand Down
Loading