diff --git a/docs/usage.md b/docs/usage.md index a91cbd930..74f2f2335 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -145,54 +145,33 @@ module "runner" { ### Scenario: Use of Docker autoscaler -As docker machine is no longer maintained by docker, gitlab recently developed docker autoscaler to replace docker machine -(still in beta). An option is available to test it out. - -Tested with amazon-linux-2-x86 as runner manager and ubuntu-server-22-lts-x86 for runner worker. The following commands have been -added to the original AMI for the runner worker for the docker-autoscaler to work correctly: - -```bash -# Install docker -# Add Docker's official GPG key: -apt-get update -apt-get install -y ca-certificates curl -install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc -chmod a+r /etc/apt/keyrings/docker.asc - -# Add the repository to Apt sources: -echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ - $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ - tee /etc/apt/sources.list.d/docker.list > /dev/null -apt-get update - -apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -usermod -aG docker ubuntu -``` +As docker machine is no longer maintained by Docker, GitLab recently developed docker autoscaler to replace docker machine. + +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 +which has the Docker engine pre-installed. This means that any "base" Amazon Linux or Ubuntu AMI cannot work. + +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 #### Docker Autoscaler Configuration ```hcl module "runner" { - # https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws/ - source = "cattle-ops/gitlab-runner/aws" + source = "cattle-ops/gitlab-runner/aws" - vpc_id = module.vpc.vpc_id + vpc_id = module.vpc.vpc_id subnet_id = element(module.vpc.private_subnets, 0) runner_gitlab = { - tag_list = "runner_worker" - type = "instance" url = "https://gitlab.com" - preregistered_runner_token_ssm_parameter_name = "my-gitlab-runner-token-ssm-parameter-name" } - - runner_manager = { - maximum_concurrent_jobs = 5 + + runner_ami_filter = { + name = ["amazon-linux-2-x86"] } + runner_ami_owners = ["amazon"] + runner_worker = { max_jobs = 5 request_concurrency = 5 @@ -202,19 +181,19 @@ module "runner" { runner_worker_docker_autoscaler_asg = { on_demand_percentage_above_base_capacity = 0 enable_mixed_instances_policy = true - idle_time = 600 - subnet_ids = vpc.private_subnets_ids - types = ["t3a.medium", "t3.medium"] - volume_type = "gp3" - private_address_only = true - ebs_optimized = true - root_size = 40 + subnet_ids = module.vpc.private_subnets + types = ["t3a.medium", "t3.medium"] } runner_worker_docker_autoscaler = { - connector_config_user = "ubuntu" + connector_config_user = "ubuntu" # this user id is used to connect to the instance via SSH + } + + runner_worker_docker_autoscaler_ami_filter = { + name = ["ubuntu-server-22-lts-x86-*"] } + runner_worker_docker_autoscaler_ami_owners = ["099720109477"] # Canonical } ``` diff --git a/examples/runner-fleeting-plugin/main.tf b/examples/runner-fleeting-plugin/main.tf index d216055c5..2f558565b 100644 --- a/examples/runner-fleeting-plugin/main.tf +++ b/examples/runner-fleeting-plugin/main.tf @@ -56,13 +56,8 @@ module "runner" { subnet_id = element(module.vpc.private_subnets, 0) runner_instance = { - collect_autoscaling_metrics = ["GroupDesiredCapacity", "GroupInServiceCapacity"] - name = var.runner_name - ssm_access = true - } - - runner_networking = { - allow_incoming_ping_security_group_ids = [data.aws_security_group.default.id] + name = var.runner_name + ssm_access = true } runner_gitlab = { @@ -76,23 +71,14 @@ module "runner" { max_jobs = 10 } - runner_worker_gitlab_pipeline = { - pre_build_script = <