K8S控制器压测调参
选举参数: (适当调大)
flag.DurationVar(&leaseDuration, "lease-duration", 75*time.Second, "")
flag.DurationVar(&renewDeadline, "renew-deadline", 60*time.Second, "")
flag.DurationVar(&retryPeriod, "retry-period", 10*time.Second, "")
与APIServer建连和请求参数(尤其是第一次全量List):
flag.Float64Var(&clientQPS64, "client-qps", 300, "the qps value for fedcluster")
flag.IntVar(&clientBurst, "client-burst", 600, "the burst value for fedcluster")
flag.IntVar(&concurrency, "concurrency", 20, "Number of FedKService to process simultaneously")
flag.DurationVar(&clientTimeout, "client-timeout", 100*time.Second, "karmada ApiServer request timeout")
flag.DurationVar(&cacheSyncTimeout, "cache-sync-timeout", 10*time.Minute, "the cache sync context timeout")
控制器定时调协参数:(关闭)
flag.DurationVar(&resyncPeriod, "resync_period", 0*time.Second, "karmada Controller re-reconcile period")
代码例子:
mgr, err := ctrl.NewManager(fedClusterRestConfig, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: webhookPort,
CertDir: webhookCertDir,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: leaderElectionID,
RetryPeriod: &retryPeriod,
RenewDeadline: &renewDeadline,
LeaseDuration: &leaseDuration,
SyncPeriod: &resyncPeriod,
})
clientConfig := clientcmd.NewDefaultClientConfig(*kubeconfig, &clientcmd.ConfigOverrides{})
cfg, err = clientConfig.ClientConfig()
if err != nil {
log.Error(err, "failed to create rest config")
os.Exit(1)
}
cfg.QPS = clientQPS
cfg.Burst = clientBurst
cfg.Timeout = clientTimeout
if err = (&controllers.XXXReconciler{
Client: mgr.GetClient(),
Logger: logger,
Scheme: mgr.GetScheme(),
RestConfig: cfg,
Recorder: mgr.GetEventRecorderFor("FedKService"),
}).SetupWithManager(mgr, controller.Options{
RateLimiter: utils.ControllerRateLimiter(clientQPS, clientBurst),
MaxConcurrentReconciles: concurrency,
CacheSyncTimeout: cacheSyncTimeout,
})