-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from FriedCircuits:feature/github-runners-module
Module to deploy Github self-hosted runners
- Loading branch information
Showing
5 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.0.14 | ||
v0.0.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
resource "kubernetes_namespace" "namespace" { | ||
metadata { | ||
name = var.namespace | ||
} | ||
} | ||
|
||
resource "kubernetes_secret" "github" { | ||
metadata { | ||
name = "github-token" | ||
namespace = var.namespace | ||
} | ||
data = { | ||
github_token = var.github_token | ||
} | ||
type = "Opaque" | ||
} | ||
|
||
module "cert_manager" { | ||
source = "git::[email protected]:friedcircuits/terraform-modules.git//modules/k8s/helm-chart?ref=v0.0.15" | ||
|
||
helm_repo = "https://charts.jetstack.io/" | ||
name = "cert-manager" | ||
chart = "cert-manager" | ||
namespace = var.namespace | ||
create_namespace = false | ||
chart_version = var.cert_chart_verison | ||
|
||
helm_values = { | ||
installCRDs = true | ||
resources = { | ||
limits = { | ||
cpu = "100m" | ||
memory = "128Mi" | ||
} | ||
requests = { | ||
cpu = "100m" | ||
memory = "128Mi" | ||
} | ||
} | ||
} | ||
|
||
depends_on = [ | ||
kubernetes_namespace.namespace, | ||
] | ||
} | ||
|
||
module "github" { | ||
source = "git::[email protected]:friedcircuits/terraform-modules.git//modules/k8s/helm-chart?ref=v0.0.15" | ||
|
||
helm_repo = "https://actions-runner-controller.github.io/actions-runner-controller" | ||
name = "actions-runner-controller" | ||
chart = "actions-runner-controller" | ||
namespace = var.namespace | ||
create_namespace = false | ||
chart_version = var.github_chart_version | ||
|
||
|
||
helm_values = { | ||
authSecret = { | ||
create = false | ||
name = "github-token" | ||
} | ||
resources = { | ||
limits = { | ||
cpu = "100m" | ||
memory = "128Mi" | ||
} | ||
requests = { | ||
cpu = "100m" | ||
memory = "128Mi" | ||
} | ||
} | ||
} | ||
|
||
depends_on = [ | ||
kubernetes_namespace.namespace, | ||
module.cert_manager | ||
] | ||
} | ||
|
||
resource "kubernetes_manifest" "runner" { | ||
for_each = { for repo in var.repos : repo.repo => repo } | ||
manifest = { | ||
apiVersion = "actions.summerwind.dev/v1alpha1" | ||
kind = "RunnerDeployment" | ||
metadata = { | ||
name = "runner-deployment" | ||
namespace = var.namespace | ||
} | ||
spec = { | ||
template = { | ||
spec = { | ||
repository = each.value.repo | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
resource "kubernetes_manifest" "runner_autoscaler" { | ||
for_each = { for repo in var.repos : repo.repo => repo } | ||
manifest = { | ||
apiVersion = "actions.summerwind.dev/v1alpha1" | ||
kind = "HorizontalRunnerAutoscaler" | ||
metadata = { | ||
name = "runner-deployment-autoscaler" | ||
namespace = var.namespace | ||
} | ||
spec = { | ||
scaleTargetRef = { | ||
name = "runner-deployment" | ||
} | ||
minReplicas = each.value.min | ||
maxReplicas = each.value.max | ||
metrics = [{ | ||
type = "TotalNumberOfQueuedAndInProgressWorkflowRuns" | ||
repositoryNames = [ | ||
each.value.repo | ||
] | ||
}] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
variable "namespace" { | ||
description = "Which Kubernetes Namespace to deploy the chart into." | ||
type = string | ||
default = "github" | ||
} | ||
|
||
variable "cert_chart_verison" { | ||
description = "Helm chart version for cert manager. Required for github runners." | ||
type = string | ||
default = "v1.10.0" | ||
} | ||
|
||
variable "github_chart_version" { | ||
description = "The version of the helm chart to use. Note that this is different from the app/container version." | ||
type = string | ||
default = "0.21.0" | ||
} | ||
|
||
variable "github_token" { | ||
description = "Github token with repo access." | ||
type = string | ||
} | ||
|
||
variable "repos" { | ||
description = "List of repos to run runers for." | ||
type = list(object({ | ||
repo = string | ||
min = number | ||
max = number | ||
})) | ||
default = [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = "~> 2.0" | ||
} | ||
helm = { | ||
source = "hashicorp/helm" | ||
version = "~> 2.0" | ||
} | ||
} | ||
} |