Skip to content

Commit 1599b16

Browse files
authored
Upstream EKS Action Runner Controller (cloudposse/terraform-aws-components#528)
1 parent 1907eda commit 1599b16

File tree

6 files changed

+48
-5
lines changed

6 files changed

+48
-5
lines changed

src/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ After the webhook is created, select "edit" for the webhook and go to the "Recen
165165
(of a "ping" event) with a green check mark. If not, verify all the settings and consult
166166
the logs of the `actions-runner-controller-github-webhook-server` pod.
167167

168-
Useful Reference
169168

170169
### Updating CRDs
171170

@@ -180,6 +179,9 @@ If new CRDs are needed, install them manually via a command like
180179
kubectl create -f https://raw.githubusercontent.com/actions-runner-controller/actions-runner-controller/master/charts/actions-runner-controller/crds/actions.summerwind.dev_horizontalrunnerautoscalers.yaml
181180
```
182181

182+
183+
### Useful Reference
184+
183185
Consult [actions-runner-controller](https://github.com/actions-runner-controller/actions-runner-controller) documentation for further details.
184186

185187
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -264,7 +266,7 @@ Consult [actions-runner-controller](https://github.com/actions-runner-controller
264266
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
265267
| <a name="input_region"></a> [region](#input\_region) | AWS Region. | `string` | n/a | yes |
266268
| <a name="input_resources"></a> [resources](#input\_resources) | The cpu and memory of the deployment's limits and requests. | <pre>object({<br> limits = object({<br> cpu = string<br> memory = string<br> })<br> requests = object({<br> cpu = string<br> memory = string<br> })<br> })</pre> | n/a | yes |
267-
| <a name="input_runners"></a> [runners](#input\_runners) | Map of Action Runner configurations, with the key being the name of the runner. Please note that the name must be in<br>kebab-case.<br><br>For example:<pre>hcl<br>organization_runner = {<br> type = "organization" # can be either 'organization' or 'repository'<br> dind_enabled: false # A Docker sidecar container will be deployed<br> image: summerwind/actions-runner # If dind_enabled=true, set this to 'summerwind/actions-runner-dind'<br> scope = "ACME" # org name for Organization runners, repo name for Repository runners<br> scale_down_delay_seconds = 300<br> min_replicas = 1<br> max_replicas = 5<br> busy_metrics = {<br> scale_up_threshold = 0.75<br> scale_down_threshold = 0.25<br> scale_up_factor = 2<br> scale_down_factor = 0.5<br> }<br> labels = [<br> "Ubuntu",<br> "core-automation",<br> ]<br>}</pre> | <pre>map(object({<br> type = string<br> scope = string<br> image = optional(string, "")<br> dind_enabled = bool<br> scale_down_delay_seconds = number<br> min_replicas = number<br> max_replicas = number<br> busy_metrics = optional(object({<br> scale_up_threshold = string<br> scale_down_threshold = string<br> scale_up_adjustment = optional(string)<br> scale_down_adjustment = optional(string)<br> scale_up_factor = optional(string)<br> scale_down_factor = optional(string)<br> }))<br> webhook_driven_scaling_enabled = bool<br> pull_driven_scaling_enabled = bool<br> labels = list(string)<br> storage = optional(string, "")<br> resources = object({<br> limits = object({<br> cpu = string<br> memory = string<br> ephemeral_storage = optional(string, "")<br> })<br> requests = object({<br> cpu = string<br> memory = string<br> })<br> })<br> }))</pre> | n/a | yes |
269+
| <a name="input_runners"></a> [runners](#input\_runners) | Map of Action Runner configurations, with the key being the name of the runner. Please note that the name must be in<br>kebab-case.<br><br>For example:<pre>hcl<br>organization_runner = {<br> type = "organization" # can be either 'organization' or 'repository'<br> dind_enabled: false # A Docker sidecar container will be deployed<br> image: summerwind/actions-runner # If dind_enabled=true, set this to 'summerwind/actions-runner-dind'<br> scope = "ACME" # org name for Organization runners, repo name for Repository runners<br> scale_down_delay_seconds = 300<br> min_replicas = 1<br> max_replicas = 5<br> busy_metrics = {<br> scale_up_threshold = 0.75<br> scale_down_threshold = 0.25<br> scale_up_factor = 2<br> scale_down_factor = 0.5<br> }<br> labels = [<br> "Ubuntu",<br> "core-automation",<br> ]<br>}</pre> | <pre>map(object({<br> type = string<br> scope = string<br> image = optional(string, "")<br> dind_enabled = bool<br> scale_down_delay_seconds = number<br> min_replicas = number<br> max_replicas = number<br> busy_metrics = optional(object({<br> scale_up_threshold = string<br> scale_down_threshold = string<br> scale_up_adjustment = optional(string)<br> scale_down_adjustment = optional(string)<br> scale_up_factor = optional(string)<br> scale_down_factor = optional(string)<br> }))<br> webhook_driven_scaling_enabled = bool<br> webhook_startup_timeout = optional(string, null)<br> pull_driven_scaling_enabled = bool<br> labels = list(string)<br> storage = optional(string, false)<br> pvc_enabled = optional(string, false)<br> resources = object({<br> limits = object({<br> cpu = string<br> memory = string<br> ephemeral_storage = optional(string, false)<br> })<br> requests = object({<br> cpu = string<br> memory = string<br> })<br> })<br> }))</pre> | n/a | yes |
268270
| <a name="input_s3_bucket_arns"></a> [s3\_bucket\_arns](#input\_s3\_bucket\_arns) | List of ARNs of S3 Buckets to which the runners will have read-write access to. | `list(string)` | `[]` | no |
269271
| <a name="input_ssm_github_secret_path"></a> [ssm\_github\_secret\_path](#input\_ssm\_github\_secret\_path) | The path in SSM to the GitHub app private key file contents or GitHub PAT token. | `string` | `""` | no |
270272
| <a name="input_ssm_github_webhook_secret_token_path"></a> [ssm\_github\_webhook\_secret\_token\_path](#input\_ssm\_github\_webhook\_secret\_token\_path) | The path in SSM to the GitHub Webhook Secret token. | `string` | `""` | no |

src/charts/actions-runner/templates/horizontalrunnerautoscaler.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ spec:
3131
- githubEvent:
3232
workflowJob: {}
3333
amount: 1
34-
duration: "{{ .Values.scale_down_delay_seconds }}s"
34+
duration: "{{ .Values.webhook_startup_timeout }}"
3535
{{- end }}

src/charts/actions-runner/templates/runnerdeployment.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
{{- if .Values.pvc_enabled }}
2+
---
3+
# Persistent Volumes can be used for image caching
4+
apiVersion: v1
5+
kind: PersistentVolumeClaim
6+
metadata:
7+
name: {{ .Values.release_name }}
8+
spec:
9+
accessModes:
10+
- ReadWriteMany
11+
# StorageClassName comes from efs-controller and must be deployed first.
12+
storageClassName: efs-sc
13+
resources:
14+
requests:
15+
# EFS is not actually storage constrained, but this storage request is
16+
# required. 100Gi is a ballpark for how much we initially request, but this
17+
# may grow. We are responsible for docker pruning this periodically to
18+
# save space.
19+
storage: 100Gi
20+
{{- end }}
21+
---
122
apiVersion: actions.summerwind.dev/v1alpha1
223
kind: RunnerDeployment
324
metadata:
@@ -56,7 +77,15 @@ spec:
5677
dockerVolumeMounts:
5778
- mountPath: /var/lib/docker
5879
name: docker-volume
80+
{{- end }}
81+
{{- if .Values.pvc_enabled }}
82+
volumeMounts:
83+
- mountPath: /home/runner/work/shared
84+
name: shared-volume
85+
{{- end }}
86+
{{- if or (and .Values.dind_enabled .Values.storage) (.Values.pvc_enabled) }}
5987
volumes:
88+
{{- if and .Values.dind_enabled .Values.storage }}
6089
- name: docker-volume
6190
ephemeral:
6291
volumeClaimTemplate:
@@ -66,3 +95,9 @@ spec:
6695
requests:
6796
storage: {{ .Values.storage }}
6897
{{- end }}
98+
{{- if .Values.pvc_enabled }}
99+
- name: shared-volume
100+
persistentVolumeClaim:
101+
claimName: {{ .Values.release_name }}
102+
{{- end }}
103+
{{- end }}

src/charts/actions-runner/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ resources:
2020
cpu: 0.5
2121
memory: 1Gi
2222
storage: "10Gi"
23+
pvc_enabled: false
2324
webhook_driven_scaling_enabled: false
25+
webhook_startup_timeout: "30m"
2426
pull_driven_scaling_enabled: false
2527
labels:
2628
- "Ubuntu"

src/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ module "actions_runner" {
216216
min_replicas = each.value.min_replicas
217217
max_replicas = each.value.max_replicas
218218
webhook_driven_scaling_enabled = each.value.webhook_driven_scaling_enabled
219+
webhook_startup_timeout = try(each.value.webhook_startup_timeout, "${each.value.scale_down_delay_seconds}s") # if webhook_startup_timeout isnt defined, use scale_down_delay_seconds
219220
pull_driven_scaling_enabled = each.value.pull_driven_scaling_enabled
221+
pvc_enabled = each.value.pvc_enabled
220222
}),
221223
local.busy_metrics_filtered[each.key] == null ? "" : yamlencode(local.busy_metrics_filtered[each.key]),
222224
])

src/variables.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,16 @@ variable "runners" {
178178
scale_down_factor = optional(string)
179179
}))
180180
webhook_driven_scaling_enabled = bool
181+
webhook_startup_timeout = optional(string, null)
181182
pull_driven_scaling_enabled = bool
182183
labels = list(string)
183-
storage = optional(string, "")
184+
storage = optional(string, false)
185+
pvc_enabled = optional(string, false)
184186
resources = object({
185187
limits = object({
186188
cpu = string
187189
memory = string
188-
ephemeral_storage = optional(string, "")
190+
ephemeral_storage = optional(string, false)
189191
})
190192
requests = object({
191193
cpu = string

0 commit comments

Comments
 (0)