Skip to content

Instantly share code, notes, and snippets.

@taufiqpsumarna
Last active December 20, 2023 01:58
Show Gist options
  • Save taufiqpsumarna/acb7f93e0ffb328797004e6676fcd573 to your computer and use it in GitHub Desktop.
Save taufiqpsumarna/acb7f93e0ffb328797004e6676fcd573 to your computer and use it in GitHub Desktop.
Gitlab Runner Config EC2Machine
concurrent = 4
check_interval = 0
[[runners]]
name = "gitlab-runner-autoscaler"
url = "https://gitlab.com" #TODO_1: Change with your gitlab repository URL
token = "" #TODO_2: Fill with your Gitlab Token
executor = "docker+machine"
limit = 4
[runners.docker]
tls_verify = false
image = "docker:20.10.24-dind-alpine3.18"
privileged = true
volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock"]
disable_cache = true
shm_size = 0
[runners.cache]
Type = "s3"
Path = "cache"
Shared = true
[runners.cache.s3] #TODO_3: Change with your S3 Bucket, Access and Secret Key
ServerAddress = "s3.amazonaws.com"
AccessKey = "your-access-key" #Changeme
SecretKey = "your-secret-key" #Changeme
BucketName = "s3-cache-bucket-name" #Changeme
BucketLocation = "ap-southeast-1"
[runners.machine]
MachineDriver = "amazonec2"
MachineName = "gitlab-ci-machine-%s"
OffPeakTimezone = ""
OffPeakIdleCount = 0
OffPeakIdleTime = 0
IdleCount = 0 #Changeme (optional)
#TODO_4: Change with your gitlab-runner-manager IAM Roles, Access, Secret Key, VPC, subnet, security group and instance type
MachineOptions = [
"amazonec2-access-key=your-access-key", #Changeme
"amazonec2-secret-key=your-secret-key", #Changeme
"amazonec2-region=us-east-2", #Changeme
"amazonec2-vpc-id=vpc-0175846a", #Changeme
"amazonec2-subnet-id=subnet-dbb6afb3", #Changeme
"amazonec2-zone=a", #Changeme
"amazonec2-use-private-address=true",
"amazonec2-tags=runner-manager-name,gitlab-aws-autoscaler,gitlab,true,gitlab-runner-autoscale,true",
"amazonec2-security-group=gitlab-runner-instance-worker", #Changeme: Security security group with port 22 (ssh), 2376 (docker-machine-port) open
"amazonec2-instance-type=t3.medium", #Changeme (optional)
"amazonec2-ami=ami-0fa377108253bf620", #Ubuntu 22.04 LTS, ap-southeast-1, change with your correct AMI ID see more: https://cloud-images.ubuntu.com/locator/ec2/
"amazonec2-request-spot-instance=true",
"amazonec2-spot-price=0.03", #Changeme (optional)
"amazonec2-block-duration-minutes=0", #Changeme (optional)
"engine-install-url='https://releases.rancher.com/install-docker/20.10.24.sh'"
]
@taufiqpsumarna
Copy link
Author

Docker Engine 23.0+ Error Issue

As of this morning, the latest Docker release (23.0) caused issues with the docker-machine fork, resulting in GitLab Runner not being able to create autoscaling runners using the docker+machine executor. The issue is captured in #98 (closed). Many of us were using an older version of docker-machine as a workaround for the problem described in this issue, but since we now have to update to the latest release this is no longer possible.

https://gitlab.com/gitlab-org/ci-cd/docker-machine/-/issues/109#note_1325863864

@taufiqpsumarna
Copy link
Author

Change default Gitlab Runner image 20.10.24-dind-alpine3.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment