Skip to content

Commit

Permalink
Expose performance options (v0.16) (#1080)
Browse files Browse the repository at this point in the history
* Expose performance options

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]>

* Remove test for Pipelines v0.41

This release is no longer supported and is no longer compatible with the
e2e tests in this branch.

Signed-off-by: Luiz Carvalho <[email protected]>

---------

Signed-off-by: Luiz Carvalho <[email protected]>
  • Loading branch information
lcarva authored Mar 20, 2024
1 parent bc7d767 commit 4ae9710
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/kind-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
fail-fast: false # Keep running if one leg fails.
matrix:
pipelines-release:
- v0.41.0
- v0.44.0
- v0.46.0
- v0.47.0
Expand Down
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 4ae9710

Please sign in to comment.