File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
cmd/kperf/commands/runnergroup Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ var runCommand = cli.Command{
4444 },
4545 cli.StringSliceFlag {
4646 Name : "affinity" ,
47- Usage : "Deploy server to the node with a specific labels (FORMAT: KEY=VALUE[,VALUE])" ,
47+ Usage : "Deploy server and runners to the node with a specific labels (FORMAT: KEY=VALUE[,VALUE])" ,
4848 },
4949 cli.IntFlag {
5050 Name : "runner-verbosity" ,
@@ -76,6 +76,8 @@ var runCommand = cli.Command{
7676 return fmt .Errorf ("only support one runner group right now. will support it after https://github.com/Azure/kperf/issues/25" )
7777 }
7878
79+ specs [0 ].NodeAffinity = affinityLabels
80+
7981 kubeCfgPath := cliCtx .GlobalString ("kubeconfig" )
8082 return runner .CreateRunnerGroupServer (context .Background (),
8183 kubeCfgPath ,
Original file line number Diff line number Diff line change @@ -374,6 +374,11 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job {
374374 job .OwnerReferences = append (job .OwnerReferences , * h .ownerRef )
375375 }
376376
377+ job .Spec .Template .ObjectMeta = metav1.ObjectMeta {
378+ Labels : map [string ]string {
379+ "app-name-job" : h .name ,
380+ },
381+ }
377382 job .Spec .Template .Spec = corev1.PodSpec {
378383 Affinity : & corev1.Affinity {},
379384 Containers : []corev1.Container {
@@ -430,6 +435,19 @@ func (h *Handler) buildBatchJobObject(uploadURL string) *batchv1.Job {
430435 },
431436 },
432437 RestartPolicy : corev1 .RestartPolicyNever ,
438+ TopologySpreadConstraints : []corev1.TopologySpreadConstraint {
439+ {
440+ MaxSkew : 1 ,
441+ TopologyKey : "kubernetes.io/hostname" ,
442+ WhenUnsatisfiable : corev1 .ScheduleAnyway ,
443+ LabelSelector : & metav1.LabelSelector {
444+ MatchLabels : map [string ]string {
445+ "app-name-job" : h .name ,
446+ },
447+ },
448+ },
449+ },
450+
433451 Volumes : []corev1.Volume {
434452 {
435453 Name : "config" ,
You can’t perform that action at this time.
0 commit comments