From eda4b19594fed7c1e5139c59784573b5bf66e30d Mon Sep 17 00:00:00 2001 From: Luiz Carvalho Date: Wed, 20 Mar 2024 12:42:35 -0400 Subject: [PATCH] Expose performance options (v0.19) (#1081) * 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 * 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 --------- Signed-off-by: Luiz Carvalho --- .github/workflows/kind-e2e.yaml | 1 - cmd/controller/main.go | 21 ++++++++++++++++++--- docs/performance.md | 27 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 docs/performance.md diff --git a/.github/workflows/kind-e2e.yaml b/.github/workflows/kind-e2e.yaml index 60bf099f4a..67f5202fe1 100644 --- a/.github/workflows/kind-e2e.yaml +++ b/.github/workflows/kind-e2e.yaml @@ -32,7 +32,6 @@ jobs: fail-fast: false # Keep running if one leg fails. matrix: pipelines-release: - - v0.41.3 # LTS - v0.44.4 # LTS - v0.47.3 # LTS - v0.50.1 # LTS diff --git a/cmd/controller/main.go b/cmd/controller/main.go index d8541a617f..8d99aa482b 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -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" @@ -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) } diff --git a/docs/performance.md b/docs/performance.md new file mode 100644 index 0000000000..0043a96520 --- /dev/null +++ b/docs/performance.md @@ -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 +```