Skip to content

Commit c50620a

Browse files
authored
Make QPS and burst configurable (#47)
Signed-off-by: Yi Chen <github@chenyicn.net>
1 parent 1828ba6 commit c50620a

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎cmd/tf-operator.v1/app/options/options.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"flag"
1919
"time"
2020

21-
"k8s.io/api/core/v1"
21+
v1 "k8s.io/api/core/v1"
2222
)
2323

2424
const (
@@ -39,6 +39,8 @@ type ServerOption struct {
3939
MonitoringPort int
4040
ResyncPeriod time.Duration
4141
EventLevel string
42+
QPS float64
43+
Burst int
4244
}
4345

4446
// NewServerOption creates a new CMServer with a default config.
@@ -71,4 +73,7 @@ func (s *ServerOption) AddFlags(fs *flag.FlagSet) {
7173
fs.DurationVar(&s.ResyncPeriod, "resync-period", DefaultResyncPeriod, "Resync interval of the tf-operator")
7274

7375
fs.StringVar(&s.EventLevel, "event-level", EventLevelDebug, "The tfjob event level, support info,debug.")
76+
77+
fs.Float64Var(&s.QPS, "qps", 10.0, "QPS for kubernetes client")
78+
fs.IntVar(&s.Burst, "burst", 30, "Maximum burst for throttle")
7479
}

‎cmd/tf-operator.v1/app/server.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"time"
2121

2222
"github.com/kubeflow/tf-operator/cmd/tf-operator.v1/app/options"
23-
"github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1"
23+
v1 "github.com/kubeflow/tf-operator/pkg/apis/tensorflow/v1"
2424
tfjobclientset "github.com/kubeflow/tf-operator/pkg/client/clientset/versioned"
2525
"github.com/kubeflow/tf-operator/pkg/client/clientset/versioned/scheme"
2626
tfjobinformers "github.com/kubeflow/tf-operator/pkg/client/informers/externalversions"
@@ -99,8 +99,8 @@ func Run(opt *options.ServerOption) error {
9999
if err != nil {
100100
log.Fatalf("Error building kubeconfig: %s", err.Error())
101101
}
102-
kcfg.QPS = 10
103-
kcfg.Burst = 20
102+
kcfg.QPS = float32(opt.QPS)
103+
kcfg.Burst = opt.Burst
104104

105105
// Create clients.
106106
kubeClientSet, leaderElectionClientSet, tfJobClientSet, kubeBatchClientSet, err := createClientSets(kcfg)

0 commit comments

Comments
 (0)