Skip to content

Commit

Permalink
Expose performance options (#1083)
Browse files Browse the repository at this point in the history
This allow admins to specify a few parameters to better suit their use
of Chains.

`--threads-per-controller` controls the number of concurrent threads the
Chains controller processes. The default value is 2.

`--kube-api-burst` controle the maximum burst for throttle.

`--kube-api-qps` controles the maximum QPS to the server from the
client.

The approach taken here is the same one used by the Tekton Pipeline
controller for the sake of consistency in the ecosystem.

Signed-off-by: Luiz Carvalho <[email protected]>
  • Loading branch information
lcarva authored Mar 20, 2024
1 parent d5a5659 commit ebcd9c2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (

"github.com/tektoncd/chains/pkg/reconciler/pipelinerun"
"github.com/tektoncd/chains/pkg/reconciler/taskrun"

"k8s.io/client-go/rest"

"knative.dev/pkg/controller"
"knative.dev/pkg/injection"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/signals"
Expand All @@ -35,11 +39,22 @@ import (
_ "github.com/sigstore/sigstore/pkg/signature/kms/hashivault"
)

var namespace = flag.String("namespace", "", "Namespace to restrict informer to. Optional, defaults to all namespaces.")

func main() {
flag.IntVar(&controller.DefaultThreadsPerController, "threads-per-controller", controller.DefaultThreadsPerController, "Threads (goroutines) to create per controller")
namespace := flag.String("namespace", "", "Namespace to restrict informer to. Optional, defaults to all namespaces.")

// This also calls flag.Parse().
cfg := injection.ParseAndGetRESTConfigOrDie()

if cfg.QPS == 0 {
cfg.QPS = 2 * rest.DefaultQPS
}
if cfg.Burst == 0 {
cfg.Burst = rest.DefaultBurst
}

flag.Parse()
ctx := injection.WithNamespaceScope(signals.NewContext(), *namespace)

sharedmain.MainWithContext(ctx, "watcher", taskrun.NewController, pipelinerun.NewController)
sharedmain.MainWithConfig(ctx, "watcher", cfg, taskrun.NewController, pipelinerun.NewController)
}
27 changes: 27 additions & 0 deletions docs/performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Performance

Tekton Chains exposes a few parameters that can be used to fine tune the controllers execution to
improve its performance as needed.

The controller accepts the following parameters:

`--threads-per-controller` controls the number of concurrent threads the Chains controller
processes. The default value is 2.

`--kube-api-burst` controle the maximum burst for throttle. The default value is 10.

`--kube-api-qps` controles the maximum QPS to the server from the client. The default value is 5.

Modify the `Deployment` to use those parameters, for example:

```yaml
spec:
template:
spec:
containers:
- image: gcr.io/tekton-releases/github.com/tektoncd/chains/cmd/controller:v0.20.0
args:
- --threads-per-controller=32
- --kube-api-burst=2
- --kube-api-qps=3
```

0 comments on commit ebcd9c2

Please sign in to comment.