Skip to content

Commit 68a63bd

Browse files
authored
docs: improve documentation for docker-autoscaler setup (#1323)
1 parent 0a38f87 commit 68a63bd

File tree

2 files changed

+27
-62
lines changed

2 files changed

+27
-62
lines changed

docs/usage.md

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -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
177158
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"
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

examples/runner-fleeting-plugin/main.tf

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,8 @@ module "runner" {
5656
subnet_id = element(module.vpc.private_subnets, 0)
5757

5858
runner_instance = {
59-
collect_autoscaling_metrics = ["GroupDesiredCapacity", "GroupInServiceCapacity"]
60-
name = var.runner_name
61-
ssm_access = true
62-
}
63-
64-
runner_networking = {
65-
allow_incoming_ping_security_group_ids = [data.aws_security_group.default.id]
59+
name = var.runner_name
60+
ssm_access = true
6661
}
6762

6863
runner_gitlab = {
@@ -76,23 +71,14 @@ module "runner" {
7671
max_jobs = 10
7772
}
7873

79-
runner_worker_gitlab_pipeline = {
80-
pre_build_script = <<EOT
81-
'''
82-
echo 'multiline 1'
83-
echo 'multiline 2'
84-
'''
85-
EOT
86-
post_build_script = "\"echo 'single line'\""
87-
}
88-
8974
runner_worker_docker_autoscaler = {
90-
fleeting_plugin_version = "1.0.0"
75+
connector_config_user = "ubuntu" # this user id is used to connect to the instance via SSH
9176
}
9277

93-
runner_worker_docker_autoscaler_ami_owners = ["591542846629"] # FIXME Change to your AWS account ID
78+
# FIXME: this AMI is outdated, but has Docker installed, which is needed. There are no other AMIs available with Docker pre-installed.
79+
runner_worker_docker_autoscaler_ami_owners = ["099720109477"] # Canonical
9480
runner_worker_docker_autoscaler_ami_filter = {
95-
name = ["al2023-ami-ecs-hvm-2023.0.20240723-kernel-6.1-x86_64"] # FIXME Change to your AMI name
81+
name = ["ubuntu-server-22-lts-x86-*"]
9682
}
9783

9884
runner_worker_docker_autoscaler_instance = {

0 commit comments

Comments
 (0)