From abb86157963f71e680f534e0cfa864edde91e07a Mon Sep 17 00:00:00 2001 From: Arnaud <25585350+arnaud-tincelin@users.noreply.github.com> Date: Tue, 28 Jun 2022 02:08:25 +0200 Subject: [PATCH] Webhook server configuration with kustomize (#1312) * webhook server configuration with kustomize * Update README.md * Update README.md * Update README.md Co-authored-by: Yusuke Kuoka --- README.md | 45 +++++++++++++++++-- config/default/kustomization.yaml | 6 --- .../gh-webhook-server-auth-proxy-patch.yaml | 0 .../github-webhook-server/kustomization.yaml | 15 ++++--- 4 files changed, 51 insertions(+), 15 deletions(-) rename config/{default => github-webhook-server}/gh-webhook-server-auth-proxy-patch.yaml (100%) diff --git a/README.md b/README.md index 54cb5cb4..1d061532 100644 --- a/README.md +++ b/README.md @@ -726,6 +726,8 @@ The primary benefit of autoscaling on Webhooks compared to the pull driven scali > You can learn the implementation details in [#282](https://github.com/actions-runner-controller/actions-runner-controller/pull/282) +##### Install with Helm + To enable this feature, you first need to install the GitHub webhook server. To install via our Helm chart, _[see the values documentation for all configuration options](https://github.com/actions-runner-controller/actions-runner-controller/blob/master/charts/actions-runner-controller/README.md)_ @@ -839,12 +841,49 @@ alongside your webhook on the Settings -> Webhooks page. Once you were able to confirm that the Webhook server is ready and running from GitHub create or update your `HorizontalRunnerAutoscaler` resources by learning the following configuration examples. +##### Install with Kustomize + +To install this feature using Kustomize, add `github-webhook-server` resources to your `kustomization.yaml` file as in the example below: + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +# You should already have this +- github.com/actions-runner-controller/actions-runner-controller/config//default?ref=v0.22.2 +# Add the below! +- github.com/actions-runner-controller/actions-runner-controller/config//github-webhook-server?ref=v0.22.2 + +Finally, you will have to configure an ingress so that you may configure the webhook in github. An example of such ingress can be find below: + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: actions-runners-webhook-server +spec: + rules: + - http: + paths: + - path: / + backend: + service: + name: github-webhook-server + port: + number: 80 + pathType: Exact + +``` + +##### Examples + - [Example 1: Scale on each `workflow_job` event](#example-1-scale-on-each-workflow_job-event) - [Example 2: Scale up on each `check_run` event](#example-2-scale-up-on-each-check_run-event) - [Example 3: Scale on each `pull_request` event against a given set of branches](#example-3-scale-on-each-pull_request-event-against-a-given-set-of-branches) - [Example 4: Scale on each `push` event](#example-4-scale-on-each-push-event) -##### Example 1: Scale on each `workflow_job` event +###### Example 1: Scale on each `workflow_job` event > This feature requires controller version => [v0.20.0](https://github.com/actions-runner-controller/actions-runner-controller/releases/tag/v0.20.0) @@ -888,7 +927,7 @@ You can configure your GitHub webhook settings to only include `Workflows Job` e Each kind has a `status` of `queued`, `in_progress` and `completed`. With the above configuration, `actions-runner-controller` adds one runner for a `workflow_job` event whose `status` is `queued`. Similarly, it removes one runner for a `workflow_job` event whose `status` is `completed`. The caveat to this to remember is that this scale-down is within the bounds of your `scaleDownDelaySecondsAfterScaleOut` configuration, if this time hasn't passed the scale down will be deferred. -##### Example 2: Scale up on each `check_run` event +###### Example 2: Scale up on each `check_run` event > Note: This should work almost like https://github.com/philips-labs/terraform-aws-github-runner @@ -950,7 +989,7 @@ spec: duration: "5m" ``` -##### Example 3: Scale on each `pull_request` event against a given set of branches +###### Example 3: Scale on each `pull_request` event against a given set of branches To scale up replicas of the runners for `example/myrepo` by 1 for 5 minutes on each `pull_request` against the `main` or `develop` branch you write manifests like the below: diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 4539475e..3b60b64a 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -22,8 +22,6 @@ bases: - ../certmanager # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. #- ../prometheus -# [GH_WEBHOOK_SERVER] To enable the GitHub webhook server, uncomment all sections with 'GH_WEBHOOK_SERVER'. -#- ../github-webhook-server patchesStrategicMerge: # Protect the /metrics endpoint by putting it behind auth. @@ -46,10 +44,6 @@ patchesStrategicMerge: # 'CERTMANAGER' needs to be enabled to use ca injection - webhookcainjection_patch.yaml -# [GH_WEBHOOK_SERVER] To enable the GitHub webhook server, uncomment all sections with 'GH_WEBHOOK_SERVER'. -# Protect the GitHub webhook server metrics endpoint by putting it behind auth. -# - gh-webhook-server-auth-proxy-patch.yaml - # the following config is for teaching kustomize how to do var substitution vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. diff --git a/config/default/gh-webhook-server-auth-proxy-patch.yaml b/config/github-webhook-server/gh-webhook-server-auth-proxy-patch.yaml similarity index 100% rename from config/default/gh-webhook-server-auth-proxy-patch.yaml rename to config/github-webhook-server/gh-webhook-server-auth-proxy-patch.yaml diff --git a/config/github-webhook-server/kustomization.yaml b/config/github-webhook-server/kustomization.yaml index b7c92d42..9c9c947c 100644 --- a/config/github-webhook-server/kustomization.yaml +++ b/config/github-webhook-server/kustomization.yaml @@ -2,11 +2,14 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - - name: controller - newName: summerwind/actions-runner-controller - newTag: latest +- name: controller + newName: summerwind/actions-runner-controller + newTag: latest resources: - - deployment.yaml - - rbac.yaml - - service.yaml +- deployment.yaml +- rbac.yaml +- service.yaml + +patchesStrategicMerge: +- gh-webhook-server-auth-proxy-patch.yaml