Sub topic 5
Giving ARC access to GitHub
This chapter covers how Actions Runner Controller (ARC) proves its identity to GitHub, and how to store the credentials in Kubernetes. It assumes you can use kubectl, you know what a Kubernetes secret is, and you have read the previous chapter on ARC's architecture.
Why ARC needs credentials
The listener pod in each runner scale set polls GitHub for queued jobs. The controller also asks GitHub for registration tokens so new runner pods can join. Both actions need an authenticated identity with permission to manage runners at the scope you chose in githubConfigUrl: a repository, an organization, or an enterprise.
ARC supports two ways to authenticate:
- A personal access token (PAT).
- A GitHub App.
Option 1: personal access token
A PAT is the quickest way to start. Create a classic token with the scope that matches your target:
| Scope of `githubConfigUrl` | Classic PAT scope |
|---|---|
| Repository | `repo` |
| Organization | `admin:org` (plus `repo` for private repositories) |
| Enterprise | `manage_runners:enterprise` |
Store the token in a secret in the runner namespace. The key must be named github_token.
kubectl create namespace arc-runners
kubectl create secret generic pre-defined-secret \
--namespace arc-runners \
--from-literal=github_token='<YOUR_PAT>'Creating the secret first keeps the token out of the Helm command line and out of your shell history of helm install arguments. You then reference it in the values file:
githubConfigUrl: "https://github.com/<your-org>/<your-repo>"
githubConfigSecret: pre-defined-secretA PAT belongs to a person. If that person leaves the organization or the token expires, ARC stops working.
Option 2: GitHub App
A GitHub App is the better choice for production. It is not tied to a user, its permissions are narrower, and it has higher API rate limits. You need three values:
- The App ID.
- The installation ID.
- A private key generated for the App.
The App needs repository permission "Administration: read and write" for repository-level scale sets. For organization-level scale sets it needs organization permission "Self-hosted runners: read and write". Install the App on the target account first.
The secret uses different keys than the PAT:
kubectl create secret generic pre-defined-secret \
--namespace arc-runners \
--from-literal=github_app_id='<APP_ID>' \
--from-literal=github_app_installation_id='<INSTALLATION_ID>' \
--from-file=github_app_private_key=./private-key.pemThe githubConfigSecret value in your values file stays the same. ARC detects which kind of credential the secret holds from its keys.
Common errors
- Wrong key names.
github_tokenfor a PAT, or the threegithub_app_*keys for an App. Any other names are ignored, and authentication fails. - Insufficient scope. The scale set installs, but the listener logs a 403 or 404 from GitHub. Compare your token or App permissions to the table above.
- Mismatched installation. The App is not installed on the organization or repository named in
githubConfigUrl. - Rotated credentials. Updating the secret does not always take effect in a running listener. Restart the listener pod, or reinstall the scale set, after changing the secret.
Exercise
You installed a runner scale set with a GitHub App, but the listener cannot authenticate. The secret has the keys appid, installationid, and private_key. What is wrong, and where must the corrected secret live?
Show answer
The keys have the wrong names. ARC expects githubappid, githubappinstallationid, and githubappprivatekey. The secret must be in the runner scale set's namespace (arc-runners in this tutorial) and be referenced by githubConfigSecret.