Go to file
Moto Ishizawa cac199f16e
Merge pull request #20 from summerwind/github-apps-support
Add support of GitHub Apps authentication
2020-03-28 22:18:36 +09:00
.github/workflows feat: RunnerSets 2020-02-24 10:32:44 +09:00
api/v1alpha1 Add variants of PodTemplate spec fields into the Runner spec (#7) 2020-03-20 22:50:50 +09:00
config Add environment variables and volumes for GitHub Apps credentials 2020-03-26 23:12:54 +09:00
controllers Add variants of PodTemplate spec fields into the Runner spec (#7) 2020-03-20 22:50:50 +09:00
hack Initial commit 2020-01-28 15:03:23 +09:00
runner Update runner to v2.168.0 2020-03-25 17:10:25 +09:00
.gitignore Update .gitignore 2020-02-03 10:52:07 +09:00
Dockerfile Initial commit 2020-01-28 15:03:23 +09:00
LICENSE Add LICENSE 2020-01-30 20:12:12 +09:00
Makefile Set container image version properly in the release task 2020-02-03 16:55:38 +09:00
PROJECT Update custom resource information 2020-03-15 22:07:27 +09:00
README.md Clarify instructions for getting a token (#18) 2020-03-25 21:22:19 +09:00
go.mod Add variants of PodTemplate spec fields into the Runner spec (#7) 2020-03-20 22:50:50 +09:00
go.sum Add variants of PodTemplate spec fields into the Runner spec (#7) 2020-03-20 22:50:50 +09:00
main.go Add flags for GitHub Apps credentials 2020-03-26 23:12:11 +09:00

README.md

actions-runner-controller

This controller operates self-hosted runners for GitHub Actions on your Kubernetes cluster.

Motivation

GitHub Actions is very useful as a tool for automating development. GitHub Actions job is run in the cloud by default, but you may want to run your jobs in your environment. Self-hosted runner can be used for such use cases, but requires the provision of a virtual machine instance and configuration. If you already have a Kubernetes cluster, you'll want to run the self-hosted runner on top of it.

actions-runner-controller makes that possible. Just create a Runner resource on your Kubernetes, and it will run and operate the self-hosted runner of the specified repository. Combined with Kubernetes RBAC, you can also build simple Self-hosted runners as a Service.

Installation

First, install actions-runner-controller with a manifest file. This will create a actions-runner-system namespace in your Kubernetes and deploy the required resources.

$ kubectl apply -f https://github.com/summerwind/actions-runner-controller/releases/latest/download/actions-runner-controller.yaml

Next, from an account that has admin privileges for the repository, create a personal access token with repo scope. This token is used to register a self-hosted runner by actions-runner-controller.

Then, create a Kubernetes secret, replacing ${GITHUB_TOKEN} with your token.

$ kubectl create secret generic controller-manager --from-literal=github_token=${GITHUB_TOKEN} -n actions-runner-system

Usage

There's generally two ways to use this controller:

  • Manage runners one by one with Runner
  • Manage a set of runners with RunnerDeployment

Runners

To launch a single Self-hosted runner, you need to create a manifest file includes Runner resource as follows. This example launches a self-hosted runner with name example-runner for the summerwind/actions-runner-controller repository.

# runner.yaml
apiVersion: actions.summerwind.dev/v1alpha1
kind: Runner
metadata:
  name: example-runner
spec:
  repository: summerwind/actions-runner-controller
  env: []

Apply the created manifest file to your Kubernetes.

$ kubectl apply -f runner.yaml
runner.actions.summerwind.dev/example-runner created

You can see that the Runner resource has been created.

$ kubectl get runners
NAME             REPOSITORY                             STATUS
example-runner   summerwind/actions-runner-controller   Running

You can also see that the runner pod has been running.

$ kubectl get pods
NAME           READY   STATUS    RESTARTS   AGE
example-runner 2/2     Running   0          1m

The runner you created has been registered to your repository.

Actions tab in your repository settings

Now your can use your self-hosted runner. See the official documentation on how to run a job with it.

RunnerDeployments

There's also RunnerReplicaSet and RunnerDeployment that corresponds to ReplicaSet and Deployment but for Runner.

You usually need only RunnerDeployment rather than RunnerReplicaSet as the former is for managing the latter.

# runnerdeployment.yaml
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: example-runnerdeploy
spec:
  replicas: 2
  template:
    spec:
      repository: mumoshu/actions-runner-controller-ci
      env: []

Apply the manifest file to your cluster:

$ kubectl apply -f runner.yaml
runnerdeployment.actions.summerwind.dev/example-runnerdeploy created

You can see that 2 runners has been created as specified by replicas: 2:

$ kubectl get runners
NAME             REPOSITORY                             STATUS
NAME                             REPOSITORY                             STATUS
example-runnerdeploy2475h595fr   mumoshu/actions-runner-controller-ci   Running
example-runnerdeploy2475ht2qbr   mumoshu/actions-runner-controller-ci   Running