Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runner): Replace patch by install ICU package for ARM runners #1624

Merged
merged 8 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
fail-fast: false
matrix:
terraform: [0.14.3, 0.15.5, 1.0.8]
example: ["default", "ubuntu", "prebuilt"]
example: ["default", "ubuntu", "prebuilt", "arm64", "ephemeral", "windows"]
defaults:
run:
working-directory: examples/${{ matrix.example }}
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ To be able to support a number of use-cases the module has quite a lot configura

#### ARM64 support via Graviton/Graviton2 instance-types

When using the default example or top-level module, specifying an `instance_type` that matches a Graviton/Graviton 2 (ARM64) architecture (e.g. a1, t4g or any 6th-gen `g` or `gd` type), the sub-modules will be automatically configured to provision with ARM64 AMIs and leverage GitHub's ARM64 action runner. See below for more details.
When using the default example or top-level module, specifying `instance_types` that match a Graviton/Graviton 2 (ARM64) architecture (e.g. a1, t4g or any 6th-gen `g` or `gd` type), you must also specify `runner_architecture = "arm64"` and the sub-modules will be automatically configured to provision with ARM64 AMIs and leverage GitHub's ARM64 action runner. See below for more details.

## Usages

Expand Down Expand Up @@ -184,8 +184,6 @@ module "github-runner" {
}
```

**ARM64** support: Specify an `a1`, `t4g` or `*6g*` (6th-gen Graviton2) instance type to stand up an ARM64 runner, otherwise the default is x86_64.

Run terraform by using the following commands

```bash
Expand Down Expand Up @@ -322,9 +320,10 @@ This module also allows you to run agents from a prebuilt AMI to gain faster sta
Examples are located in the [examples](./examples) directory. The following examples are provided:

- _[Default](examples/default/README.md)_: The default example of the module
- _[ARM64](examples/arm64/README.md)_: Example usage with ARM64 architecture
- _[Ubuntu](examples/ubuntu/README.md)_: Example usage of creating a runner using Ubuntu AMIs.
- _[Windows](examples/windows/README.md)_: Example usage of creating a runner using Windows as the OS.
- _[Ephemeral](examples/ephemeral/README.md) : Example usages of ephemeral runners based on the default example.
- _[Ephemeral](examples/ephemeral/README.md)_: Example usages of ephemeral runners based on the default example.
- _[Prebuilt Images](examples/prebuilt/README.md)_: Example usages of deploying runners with a custom prebuilt image.
- _[Permissions boundary](examples/permissions-boundary/README.md)_: Example usages of permissions boundaries.

Expand All @@ -345,7 +344,7 @@ The following sub modules are optional and are provided as example or utility:

### ARM64 configuration for submodules

When using the top level module configure `runner_architecture = arm64` and insure the list of `instance_types` matches. When not using the top-level ensure the bot properties are set on the submodules.
When using the top level module configure `runner_architecture = "arm64"` and ensure the list of `instance_types` matches. When not using the top-level, ensure these properties are set on the submodules.

## Debugging

Expand All @@ -354,7 +353,7 @@ In case the setup does not work as intended follow the trace of events:
- In the GitHub App configuration, the Advanced page displays all webhook events that were sent.
- In AWS CloudWatch, every lambda has a log group. Look at the logs of the `webhook` and `scale-up` lambdas.
- In AWS SQS you can see messages available or in flight.
- Once an EC2 instance is running, you can connect to it in the EC2 user interface using Session Manager. Check the user data script using `cat /var/log/user-data.log`. By default several log files of the instances are streamed to AWS CloudWatch, look for a log group named `<environment>/runners`. In the log group you should see at least the log streams for the user data installation and runner agent.
- Once an EC2 instance is running, you can connect to it in the EC2 user interface using Session Manager (use `enable_ssm_on_runners = true`). Check the user data script using `cat /var/log/user-data.log`. By default several log files of the instances are streamed to AWS CloudWatch, look for a log group named `<environment>/runners`. In the log group you should see at least the log streams for the user data installation and runner agent.
- Registered instances should show up in the Settings - Actions page of the repository or organization (depending on the installation mode).

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
57 changes: 57 additions & 0 deletions examples/arm64/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions examples/arm64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Action runners deployment with ARM64 architecture

This module shows how to create GitHub action runners using AWS Graviton instances which have ARM64 architecture. Lambda release will be downloaded from GitHub.

## Usages

Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case.

> Ensure you have set the version in `lambdas-download/main.tf` for running the example. The version needs to be set to a GitHub release version, see https://github.com/philips-labs/terraform-aws-github-runner/releases
```bash
cd lambdas-download
terraform init
terraform apply
cd ..
```

Before running Terraform, ensure the GitHub app is configured. See the [configuration details](../../README.md#usages) for more details.

```bash
terraform init
terraform apply
```

You can receive the webhook details by running:

```bash
terraform output -raw webhook_secret
```

Be-aware some shells will print some end of line character `%`.
25 changes: 25 additions & 0 deletions examples/arm64/lambdas-download/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
locals {
version = "<REPLACE_BY_GITHUB_RELEASE_VERSION>"
}

module "lambdas" {
source = "../../../modules/download-lambda"
lambdas = [
{
name = "webhook"
tag = local.version
},
{
name = "runners"
tag = local.version
},
{
name = "runner-binaries-syncer"
tag = local.version
}
]
}

output "files" {
value = module.lambdas.files
}
77 changes: 77 additions & 0 deletions examples/arm64/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
locals {
environment = "default"
aws_region = "eu-west-1"
}

resource "random_id" "random" {
byte_length = 20
}


################################################################################
### Hybrid account
################################################################################

module "runners" {
source = "../../"
create_service_linked_role_spot = true
aws_region = local.aws_region
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets

environment = local.environment
tags = {
Project = "ProjectX"
}

github_app = {
key_base64 = var.github_app_key_base64
id = var.github_app_id
webhook_secret = random_id.random.hex
}

# Grab zip files via lambda_download, will automatically get the ARM64 build
webhook_lambda_zip = "lambdas-download/webhook.zip"
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
runners_lambda_zip = "lambdas-download/runners.zip"

enable_organization_runners = false
# Runners will automatically get the "arm64" label
runner_extra_labels = "default,example"

# enable access to the runners via SSM
enable_ssm_on_runners = true

# use S3 or KMS SSE to runners S3 bucket
# runner_binaries_s3_sse_configuration = {
# rule = {
# apply_server_side_encryption_by_default = {
# sse_algorithm = "AES256"
# }
# }
# }

# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
# idle_config = [{
# cron = "* * 9-17 * * *"
# timeZone = "Europe/Amsterdam"
# idleCount = 1
# }]

# Let the module manage the service linked role
# create_service_linked_role_spot = true

runner_architecture = "arm64"
# Ensure all instance types have ARM64 architecture (ie. AWS Graviton processors)
instance_types = ["t4g.large", "c6g.large"]

# override delay of events in seconds
delay_webhook_event = 5
runners_maximum_count = 1

# set up a fifo queue to remain order
fifo_build_queue = true

# override scaling down
scale_down_schedule_expression = "cron(* * * * ? *)"
}
15 changes: 15 additions & 0 deletions examples/arm64/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "runners" {
value = {
lambda_syncer_name = module.runners.binaries_syncer.lambda.function_name
}
}

output "webhook_endpoint" {
value = module.runners.webhook.endpoint
}

output "webhook_secret" {
sensitive = true
value = random_id.random.hex
}

3 changes: 3 additions & 0 deletions examples/arm64/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = local.aws_region
}
4 changes: 4 additions & 0 deletions examples/arm64/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

variable "github_app_key_base64" {}

variable "github_app_id" {}
15 changes: 15 additions & 0 deletions examples/arm64/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.27"
}
local = {
source = "hashicorp/local"
}
random = {
source = "hashicorp/random"
}
}
required_version = ">= 0.14"
}
7 changes: 7 additions & 0 deletions examples/arm64/vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "vpc" {
source = "git::https://github.com/philips-software/terraform-aws-vpc.git?ref=2.2.0"

environment = local.environment
aws_region = local.aws_region
create_private_hosted_zone = false
}
2 changes: 1 addition & 1 deletion examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resource "random_id" "random" {


################################################################################
### Hybrid acccount
### Hybrid account
################################################################################

module "runners" {
Expand Down
3 changes: 1 addition & 2 deletions modules/runners/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ locals {
instance_profile_path = var.instance_profile_path == null ? "/${var.environment}/" : var.instance_profile_path
lambda_zip = var.lambda_zip == null ? "${path.module}/lambdas/runners/runners.zip" : var.lambda_zip
userdata_template = var.userdata_template == null ? local.default_userdata_template[var.runner_os] : var.userdata_template
userdata_arm_patch = "${path.module}/templates/arm-runner-patch.tpl"
kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : ""

default_ami = {
Expand Down Expand Up @@ -119,7 +118,7 @@ resource "aws_launch_template" "runner" {
pre_install = var.userdata_pre_install
install_runner = templatefile(local.userdata_install_runner[var.runner_os], {
S3_LOCATION_RUNNER_DISTRIBUTION = var.s3_location_runner_binaries
ARM_PATCH = var.runner_architecture == "arm64" ? templatefile(local.userdata_arm_patch, {}) : ""
RUNNER_ARCHITECTURE = var.runner_architecture
})
post_install = var.userdata_post_install
start_runner = templatefile(local.userdata_start_runner[var.runner_os], {})
Expand Down
49 changes: 0 additions & 49 deletions modules/runners/templates/arm-runner-patch.tpl

This file was deleted.

Loading