Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = cli.Command{ Name: "warmup", Usage: "Warmup cluster and try best to scale it to 8 cores at least", Flags: []cli.Flag{ cli.StringFlag{ Name: "kubeconfig", Usage: "Path to the kubeconfig file", }, cli.StringFlag{ Name: "runner-image", Usage: "The runner's conainer image", Required: true, }, cli.StringFlag{ Name: "runner-flowcontrol", Usage: "Apply flowcontrol to runner group. (FORMAT: PriorityLevel:MatchingPrecedence)", Value: "workload-low:1000", }, cli.Float64Flag{ Name: "rate", Usage: "The maximum requests per second per runner (There are 10 runners totally)", Value: 20, }, cli.IntFlag{ Name: "total", Usage: "Total requests per runner (There are 10 runners totally and runner's rate is 20)", Value: 10000, }, cli.StringFlag{ Name: "vc-affinity", Usage: "Deploy virtualnode's controller with a specific labels (FORMAT: KEY=VALUE[,VALUE])", Value: "node.kubernetes.io/instance-type=Standard_D8s_v3,m4.2xlarge", }, cli.StringFlag{ Name: "rg-affinity", Usage: "Deploy runner group with a specific labels (FORMAT: KEY=VALUE[,VALUE])", Value: "node.kubernetes.io/instance-type=Standard_D16s_v3,m4.4xlarge", }, cli.BoolFlag{ Name: "eks", Usage: "Indicates the target kubernetes cluster is EKS", Hidden: true, }, }, Action: func(cliCtx *cli.Context) (retErr error) { ctx := context.Background() rgCfgFile, rgCfgFileDone, err := utils.NewLoadProfileFromEmbed( "loadprofile/warmup.yaml", func(spec *types.RunnerGroupSpec) error { reqs := cliCtx.Int("total") if reqs < 0 { return fmt.Errorf("invalid total value: %v", reqs) } rate := cliCtx.Float64("rate") if rate <= 0 { return fmt.Errorf("invalid rate value: %v", rate) } rgAffinity := cliCtx.String("rg-affinity") affinityLabels, err := kperfcmdutils.KeyValuesMap([]string{rgAffinity}) if err != nil { return fmt.Errorf("failed to parse %s affinity: %w", rgAffinity, err) } spec.Profile.Spec.Total = reqs spec.Profile.Spec.Rate = rate spec.NodeAffinity = affinityLabels data, _ := yaml.Marshal(spec) klog.V(2).InfoS("Load Profile", "config", string(data)) return nil }, ) if err != nil { return err } defer func() { _ = rgCfgFileDone() }() kubeCfgPath := cliCtx.String("kubeconfig") isEKS := cliCtx.Bool("eks") virtualNodeAffinity := cliCtx.String("vc-affinity") if isEKS { perr := patchEKSDaemonsetWithoutToleration(ctx, kubeCfgPath) if perr != nil { return perr } } cores, ferr := utils.FetchAPIServerCores(ctx, kubeCfgPath) if ferr == nil { if isReady(cores) { klog.V(0).Infof("apiserver resource is ready: %v", cores) return nil } } else { klog.V(0).ErrorS(ferr, "failed to fetch apiserver cores") } delNP, err := deployWarmupVirtualNodepool(ctx, kubeCfgPath, isEKS, virtualNodeAffinity) if err != nil { return err } defer func() { derr := delNP() if retErr == nil { retErr = derr } }() var wg sync.WaitGroup wg.Add(1) jobCtx, jobCancel := context.WithCancel(ctx) go func() { defer wg.Done() utils.RepeatJobWithPod(jobCtx, kubeCfgPath, "warmupjob", "workload/3kpod.job.yaml", 5*time.Second) }() _, derr := utils.DeployRunnerGroup(ctx, kubeCfgPath, cliCtx.String("runner-image"), rgCfgFile, cliCtx.String("runner-flowcontrol"), "", ) jobCancel() wg.Wait() cores, ferr = utils.FetchAPIServerCores(ctx, kubeCfgPath) if ferr == nil { if isReady(cores) { klog.V(0).Infof("apiserver resource is ready: %v", cores) return nil } } return derr }, }
Command represents warmup subcommand.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.