Skip to content

Commit

Permalink
add qps and burst settings (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuanyiyi authored Oct 26, 2023
1 parent bd41239 commit 6513d8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ spec:
args:
- --leader-elect=false
- --provider-config=/etc/kruise-game/config.toml
- --api-server-qps=5
- --api-server-qps-burst=10
image: controller:latest
name: manager
env:
Expand Down
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/openkruise/kruise-game/pkg/metrics"
"github.com/openkruise/kruise-game/pkg/webhook"
"google.golang.org/grpc"
"k8s.io/client-go/rest"
"net"
"os"
"time"
Expand All @@ -53,6 +54,8 @@ import (
var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")

apiServerSustainedQPSFlag, apiServerBurstQPSFlag int
)

func init() {
Expand Down Expand Up @@ -82,6 +85,8 @@ func main() {
"Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
flag.StringVar(&syncPeriodStr, "sync-period", "", "Determines the minimum frequency at which watched resources are reconciled.")
flag.StringVar(&scaleServerAddr, "scale-server-bind-address", ":6000", "The address the scale server endpoint binds to.")
flag.IntVar(&apiServerSustainedQPSFlag, "api-server-qps", 0, "Maximum sustained queries per second to send to the API server")
flag.IntVar(&apiServerBurstQPSFlag, "api-server-qps-burst", 0, "Maximum burst queries per second to send to the API server")

// Add cloud provider flags
cloudprovider.InitCloudProviderFlags()
Expand All @@ -106,6 +111,7 @@ func main() {
}

restConfig := ctrl.GetConfigOrDie()
setRestConfig(restConfig)
mgr, err := ctrl.NewManager(restConfig, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down Expand Up @@ -205,3 +211,12 @@ func main() {
os.Exit(1)
}
}

func setRestConfig(c *rest.Config) {
if apiServerSustainedQPSFlag > 0 {
c.QPS = float32(apiServerSustainedQPSFlag)
}
if apiServerBurstQPSFlag > 0 {
c.Burst = apiServerBurstQPSFlag
}
}

0 comments on commit 6513d8e

Please sign in to comment.