Skip to content

Create tags on spot instance after instance creation

Romuald Atchadé requested to merge tags-for-spot-instance into main

NOTE THAT THIS FORK IS MAINTAINED FOR CRITICAL BUG FIXES AFFECTING RUNNING COSTS ONLY. NO OTHER CONTRIBUTIONS WILL BE ACCEPTED.

What critical bug this MR is fixing?

fixes #112 (closed)

How to test

By following the steps described here, I was able to create spot intances and the name could be seen in the AWS Console

config.toml
concurrent = 10
check_interval = 0

[[runners]]
  name = "gitlab-aws-autoscaler"
  url = "https://gitlab.com"
  token = "REDACTED"
  executor = "docker+machine"
  limit = 20
  [runners.docker]
    image = "alpine"
    privileged = true
    disable_cache = true
  [runners.cache]
    Type = "s3"
    Shared = true
    [runners.cache.s3]
      ServerAddress = "s3.amazonaws.com"
      AccessKey = "XXX"
      SecretKey = "XXX"
      BucketName = "touni-test-bucket"
      BucketLocation = "us-east-1"
  [runners.machine]
    IdleCount = 1
    IdleTime = 1800
    MaxBuilds = 100
    MachineDriver = "amazonec2"
    MachineName = "gitlab-docker-machine-%s"
    MachineOptions = [
      "amazonec2-access-key=XXX",
      "amazonec2-secret-key=XXX",
      "amazonec2-region=us-east-1",
      "amazonec2-zone=d",
      "amazonec2-vpc-id=vpc-XXX",
      "amazonec2-subnet-id=subnet-XXX",
      "amazonec2-use-private-address=true",
      "amazonec2-tags=runner-manager-name,gitlab-aws-autoscaler,gitlab,true,gitlab-runner-autoscale,true",
      "amazonec2-security-group=XXX",
      "amazonec2-instance-type=t2.micro",
      "amazonec2-request-spot-instance=true",
      "amazonec2-spot-price=15",
    ]
    [[runners.machine.autoscaling]]
      Periods = ["* * 9-17 * * mon-fri *"]
      IdleCount = 50
      IdleTime = 3600
      Timezone = "UTC"
    [[runners.machine.autoscaling]]
      Periods = ["* * * * * sat,sun *"]
      IdleCount = 5
      IdleTime = 60
      Timezone = "UTC"

Tags and Instance name can now be seen

Screenshots Screenshot_2023-08-15_at_1.51.35_AM

Screenshot_2023-08-15_at_1.53.40_AM

How does this change help reduce cost of usage? What scale of cost reduction is it?

In what scenarios is this change usable with GitLab Runner's docker+machine executor?

Edited by Romuald Atchadé

Merge request reports