Skip to content

Commit

Permalink
Add qps flag
Browse files Browse the repository at this point in the history
Signed-off-by: kouki <kouworld0123@gmail.com>
  • Loading branch information
kmdkuk committed Mar 17, 2023
1 parent 399e4a7 commit dbd4f32
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/moco-controller/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var config struct {
exporterImage string
interval time.Duration
maxConcurrentReconciles int
qps int
zapOpts zap.Options
}

Expand Down Expand Up @@ -104,6 +105,9 @@ func init() {
fs.StringVar(&config.exporterImage, "mysqld-exporter-image", moco.ExporterImage, "The image of mysqld_exporter sidecar container")
fs.DurationVar(&config.interval, "check-interval", 1*time.Minute, "Interval of cluster maintenance")
fs.IntVar(&config.maxConcurrentReconciles, "max-concurrent-reconciles", 8, "The maximum number of concurrent reconciles which can be run")
// The default QPS is 20.
// https://github.com/kubernetes-sigs/controller-runtime/blob/a26de2d610c3cf4b2a02688534aaf5a65749c743/pkg/client/config/config.go#L84-L85
fs.IntVar(&config.qps, "apiserver-qps-throttle", 20, "The maximum QPS to the API server.")

goflags := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(goflags)
Expand Down
10 changes: 9 additions & 1 deletion cmd/moco-controller/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ func subMain(ns, addr string, port int) error {
clusterLog := ctrl.Log.WithName("cluster-manager")
clustering.SetDefaultLogger(clusterLog)

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
restCfg, err := ctrl.GetConfig()
if err != nil {
setupLog.Error(err, "failed to get REST config")
return err
}
restCfg.QPS = float32(config.qps)
restCfg.Burst = int(restCfg.QPS * 1.5)

mgr, err := ctrl.NewManager(restCfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: config.metricsAddr,
HealthProbeBindAddress: config.probeAddr,
Expand Down
1 change: 1 addition & 0 deletions docs/moco-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Flags:
--add_dir_header If true, adds the file directory to the header of the log messages
--agent-image string The image of moco-agent sidecar container
--alsologtostderr log to standard error as well as files (no effect when -logtostderr=true)
--apiserver-qps-throttle int The maximum QPS to the API server. (default 20)
--backup-image string The image of moco-backup container
--cert-dir string webhook certificate directory
--check-interval duration Interval of cluster maintenance (default 1m0s)
Expand Down

0 comments on commit dbd4f32

Please sign in to comment.