visit
At Symbiosis we run a lot of tests on each commit, so we've spent a considerable time making sure they run quickly and can perform complex integration tests.
We will show you how to install it using kubectl
but using helm is just as easy.
kubectl create -f //github.com/actions-runner-controller/actions-runner-controller/releases/download/v0.25.2/actions-runner-controller.yaml
Select the repo (Full control)
permission, and if your runners will run in an organization you need to select the following permissions as well:
kubectl create secret generic controller-manager \
--namespace=actions-runner-system \
--from-literal=github_token=<YOUR PERSONAL ACCESS TOKEN>
name: Run test on PRs
on:
pull_request: {}
jobs:
test:
name: "Run tests"
runs-on: [self-hosted]
steps:
- name: Checkout repo
uses: actions/checkout@master
- name: Run tests
run: yarn test
This workflow triggers commits to pull requests and runs yarn test
. Let’s put it into .github/workflow/test-workflow.yaml
and push the changes to our repository.
Notice the runs-on: [self-hosted]
option that will instruct GitHub to select any of your own self-hosted runners. Don't worry, you can be more specific about which type of runner to use. More on that later.
However, there is the workflowJob
trigger that has none of these drawbacks, but requires us to create an Ingress and configure a GitHub webhook. So this step isn't strictly necessary but we can assure you it's worth the effort.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: actions-runner-controller-github-webhook-server
namespace: actions-runner-system
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
tls:
- hosts:
- your.domain.com
secretName: your-tls-secret-name
rules:
- http:
paths:
- path: /actions-runner-controller-github-webhook-server
pathType: Prefix
backend:
service:
name: actions-runner-controller-github-webhook-server
port:
number: 80
The next step is to define the webhook in GitHub. Go to Settings > Webhooks > Add webhook
in your target repository.
First let's set the payload URL to point to the ingress, for example using the details above: . Set content type to json
and enable the Workflow Jobs permission.
Once it is done you can create the webhook and go to Recent Deliveries to verify that the ingress can be reached successfully.
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: actions-runners
spec:
template:
spec:
repository: myorg/myrepo
---
apiVersion: actions.summerwind.dev/v1alpha1
kind: HorizontalRunnerAutoscaler
metadata:
name: actions-runners
spec:
minReplicas: 0
maxReplicas: 5
scaleTargetRef:
kind: RunnerDeployment
name: actions-runners
scaleUpTriggers:
- githubEvent:
workflowJob: {}
duration: "30m"
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: actions-runners
spec:
template:
spec:
repository: myorg/myrepo
labels:
- my-label
With this label, we're able to select this runner by setting both self-hosted
and my-label
in our workflow:
name: Run test on PRs
on:
pull_request: {}
jobs:
test:
name: "Run tests"
runs-on: [self-hosted, my-label]
steps:
- name: Checkout repo
uses: actions/checkout@master
- name: Run tests
run: yarn test
The below runner will provision a 10Gi PVC that will be shared. Notice that we're using RunnerSet
instead of RunnerDeployment
. This resource functions much like the StatefulSet
in that it will allocate the runner on a node where the volume can be properly mounted.
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: actions-runners
spec:
template:
spec:
repository: myorg/myrepo
volumeMounts:
- mountPath: /runner/work
name: pvc
volumes:
- name: pvc
ephemeral:
volumeClaimTemplate:
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Gi
Lead image generated with stable diffusion.
Also published