@@ -145,54 +145,33 @@ module "runner" {
145145
146146### Scenario: Use of Docker autoscaler
147147
148- As docker machine is no longer maintained by docker, gitlab recently developed docker autoscaler to replace docker machine
149- (still in beta). An option is available to test it out.
150-
151- Tested with amazon-linux-2-x86 as runner manager and ubuntu-server-22-lts-x86 for runner worker. The following commands have been
152- added to the original AMI for the runner worker for the docker-autoscaler to work correctly:
153-
154- ``` bash
155- # Install docker
156- # Add Docker's official GPG key:
157- apt-get update
158- apt-get install -y ca-certificates curl
159- install -m 0755 -d /etc/apt/keyrings
160- curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
161- chmod a+r /etc/apt/keyrings/docker.asc
162-
163- # Add the repository to Apt sources:
164- echo \
165- " deb [arch=$( dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
166- $( . /etc/os-release && echo " $VERSION_CODENAME " ) stable" | \
167- tee /etc/apt/sources.list.d/docker.list > /dev/null
168- apt-get update
169-
170- apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
171- usermod -aG docker ubuntu
172- ```
148+ As docker machine is no longer maintained by Docker, GitLab recently developed docker autoscaler to replace docker machine.
149+
150+ Tested with amazon-linux-2-x86 as runner manager and ubuntu-server-22-lts-x86 for runner worker. The main problem is to find an AMI
151+ which has the Docker engine pre-installed. This means that any "base" Amazon Linux or Ubuntu AMI cannot work.
152+
153+ There is a project in the early alpha phase to support you to build your own AMI: https://github.com/cattle-ops/AWS-Fleeting-Plugin-AMI
173154
174155#### Docker Autoscaler Configuration
175156
176157``` hcl
177158module "runner" {
178- # https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws/
179- source = "cattle-ops/gitlab-runner/aws"
159+ source = "cattle-ops/gitlab-runner/aws"
180160
181- vpc_id = module.vpc.vpc_id
161+ vpc_id = module.vpc.vpc_id
182162 subnet_id = element(module.vpc.private_subnets, 0)
183163
184164 runner_gitlab = {
185- tag_list = "runner_worker"
186- type = "instance"
187165 url = "https://gitlab.com"
188-
189166 preregistered_runner_token_ssm_parameter_name = "my-gitlab-runner-token-ssm-parameter-name"
190167 }
191-
192- runner_manager = {
193- maximum_concurrent_jobs = 5
168+
169+ runner_ami_filter = {
170+ name = ["amazon-linux-2-x86"]
194171 }
195172
173+ runner_ami_owners = ["amazon"]
174+
196175 runner_worker = {
197176 max_jobs = 5
198177 request_concurrency = 5
@@ -202,19 +181,19 @@ module "runner" {
202181 runner_worker_docker_autoscaler_asg = {
203182 on_demand_percentage_above_base_capacity = 0
204183 enable_mixed_instances_policy = true
205- idle_time = 600
206- subnet_ids = vpc.private_subnets_ids
207- types = ["t3a.medium", "t3.medium"]
208- volume_type = "gp3"
209- private_address_only = true
210- ebs_optimized = true
211- root_size = 40
184+ subnet_ids = module.vpc.private_subnets
185+ types = ["t3a.medium", "t3.medium"]
212186 }
213187
214188 runner_worker_docker_autoscaler = {
215- connector_config_user = "ubuntu"
189+ connector_config_user = "ubuntu" # this user id is used to connect to the instance via SSH
190+ }
191+
192+ runner_worker_docker_autoscaler_ami_filter = {
193+ name = ["ubuntu-server-22-lts-x86-*"]
216194 }
217195
196+ runner_worker_docker_autoscaler_ami_owners = ["099720109477"] # Canonical
218197}
219198```
220199
0 commit comments