/terraform-gha

An Infrastructure as Code (IaC) repository to simplify and secure the use of GitHub Actions Runner on Kubernetes Cluster (Local Cluster, AWS, GCP, Azure)

Primary LanguageHCLMIT LicenseMIT

TERRAFORM GHA (GitHub Actions) Runners

Getting Started

This Terraform project allows user create a Kubernetes Cluster with GitHub Action Runner Controller installed running on any cloud provider (currently support AWS) or locally using Kubernetes-in-Docker (KIND) or Minikube.

It supports two main use cases:

  1. DinD (Docker in Docker): Deploying GitHub Actions Runner using Docker in Docker as the Container Mode.
  2. Kubernetes: Deploying GitHub Actions Runner using Kubernetes as the Container Mode.

The project currently supports running GitHub Actions Runner on the following platforms:

  1. AWS EKS: Deploying GitHub Actions Runner Controller on AWS EKS.
  2. KinD: Deploying GitHub Actions Runner Controller on KinD.
  3. Minikube: Deploying GitHub Actions Runner Controller on Minikube.

⚠️ Before running the Terraform commands, make sure to update the terraform.tfvars file with the right githubConfigUrl and github_token.

Supported Providers

Building for all available cloud and deployment platforms is the main goal of this project. Any user should be able to deploy the same tools and simply switch between cloud providers and runtime environments (Windows or Linux).

Currently a lot of work is been done around EKS, KinD, Minikube

This project will be supporting the following providers:

Deploying to AWS EKS

Requirements for AWS EKS

The following tools are required for deploying GitHub Actions Runner Controller on AWS EKS (tested only on public clusters):

  • docker (up and running)
  • awscli
  • aws secret and access key
  • kubectl
  • eksctl
  • terraform (1.0+)
  • helm (3.0+)
  • make

Using Container Mode as DinD in AWS EKS

The bootstrapping and configuration of cluster can be performed with the command:

cd aws/dind
terraform init
terraform apply -var-file=terraform.tfvars

To update the cluster, there are variables that can be changed, and it is located in the terraform.tfvars.

Using Container Mode as Kubernetes in AWS EKS

The bootstrapping and configuration of cluster can be performed with the command:

cd aws/k8s
terraform init
terraform apply -var-file=terraform.tfvars

To update the cluster, there are variables that can be changed, and it is located in the terraform.tfvars.

Deploying to KinD

Requirements for KinD

The following tools are required for deploying GitHub Actions Runner Controller on KinD:

  • docker (up and running)
  • terraform (1.0+)
  • helm (3.0+)
  • kind
  • make

Using Container Mode as DinD in KinD

The bootstrapping and configuration of cluster can be performed with the command:

cd kind/dind
terraform init
terraform apply -var-file=terraform.tfvars

To update the cluster, there are variables that can be changed, and it is located in the terraform.tfvars.

Using Container Mode as Kubernetes in KinD

The bootstrapping and configuration of cluster can be performed with the command:

cd kind/k8s
terraform init
terraform apply -var-file=terraform.tfvars

To update the cluster, there are variables that can be changed, and it is located in the terraform.tfvars.

Deploying to Minikube

Requirements for Minikube

The following tools are required for deploying GitHub Actions Runner Controller on Minikube:

  • docker (up and running)
  • terraform (1.0+)
  • helm (3.0+)
  • minikube
  • make

Using Container Mode as DinD in Minikube

The bootstrapping and configuration of cluster can be performed with the command:

cd minikube/dind
terraform init
terraform apply -var-file=terraform.tfvars

To update the cluster, there are variables that can be changed, and it is located in the terraform.tfvars.

Using Container Mode as Kubernetes in Minikube

The bootstrapping and configuration of cluster can be performed with the command:

cd minikube/k8s
terraform init
terraform apply -var-file=terraform.tfvars

To update the cluster, there are variables that can be changed, and it is located in the terraform.tfvars.

Alternative: using Makefile

To simplify the execution of the commands, a Makefile is available and this is used to perform the terraform commands seamlessly. All you need to do is to type from the root folder:

make help

To create a GitHub Actions Runner on any of the platform currently supported, type:

make create-<platform>-<container_mode>

To delete the GitHub Actions Runner on any of the platform currently supported, type:

make cleanup-<platform>-<container_mode>