Skip to content

Commit 1b4e0c2

Browse files
authored
Modernize terraform config for self-hosted runners (#37127)
* Change terraform config to use new syntax. * Add a section in README about updating terraform config for self-hosted runners.
1 parent afbbf53 commit 1b4e0c2

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

.github/gh-actions-self-hosted-runners/arc/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,26 @@ terraform init -backend-config="bucket=bucket_name"
9696
terraform apply -var-file=environments/environment_name.env
9797
```
9898

99+
# Updating
100+
If you need to update the configuration (e.g. upgrading the github runner image, changing resource settings, etc), follow the steps below:
101+
102+
1. From this directory, login to your gcloud account that you created the bucket with and init terraform. Replace bucket_name with the bucket for storing terraform state, e.g. `beam-arc-state`.
103+
```
104+
gcloud auth login
105+
gcloud auth application-default login
106+
terraform init -backend-config="bucket=bucket_name"
107+
```
108+
109+
2. Terraform plan. Replace environment_name.env with the file under environments, e.g. `beam.env`. Fix config problems if any.
110+
```
111+
terraform plan -var-file=environments/environment_name.env
112+
```
113+
114+
3. Terraform apply. Replace environment_name.env with the file under environments, e.g. `beam.env`.
115+
```
116+
terraform apply -var-file=environments/environment_name.env
117+
```
118+
99119
# Maintanance
100120

101121
- To access the ARC k8s cluster call the `get_kubeconfig_command` terraform output and run the command
102-

.github/gh-actions-self-hosted-runners/arc/helm.tf

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ resource "helm_release" "cert-manager" {
2222
create_namespace = true
2323
repository = "https://charts.jetstack.io"
2424
chart = "cert-manager"
25-
25+
2626
atomic = "true"
2727
timeout = 100
2828

29-
set {
30-
name = "installCRDs"
31-
value = "true"
32-
}
29+
set = [
30+
{
31+
name = "installCRDs"
32+
value = "true"
33+
}
34+
]
3335
depends_on = [ google_container_node_pool.main-actions-runner-pool ]
3436
}
3537

@@ -43,12 +45,11 @@ resource "helm_release" "arc" {
4345
atomic = "true"
4446
timeout = 120
4547

46-
dynamic "set" {
47-
for_each = local.arc_values
48-
content {
49-
name = set.key
50-
value = set.value
48+
set = [
49+
for k, v in local.arc_values : {
50+
name = k
51+
value = v
5152
}
52-
}
53+
]
5354
depends_on = [ helm_release.cert-manager ]
5455
}

.github/gh-actions-self-hosted-runners/arc/provider.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ terraform {
2525
required_providers {
2626
google = {
2727
source = "hashicorp/google"
28-
version = "~> 4.62.0"
28+
version = "~> 6.7.0"
2929
}
3030
kubectl = {
3131
source = "alekc/kubectl"
@@ -40,7 +40,7 @@ provider "google" {
4040
}
4141

4242
provider "helm" {
43-
kubernetes {
43+
kubernetes = {
4444
host = "https://${google_container_cluster.actions-runner-gke.endpoint}"
4545
token = data.google_client_config.provider.access_token
4646
cluster_ca_certificate = base64decode(google_container_cluster.actions-runner-gke.master_auth.0.cluster_ca_certificate)
@@ -66,4 +66,4 @@ provider "github" {
6666
}
6767
owner = var.organization
6868

69-
}
69+
}

0 commit comments

Comments
 (0)