MCPcopy Index your code
hub / github.com/evryfs/github-actions-runner-operator

github.com/evryfs/github-actions-runner-operator @v0.11.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.11.1 ↗ · + Follow
73 symbols 222 edges 11 files 31 documented · 42%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

awesome-runners GitHub go.mod Go version Codacy Badge Go Report Card build codecov GitHub release (latest SemVer) Stargazers over time

github-actions-runner-operator

K8s operator for scheduling GitHub Actions runner pods. self-hosted-runners are a way to host your own runners and customize the environment used to run jobs in your GitHub Actions workflows.

This operator helps you scale and schedule runners on-demand in a declarative way.

Configuration

Authentication modes

The operator communicates with GitHub in order to determine available jobs and execute workflow on runners. Authentication to GitHub is available using the following modes:

  1. As a GitHub app.

This is the preferred mode as it provides enhanced security and increased API quota, and avoids exposure of tokens to runner pods.

Follow the guide for creating GitHub applications. There is no need to define a callback url or webhook secret as they are not used by this integration.

Depending on whether the GitHub application will operate at a repository or organization level, the following permissions must be set:

  • Repository level
    • Actions - Read/Write
    • Administration - Read/Write
  • Organization level
    • Self Hosted Runners - Read/Write

Once the GitHub application has been created, obtain the integration ID and download the private key.

A Github application can only be used by injecting environment variables into the Operator deployment. It is recommended that credentials be stored as Kubernetes secrets and then injected into the operator deployment.

Create a secret called github-runner-app by executing the following command in the namespace containing the operator:

```shell script kubectl create secret generic github-runner-app --from-literal=GITHUB_APP_INTEGRATION_ID= --from-file=GITHUB_APP_PRIVATE_KEY=


Finally define the following on the operator deployment:

```shell script
envFrom:
- secretRef:
    name: github-runner-app
````

2.  Using [Personal Access Tokens (PAT)](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token)

Create a Personal Access token with rights at a repository or organization level.

This PAT can be defined at the operator level or within the custom resource (A PAT defined at the CR level will take precedence)

To make use of a PAT that is declared at a CR level, first create a secret called `actions-runner`

```shell script
kubectl create secret generic actions-runner --from-literal=GH_TOKEN=<token>

Define the tokenRef field on the GithubActionRunner custom resource as shown below:

apiVersion: garo.tietoevry.com/v1alpha1
kind: GithubActionRunner
metadata:
  name: runner-pool
spec:
  tokenRef:
    key: GH_TOKEN
    name: actions-runner

Runner Scope

Runners can be registered either against an individual repository or at an organizational level. The following fields are available on the GithubActionRunner custom resource to specify the repository and/or organization to monitor actions:

  • organization - GitHub user or Organization
  • repository - (Optional) GitHub repository
apiVersion: garo.tietoevry.com/v1alpha1
kind: GithubActionRunner
metadata:
  name: runner-pool
spec:
  # the github org, required
  organization: yourOrg
  # the githb repository
  repository: myrepo

Runner Selection

Arguably the most important field of the GithubActionRunner custom resource is the podTemplateSpec field as it allow you to define the runner that will be managed by the operator. You have the flexibility to define all of the properties that will be needed by the runner including the image, resources and environment variables. During normal operation, the operator will create a token that can be used in your runner to communicate with GitHub. This token is created in a secret called <CR_NAME>-regtoken in the RUNNER_TOKEN key. You should inject this secret into your runner using an environment variable or volume mount.

Installation Methods

The following options are available to install the operator:

Helm Chart

A Helm chart is available from this Helm repository.

Use the following steps to create a namespace and install the operator into the namespace using a Helm chart

```shell script helm repo add evryfs-oss https://evryfs.github.io/helm-charts/ kubectl create namespace github-actions-runner-operator helm install github-actions-runner-operator evryfs-oss/github-actions-runner-operator --namespace github-actions-runner-operator

### Manual

Execute the following commands to deploy the operator using manifests available within this repository.

_Note:_ The [Kustomize](https://kustomize.io/) tool is required

1. Install the CRD's

```shell script
make install
  1. Deploy the Operator

shell script make deploy

OperatorHub

Coming Soon

Examples

A sample of the GithubActionRunner custom resource is found here

development

Operator is based on Operator SDK / Kube builder and written in Go.

Extension points exported contracts — how you extend this code

IRunnerAPI (Interface)
IRunnerAPI is a service towards GitHubs runners [2 implementers]
controllers/githubapi/runnerapi.go

Core symbols most depended-on inside this repo

manageOutcome
called by 10
controllers/githubactionrunner_controller.go
numRunners
called by 9
controllers/podrunner_types.go
from
called by 4
controllers/podrunner_types.go
tokenForRef
called by 3
controllers/githubactionrunner_controller.go
getClient
called by 3
controllers/githubapi/runnerapi.go
numBusy
called by 2
controllers/podrunner_types.go
numPods
called by 2
controllers/podrunner_types.go
inSync
called by 2
controllers/podrunner_types.go

Shape

Method 49
Function 13
Struct 9
Interface 1
TypeAlias 1

Languages

Go100%

Modules by API surface

controllers/githubactionrunner_controller.go19 symbols
controllers/podrunner_types.go13 symbols
controllers/githubapi/runnerapi.go10 symbols
api/v1alpha1/zz_generated.deepcopy.go10 symbols
api/v1alpha1/githubactionrunner_types.go9 symbols
controllers/githubactionrunner_controller_test.go5 symbols
main.go2 symbols
controllers/podutil.go2 symbols
controllers/podrunner_types_test.go2 symbols
controllers/suite_test.go1 symbols

For agents

$ claude mcp add github-actions-runner-operator \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact