Terraform module with GitHub Actions Runner Controller (ARC) deployed via Helm chart. The module is designed to deploy the GitHub Action Runner scale set Controller and a flexible number of GitHub Actions Runner scale sets, including upscale from 0 and downscale to 0.
Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:
shellterraform login solutions.corewide.com
Initialize mandatory providers:
Copy and paste into your Terraform configuration and insert the variables:
hclmodule "tf_k8s_github_actions_runner" {
source = "solutions.corewide.com/kubernetes/tf-k8s-github-actions-runner/helm"
version = "~> 5.2.0"
# specify module inputs here or try one of the examples below
...
}
Initialize the setup:
shellterraform init
Corewide DevOps team strictly follows Semantic Versioning
Specification
to
provide our clients with products that have predictable upgrades between versions. We
recommend
pinning
patch versions of our modules using pessimistic
constraint operator (~>) to prevent breaking changes during upgrades.
To get new features during the upgrades (without breaking compatibility), use
~> 5.2 and run
terraform init -upgrade
For the safest setup, use strict pinning with version = "5.2.0"
|
Module
30% off
|
$910
|
| TOTAL | $910 |
Terraform module with GitHub Actions Runner Controller (ARC) deployed via Helm chart. The module is designed to deploy the GitHub Action Runner scale set Controller and a flexible number of GitHub Actions Runner scale sets, including upscale from 0 and downscale to 0.
All notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.13.0 to 0.14.2watch_single_namespace parameter for the controller variable (disabled by default)BREAKING CHANGE: GitHub Actions Runner Controller and runner are replaced with scale sets in place of legacy mode utilized in previous versions. Upgrade requires full setup re-creation, see the Upgrade Notes section
assign_cluster_role parameter for the controller variable (enabled by default)name_prefix and runner namesv3.1v3.0v1.9controller and github_runners variables in accordance with the new Helm charts
tf-k8s-crd module dependency, RunnerDeployment, and HorizontalRunnerAutoscaler CRs management
github_token variable(Last version compatible with Helm and Kubernetes Terraform providers v2.0)
BREAKING CHANGE: now GitHub Runner and runner autoscaler Kubernetes manifests management is covered by tf-k8s-crd module, which is incompatible with previous versions. Upgrade from an older version is possible with manual changes, see Upgrade Notes section
tf-k8s-crd module dependencyBREAKING CHANGE: now all kubernetes provider resources use versioned resources which aren't compatible with previous version
BREAKING CHANGE: now all Kubernetes manifest resources are managed by kubectl provider instead of kubernetes which are't compatible with previous version
kubectl provider dependencykubernetes_manifest resource with kubectl_manifestgithub_runners[*].organization and github_runners[*].repo variablesFirst stable version
v1.x to v2.xNow all Kubernetes manifest resources are managed by kubectl provider instead of kubernetes. This approach is used to avoid cases when while deploying the module and the Kubernetes cluster at the same time, Kubernetes manifests are failing. The simplest, non-destructive way to upgrade is to remove the old kubernetes provider resource from state and import this resource as a kubectl provider resource, like so:
bash# Re-import runner manifest
terraform state rm module.github_runner.kubernetes_manifest.runner[0]
terraform import module.github_runner.kubectl_manifest.runner[0] actions.summerwind.dev/v1alpha1//RunnerDeployment//k8s-runners-0//github-runner-controller
# Re-import autoscaler manifest
terraform state rm module.github_runner.kubernetes_manifest.autoscaler[0]
terraform import module.github_runner.kubectl_manifest.autoscaler[0] actions.summerwind.dev/v1alpha1//HorizontalRunnerAutoscaler//runner-deployment-autoscaler-0//github-runner-controller
v2.x to v3.xNow all kubernetes provider resources use versioned resources. According to kubernetes provider's suggestions the simplest, non-destructive way to do this is to remove the old resource from state and import this resource as a version one, like so:
bash# If Kubernetes namespace was managed by the module, it must be re-imported
terraform state rm module.github_runner.kubernetes_namespace.github_runner[0]
terraform import module.github_runner.kubernetes_namespace_v1.github_runner[0] github-runner-controller
v3.x to v4.xThe module from v4.0 has switched from "plain" kubectl_manifest resources for GitHub Runner and runner autoscaler management to the module for CRD (Custom Resource Definitions) management. This results in a resource reference mismatch.
The CRD module uses alekc/kubectl provider instead of gavinbunney/kubectl. It means that the provider for all existing resources within your state must be updated and the following steps must be performed:
required_providers sections in your main code to reflect the usage of alekc/kubectl bashterraform state replace-provider gavinbunney/kubectl alekc/kubectl
bashterraform init
Then, TF state references of GitHub Runner and runner autostaler can be updated like so:
bashterraform state mv module.runner_controller.kubectl_manifest.runner[0] module.runner_controller.module.runner[0].kubectl_manifest.crd
terraform state mv module.runner_controller.kubectl_manifest.autoscaler[0] module.runner_controller.module.runner[0].data.kubernetes_resource.crd
v4.x to v5.xModule from v5.0 has changed the runners declaration from a list of objects to a map of objects and now requires a token for each repository.
hclmodule "runner_controller" {
...
# from v4.x format
github_token = "ghp_token"
github_runners = [
{
repo = "repo-owner/repo-name"
},
]
# to v5.0 format
...
github_runners = {
repo-runner = {
github_config_url = "https://github.com/repo-owner/repo-name"
github_token = "ghp_token"
}
}
}
Module from v5.0 has changed Helm and Kubernetes Terraform providers versions, which aren't compatible with an old version. After the module version is upgraded, re-init the module to upgrade the provider versions.
Upgrade the following Terraform provider versions on the project level:
* hashicorp/kubernetes to ~> 3.0
* hashicorp/helm to ~> 3.1
hclterraform {
required_providers {
helm = {
source = "hashicorp/helm"
version = "~> 3.1"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 3.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
If set, rewrite custom values passed to the cert-manager Helm Chart as nested maps following the below example.
Before:
hclmodule "runner_controller" {
...
controller = {
custom_values = [
{
name = "fullnameOverride"
value = "bar"
},
{
name = "image.pullPolicy"
value = "Always"
},
]
}
...
}
After:
hclmodule "runner_controller" {
...
controller = {
custom_values = {
fullnameOverride = "bar"
image = {
pullPolicy = "Always"
}
}
}
...
}
node_selector input doesn't require anymore escaping of the dot (.) symbol: hclmodule "runner_controller" {
...
# from v1.x format
controller = {
node_selector = {
"node\\.kubernetes\\.io/instance-type" = "m5.large"
}
}
# to v2.0 format
controller = {
node_selector = {
"node.kubernetes.io/instance-type" = "m5.large"
}
}
...
}
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
Deploy the repository runner with mandatory values only:
hclmodule "runner_controller" {
source = "solutions.corewide.com/kubernetes/tf-k8s-github-actions-runner/helm"
version = "~> 5.2"
github_runners = {
my-repo-runner = {
github_config_url = "https://github.com/repo-owner/repo-name"
github_token = "ghp_token"
}
}
}
Deploy the organization runner with mandatory values only:
hclmodule "runner_controller" {
source = "solutions.corewide.com/kubernetes/tf-k8s-github-actions-runner/helm"
version = "~> 5.0"
github_runners = {
my-organization-runner = {
github_config_url = "https://github.com/my-organization"
github_token = "ghp_token"
}
}
}
Deploy the repository runner with the custom values, name prefix, controller version, node selectors, replicas, service account name, and controller restricted to only watch a single namespace:
hclmodule "runner_controller" {
source = "solutions.corewide.com/kubernetes/tf-k8s-github-actions-runner/helm"
version = "~> 5.2"
name_prefix = "foo"
controller = {
replicas = 2
app_version = "0.14.2"
chart_version = "0.14.2"
service_account_name = "bar"
watch_single_namespace = true
node_selector = {
"cluster/node-pool-name" = "biz"
}
custom_values = {
fullnameOverride = "foo"
}
}
github_runners = {
my-repo-runner = {
github_config_url = "https://github.com/repo-owner/repo-name"
github_token = "ghp_token"
min_replicas = 0
max_replicas = 3
node_selector = {
"cluster/node-pool-name" = "biz-spot"
}
listener_node_selector = {
"cluster/node-pool-name" = "biz"
}
}
}
}
Pipeline example:
yaml---
name: pipeline
on:
push:
branches: [ my-branch ]
jobs:
build:
name: Build Docker
runs-on: my-scale-set
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build Docker
run: |
docker build -t my-docker-image .
| Variable | Description | Type | Default | Required | Sensitive |
|---|---|---|---|---|---|
github_runners[<key>] |
Name of the runner. Common length of runner name and var.name_prefix with dash must have up to 45 characters and can contain only (\"a-z\", \"0-9\" and \"-\")" |
string |
yes | no | |
name_prefix |
Naming prefix for all the resources created by the module. Must have up to 36 characters long, and can contain only (\"a-z\", \"0-9\" and \"-\") | string |
yes | no | |
controller |
Set of parameters for the GitHub Actions Runner Controller (ARC) | object |
{} |
no | no |
controller.app_version |
ARC application version | string |
0.14.2 |
no | no |
controller.assign_cluster_role |
Whether to bind a cluster role to the controller service account | bool |
true |
no | no |
controller.chart_version |
ARC Helm chart version | string |
0.14.2 |
no | no |
controller.cluster_role_name |
Cluster role name to bind to the controller service account | string |
cluster-admin |
no | no |
controller.custom_values |
Custom values to pass to the scale set controller Helm chart | any |
{} |
no | no |
controller.image_pull_secrets |
Secrets to use for pulling images by runners | list(string) |
[] |
no | no |
controller.labels |
Custom Kubernetes labels for ARC resources | map(string) |
{} |
no | no |
controller.node_selector |
Node selector to place ARC resources in | map(string) |
{} |
no | no |
controller.replicas |
Number of ARC replicas | number |
1 |
no | no |
controller.service_account_name |
Service Account name to create for runners and controller | string |
github-controller |
no | no |
controller.watch_single_namespace |
Whether the controller must watch only a single namespace for the runner-related custom resources | bool |
false |
no | no |
create_namespace |
Indicates creation of dedicated namespace for GitHub ARC resources | bool |
true |
no | no |
github_runners |
Set of parameters for the GitHub Runners | map(object) |
{} |
no | no |
github_runners[<key>].annotations |
Annotations to be set to the scale set resources | map(string) |
{} |
no | no |
github_runners[<key>].container_mode |
GitHub Runner container mode to use. Possible values are: dind, kubernetes, kubernetes-novolume, and null. If set to kubernetes/null the runner configuration should be applied to the template via custom_values |
string |
dind |
no | no |
github_runners[<key>].custom_values |
Custom values to pass to the scale set Helm chart | any |
{} |
no | no |
github_runners[<key>].github_config_url |
GitHub repository or organization URL for which you want to configure runners | string |
yes | no | |
github_runners[<key>].github_token |
GitHub private access token (PAT classic) suitable for personal API. PAT should be granted full access to repo and admin scopes |
string |
yes | no | |
github_runners[<key>].listener_node_selector |
Node selector to place listener resources in | map(string) |
{} |
no | no |
github_runners[<key>].max_replicas |
Max number of GitHub Runner replicas | number |
1 |
no | no |
github_runners[<key>].min_replicas |
Min number of GitHub Runner replicas | number |
1 |
no | no |
github_runners[<key>].node_selector |
Node selector to place runner resources in | map(string) |
{} |
no | no |
namespace |
The namespace to install the GitHub ARC into | string |
github-runner-controller |
no | no |
| Dependency | Version | Kind |
|---|---|---|
terraform |
>= 1.9 |
CLI |
hashicorp/helm |
~> 3.1 |
provider |
hashicorp/kubernetes |
~> 3.0 |
provider |
These components are included as is under the terms of their corresponding licenses.
| Component | License |
|---|---|
| GitHub Actions Runner Controller (ARC) | Apache-2.0 |