@@ -145,54 +145,33 @@ module "runner" {
145
145
146
146
### Scenario: Use of Docker autoscaler
147
147
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
173
154
174
155
#### Docker Autoscaler Configuration
175
156
176
157
``` hcl
177
158
module "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"
180
160
181
- vpc_id = module.vpc.vpc_id
161
+ vpc_id = module.vpc.vpc_id
182
162
subnet_id = element(module.vpc.private_subnets, 0)
183
163
184
164
runner_gitlab = {
185
- tag_list = "runner_worker"
186
- type = "instance"
187
165
url = "https://gitlab.com"
188
-
189
166
preregistered_runner_token_ssm_parameter_name = "my-gitlab-runner-token-ssm-parameter-name"
190
167
}
191
-
192
- runner_manager = {
193
- maximum_concurrent_jobs = 5
168
+
169
+ runner_ami_filter = {
170
+ name = ["amazon-linux-2-x86"]
194
171
}
195
172
173
+ runner_ami_owners = ["amazon"]
174
+
196
175
runner_worker = {
197
176
max_jobs = 5
198
177
request_concurrency = 5
@@ -202,19 +181,19 @@ module "runner" {
202
181
runner_worker_docker_autoscaler_asg = {
203
182
on_demand_percentage_above_base_capacity = 0
204
183
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"]
212
186
}
213
187
214
188
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-*"]
216
194
}
217
195
196
+ runner_worker_docker_autoscaler_ami_owners = ["099720109477"] # Canonical
218
197
}
219
198
```
220
199
0 commit comments