diff --git a/contrib/cmd/runkperf/commands/bench/node100_pod10k.go b/contrib/cmd/runkperf/commands/bench/node100_pod10k.go index 46d98fa3..a0747885 100644 --- a/contrib/cmd/runkperf/commands/bench/node100_pod10k.go +++ b/contrib/cmd/runkperf/commands/bench/node100_pod10k.go @@ -102,13 +102,20 @@ func benchNode100DeploymentNPod10KRun(cliCtx *cli.Context) (*internaltypes.Bench // NOTE: The name pattern should be aligned with ../../../../internal/manifests/loadprofile/node100_pod10k.yaml. deploymentNamePattern := "benchmark" - // TODO(xinwei): Implement batching support for deploying deployments after decoupling it from rolling update logic. - ruCleanupFn, err := utils.DeployDeployments(dpCtx, - kubeCfgPath, deploymentNamePattern, total, replica, paddingBytes, 10*time.Minute) + bm := utils.DeploymentBatchManager{ + KubeCfgPath: kubeCfgPath, + DeploymentNamePattern: deploymentNamePattern, + DeploymentReplica: replica, + PaddingBytes: paddingBytes, + DeploymentBatchSize: 20, + } + + err = bm.Add(dpCtx, total) + defer bm.CleanAll() + if err != nil { return nil, fmt.Errorf("failed to setup workload: %w", err) } - defer ruCleanupFn() err = dumpDeploymentReplicas(ctx, kubeCfgPath, deploymentNamePattern, total) if err != nil { diff --git a/contrib/internal/manifests/workload/deployments/templates/deployments.tpl b/contrib/internal/manifests/workload/deployments/templates/deployments.tpl index 38df56c9..66a21507 100644 --- a/contrib/internal/manifests/workload/deployments/templates/deployments.tpl +++ b/contrib/internal/manifests/workload/deployments/templates/deployments.tpl @@ -1,7 +1,7 @@ {{- $pattern := .Values.namePattern }} {{- $replica := int .Values.replica }} {{- $paddingBytes := int .Values.paddingBytes }} -{{- range $index := (untilStep 0 (int .Values.total) 1) }} +{{- range $index := (untilStep (int .Values.start) (int (add (int .Values.start) (int .Values.total))) 1) }} apiVersion: v1 kind: Namespace metadata: diff --git a/contrib/internal/manifests/workload/deployments/values.yaml b/contrib/internal/manifests/workload/deployments/values.yaml index bab75055..75f7d4fe 100644 --- a/contrib/internal/manifests/workload/deployments/values.yaml +++ b/contrib/internal/manifests/workload/deployments/values.yaml @@ -2,3 +2,4 @@ namePattern: "benchmark" total: 5 replica: 2000 paddingBytes: 0 +start: 0 \ No newline at end of file diff --git a/contrib/utils/utils.go b/contrib/utils/utils.go index 9eb3fdbb..71985cb0 100644 --- a/contrib/utils/utils.go +++ b/contrib/utils/utils.go @@ -121,7 +121,7 @@ func DeployDeployments( ctx context.Context, kubeCfgPath string, releaseName string, - total, replica, paddingBytes int, + total, replica, paddingBytes, start int, deployTimeout time.Duration, ) (cleanupFn func(), retErr error) { infoLogger := log.GetLogger(ctx).WithKeyValues("level", "info") @@ -148,6 +148,7 @@ func DeployDeployments( fmt.Sprintf("total=%d", total), fmt.Sprintf("replica=%d", replica), fmt.Sprintf("paddingBytes=%d", paddingBytes), + fmt.Sprintf("start=%d", start), ), ) if err != nil { diff --git a/contrib/utils/utils_common.go b/contrib/utils/utils_common.go index 845d8ea0..331292b6 100644 --- a/contrib/utils/utils_common.go +++ b/contrib/utils/utils_common.go @@ -4,6 +4,8 @@ package utils import ( + "context" + "fmt" "time" ) @@ -61,5 +63,43 @@ func WithJobWaitTimeoutOpt(to time.Duration) JobTimeoutOpt { func WithJobDeleteTimeoutOpt(to time.Duration) JobTimeoutOpt { return func(jto *jobsTimeoutOption) { jto.deleteTimeout = to + + } +} + +type DeploymentBatchManager struct { + KubeCfgPath string + DeploymentNamePattern string + DeploymentReplica int + PaddingBytes int + DeploymentBatchSize int + cleanups []func() +} + +func (bm *DeploymentBatchManager) Add(ctx context.Context, total int) error { + for start := 0; start < total; start += bm.DeploymentBatchSize { + // Create a unique name for each deployment batch + namePattern := fmt.Sprintf("%s-%d", bm.DeploymentNamePattern, start/bm.DeploymentBatchSize) + + // Calculate the current batch size, ensuring it does not exceed the total + currentBatchSize := bm.DeploymentBatchSize + if start+currentBatchSize > total { + currentBatchSize = total - start + } + + cleanup, err := DeployDeployments(ctx, bm.KubeCfgPath, namePattern, currentBatchSize, bm.DeploymentReplica, + bm.PaddingBytes, start, 10*time.Minute) + if err != nil { + return err + } + // Store the cleanup function to be called later + bm.cleanups = append(bm.cleanups, cleanup) + } + return nil +} + +func (bm *DeploymentBatchManager) CleanAll() { + for i := len(bm.cleanups) - 1; i >= 0; i-- { + bm.cleanups[i]() } }