module-base-gitlab-runner-manager
This module creates a GitLab CI Runner Manager. The module will spawn a single EC2 node in a self-healing AutoScaling Group and runners will be spawned by docker-machine using spot instances. Runners will scale automatically based on the configuration. The module also creates by default a S3 cache bucket that is shared across spot instances runners.
Usage examples
Simple example
module "gitlab_runners" {
source = "git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/compute/module-base-gitlab-runner-manager.git?ref=vX.Y.Z"
vpc_id = var.vpc_id
vpc_subnets = var.vpc_subnets
runners_name = "aws-spot-runners"
gitlab_server_url = "https://gitlab.com"
gitlab_runner_registration_config = {
registration_token = "abc123xxx456def"
tag_list = "tag1,tag2"
description = "AWS AutoScaled Spot GitLab Runners"
locked_to_project = "false"
run_untagged = "true"
maximum_timeout = "3600"
}
tags = {
Project = "project_name"
Environment = "environment_name"
}
}
Complex example
module "gitlab_runners" {
source = "git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/compute/module-base-gitlab-runner-manager.git?ref=vX.Y.Z"
vpc_id = var.vpc_id
vpc_subnets = var.vpc_subnets
runners_name = "aws-spot-runners"
gitlab_server_url = "https://gitlab.com"
gitlab_runner_registration_config = {
registration_token = "abc123xxx456def"
tag_list = "tag1,tag2"
description = "AWS AutoScaled Spot GitLab Runners"
locked_to_project = "false"
run_untagged = "true"
maximum_timeout = "3600"
}
runners_limit: 20
runners_concurrent: 20
runners_idle_time: 600
runners_idle_count: 1
runners_off_peak_timezone: "Europe/Madrid"
runners_off_peak_periods: "[\"* * 0-9,17-23 * * mon-fri *\", \"* * * * * sat,sun *\"]"
runners_off_peak_idle_count: 0
runners_off_peak_idle_time: 60
runners_instance_type: "m5.large"
runners_spot_price_bid: "0.035"
runners_root_size: 20
runners_request_concurrency: 20
runners_output_limit: 524288
runners_cache_enabled: true
runners_cache_expiration_days: 7
tags = {
Project = "project_name"
Environment = "environment_name"
}
}
Modules
| Name | Source | Version |
|---|---|---|
git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/compute/module-base-asg.git |
v0.1.0 |
|
git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/networking/module-base-sg.git |
v0.2.2 |
|
git::https://gitlab.vectoritcgroup.com/vectordigital/iac/terraform/modules/aws/networking/module-base-sg.git |
v0.2.2 |
Resources
| Name | Type |
|---|---|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
resource |
|
data source |
|
data source |
|
data source |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
AWS Region name |
|
n/a |
yes |
|
Configuration used to register the runner. See the README for an example, or reference the examples in the examples directory of this repo. |
|
|
no |
|
URL of the gitlab instance to connect to. |
|
n/a |
yes |
|
List of additional options for the docker machine config. Each element of this list must be a key=value pair. E.g. '["amazonec2-zone=a"]' |
|
|
no |
|
Version of the docker-machine package to install in the Gitlab Runner Manager instance |
|
|
no |
|
The executor to use in the Gitlab Runner Manager. It can be |
|
|
no |
|
Boolean used to enable or disable the CloudWatch logging. |
|
|
no |
|
Let the module manage a KMS key, logs will be encrypted via KMS. Be-aware of the costs of an custom key. |
|
|
no |
|
KMS key id to encrypted the CloudWatch logs. Ensure CloudWatch has access to the provided KMS key. |
|
|
no |
|
Key rotation window, set to 0 for no rotation. Only used when |
|
|
no |
|
Retention for cloudwatch logs. Defaults to unlimited |
|
|
no |
|
Version of the Gitlab Runner to be installed the Gitlab Runner Manager instance |
|
|
no |
|
User-data script snippet to insert after GitLab Runner Manager installation |
|
|
no |
|
User-data script snippet to insert before GitLab Runner Manager installation |
|
|
no |
|
The service name |
|
|
no |
|
The prefix to be attached to every resource name |
|
n/a |
yes |
|
Additional volumes that will be used in the runner config.toml, e.g Docker socket |
|
|
no |
|
List of maps used to create the AMI filter for the Gitlab Runner AMI |
|
|
no |
|
The list of owners used to select the AMI of Gitlab Runner instance. |
|
|
no |
|
Wether or not to create an S3 bucket for storing Gitlab Runners cache |
|
|
no |
|
Number of days before the Gitlab Runners cache objects expires |
|
|
no |
|
Concurrent value for the runners, will be used in the runner config.toml. |
|
|
no |
|
Environment variables during build execution, e.g. KEY=Value, see runner-public example. Will be used in the runner config.toml |
|
|
no |
|
The executor to use. Currently supports |
|
|
no |
|
IAM instance profile name of the runners, will be used in the runner config.toml |
|
|
no |
|
Idle count of the runners, will be used in the runner config.toml. |
|
|
no |
|
Idle time of the runners, will be used in the runner config.toml. |
|
|
no |
|
Image to run builds, will be used in the runner config.toml |
|
|
no |
|
Instance type used for the instances hosting docker-machine. |
|
|
no |
|
Limit for the runners, will be used in the runner config.toml. |
|
|
no |
|
Max builds for each runner after which it will be removed, will be used in the runner config.toml. By default set to 0, no maxBuilds will be set in the configuration. |
|
|
no |
|
Name of the runner, will be used in the runner config.toml. |
|
n/a |
yes |
|
Off peak idle count of the runners, will be used in the runner config.toml. |
|
|
no |
|
Off peak idle time of the runners, will be used in the runner config.toml. |
|
|
no |
|
Off peak periods of the runners, will be used in the runner config.toml. |
|
|
no |
|
Off peak idle time zone of the runners, will be used in the runner config.toml. |
|
|
no |
|
Sets the maximum build log size in kilobytes |
|
|
no |
|
Runners will run in privileged mode, will be used in the runner config.toml |
|
|
no |
|
pull_policy for the runners, will be used in the runner config.toml |
|
|
no |
|
Limit number of concurrent requests for new jobs from GitLab |
|
|
no |
|
Whether or not to request spot instances via docker-machine |
|
|
no |
|
Runner instance root size in GB. |
|
|
no |
|
shm_size for the runners, will be used in the runner config.toml |
|
|
no |
|
Spot price bid. |
|
|
no |
|
Token for the runner, will be used in the runner config.toml. |
|
|
no |
|
Specific tags for all module resources |
|
n/a |
yes |
|
The VPC ID of the VPC used to deploy the Gitlab Runner Manager |
|
n/a |
yes |
|
A list of subnets where the Gitlab Runner Manager ASG will be deployed |
|
n/a |
yes |
Outputs
| Name | Description |
|---|---|
The GitLab Runners S3 cache bucket ARN |
|
The GitLab Runners S3 cache bucket name |
|
The GitLab Runner Manager log group name |
|
The GitLab Runner Manager AutoScaling Group ARN |
|
The GitLab Runner Manager AutoScaling Group name |
|
The GitLab Runner Manager Launch Template ARN |
|
The GitLab Runner Manager Launch Template name |
|
The GitLab Runner Manager security group arn |
|
The GitLab Runner Manager security group id |
|
The GitLab Runner Manager security group name |
|
The GitLab Runners security group arn |
|
The GitLab Runners security group id |
|
The GitLab Runners security group name |