Automatically build and register a Gitlab runner to your Gitlab instance.
Use this module of you need to set up a git lab runner for you GitLab project. The runner can be within your GCP project or you can create a separate project just for your runner.
Unless you define otherwise, place the GitLab registration token in secrets manager in a secret called RUNNER_REG_TOKEN
The runner will need access to the internet so that it can reach your GitLab instance, currently the assumption is that Cloud NAT will be in place in your project. This module will not create the Cloud NAT nor will it create a public IP on the runner instance (In fact for security sake it is not recommend to!)
The runner uses DOCKER executor - that is all.
You can choose whether to have an instance schedule on the runner or not. This will stop the runner outside of hours to save you some money. Enable the schedule by setting the set_schedule
boolean to true
. If this is set it then becomes necessary to set runner_timezone
, runner_start
and runner_stop
although there are default values for these.
You will need to create a service account for the runner, the email address can be passed to the module using service_account_email
, you will also need to assign appropriate permissions for the runner service account so that is can execute your CI/CD, usually OWNER
.
It will take some time to run the first deployment, this is due to the need to download and set up the docker container. Be patient padawan.
Name | Description | Type | Default | Required |
---|---|---|---|---|
disk_size | Define the boot disk size | number |
50 |
no |
labels | Key-value map of labels to assign to the runner | map(any) |
{} |
no |
machine_type | Define the instance type | string |
"e2-micro" |
no |
name | Name of the runner instance. | string |
"gitlab-runner" |
no |
network | The network to deploy to. | string |
"default" |
no |
project_id | The project to deploy to | string |
n/a | yes |
reg_url | URL for gitlab instance | string |
n/a | yes |
region | The region to deploy to | string |
n/a | yes |
runner_start | Time for runner to start | string |
"0 6 * * 1-5" |
no |
runner_stop | Time for runner to stop | string |
"0 18 * * 1-5" |
no |
runner_tags | Tags that will be assigned to the runner | string |
"" |
no |
runner_timezone | Time zone for stop and start of instance to save $$$ | string |
"GMT" |
no |
runner_token | Name of secret that contains the Gitlab Runner registration token | string |
"RUNNER_REG_TOKEN" |
no |
service_account_email | Name of the service account email, if not specified, 'gitlab-runner-sa' will be used | string |
n/a | yes |
set_schedule | Enable stop/start schedule, SEE DOCUMENTATION! | bool |
"false" |
no |
tags | Network tags, provided as a list | list(string) |
[] |
no |
zone | The zone to deploy to | string |
n/a | yes |
No output.