Skip to content

Commit

Permalink
Merge pull request #662 from l1b0k/feat/limit
Browse files Browse the repository at this point in the history
add openAPI limit
  • Loading branch information
BSWANG authored Aug 8, 2024
2 parents a016ba5 + 0b9e591 commit c3545d6
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 123 deletions.
3 changes: 1 addition & 2 deletions cmd/terway-controlplane/terway-controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -205,7 +204,7 @@ func main() {
panic(err)
}

aliyunClient, err := aliyun.New(clientSet, flowcontrol.NewTokenBucketRateLimiter(cfg.ReadOnlyQPS, cfg.ReadOnlyBurst), flowcontrol.NewTokenBucketRateLimiter(cfg.MutatingQPS, cfg.MutatingBurst))
aliyunClient, err := aliyun.New(clientSet, aliyun.FromMap(cfg.RateLimit))
if err != nil {
panic(err)
}
Expand Down
5 changes: 1 addition & 4 deletions daemon/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/samber/lo"
"k8s.io/client-go/util/flowcontrol"

"github.com/AliyunContainerService/terway/pkg/aliyun/client"
"github.com/AliyunContainerService/terway/pkg/aliyun/credential"
Expand Down Expand Up @@ -159,9 +158,7 @@ func (b *NetworkServiceBuilder) setupAliyunClient() error {
return err
}

aliyunClient, err := client.New(clientSet,
flowcontrol.NewTokenBucketRateLimiter(8, 10),
flowcontrol.NewTokenBucketRateLimiter(4, 5))
aliyunClient, err := client.New(clientSet, client.FromMap(b.config.RateLimit))
if err != nil {
return err
}
Expand Down
5 changes: 1 addition & 4 deletions examples/maxpods/maxpods.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"log"

"github.com/sirupsen/logrus"
"k8s.io/client-go/util/flowcontrol"

"github.com/AliyunContainerService/terway/pkg/aliyun/client"
"github.com/AliyunContainerService/terway/pkg/aliyun/credential"
Expand Down Expand Up @@ -49,9 +48,7 @@ func main() {
panic(err)
}

api, err := client.New(c,
flowcontrol.NewTokenBucketRateLimiter(8, 10),
flowcontrol.NewTokenBucketRateLimiter(4, 5))
api, err := client.New(c, nil)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit c3545d6

Please sign in to comment.