terraform-aws-gitlab-runner icon indicating copy to clipboard operation
terraform-aws-gitlab-runner copied to clipboard

Support for multiple docker machines within a single runner instance

Open krzysztof-miemiec opened this issue 4 years ago • 2 comments

I'm currently doing small research in order to migrate my current GitLab runner setup (done with CloudFormation, modified and updated by hand via SSH) to Terraform. I'm currently using a setup with configuration like this:

concurrent = 20
check_interval = 0

[session_server]
  session_timeout = 3600

[[runners]]
  name = "team-a-runner"
  url = "https://gitlab.(redacted)/"
  token = "(team-a token redacted)"
  executor = "docker+machine"
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = true
    volumes = ["/certs/client", "/cache"]
    shm_size = 0
  [runners.cache]
    Type = "s3"
    Shared = true
    [runners.cache.s3]
      ServerAddress = "s3.amazonaws.com"
      BucketName = "(redacted)"
      BucketLocation = "eu-central-1"
  [runners.machine]
    IdleCount = 0
    IdleTime = 1200
    MaxBuilds = 100
    MachineDriver = "amazonec2"
    MachineName = "gitlab-docker-machine-%s"
    MachineOptions = ["engine-storage-driver=overlay2", "amazonec2-instance-type=m5.large", "amazonec2-region=eu-central-1", "amazonec2-vpc-id=(redacted)", "amazonec2-security-group=(redacted)", "amazonec2-use-private-address=true", "amazonec2-iam-instance-profile=(redacted)"]
    OffPeakPeriods = ["* * 0-9,17-23 * * mon-fri *", "* * * * * sat,sun *"]
    OffPeakTimezone = "Etc/UTC"
    OffPeakIdleCount = 0
    OffPeakIdleTime = 300

[[runners]]
  name = "team-b-runner"
  url = "https://gitlab.(redacted)/"
  token = "(team-b token redacted)"
  executor = "docker+machine"
  (same as above)

[[runners]]
  name = "team-c-runner"
  url = "https://gitlab.(redacted)/"
  token = "(team-c token redacted)"
  executor = "docker+machine"
  (same as above)

[[runners]]
  name = "team-d-runner"
  url = "https://gitlab.(redacted)/"
  token = "(team-d token redacted)"
  executor = "docker+machine"
  (same as above)

[[runners]]
  name = "team-e-runner"
  url = "https://gitlab.(redacted)/"
  token = "(team-e token redacted)"
  executor = "docker+machine"
  (same as above)

I defined multiple [[runners]] section in order to register separate runners for each Gitlab group (I can't register global runner in our company). A lot of improvements can be made to this setup, yet it's a few times cheaper than defining each runner group separately. So I have a question regarding registering more than one group of docker-machine instances inside a single GL runner, as above. Is it a bad practice to register multiple runners?

I know it's doable within Terraform, as we may simply loop over instance types and generate more [[runners]] sections. If not, why not define 12 different groups that are configured with 12 different EC2 instance types and create our own "spot fleet" within a single runner?

krzysztof-miemiec avatar Aug 17 '20 17:08 krzysztof-miemiec

In my opinion it is not a bad practice at all to have multiple runners, we have as well. We have deployed the module a few times. To match different use cases, some of them ar dedicated to a team.

With Terrafomr 13 it should also be possible to loop over modules, so would it be an option to deploy the module one time for each time, the overad is in that case that you have 1 small ec2 instances for the agent running per team.

npalm avatar Aug 18 '20 20:08 npalm

@npalm To try to avoid such cost overhead mentioned by you, I created proposal PR which should enable some cool stuff, like adding multiple different docker-machine configurations that run on spot. I'll check it tomorrow in practice on my side, please take a look and tell me what you think 😉

krzysztof-miemiec avatar Aug 20 '20 20:08 krzysztof-miemiec

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Jan 02 '23 02:01 github-actions[bot]

Hi ✋,

Sorry to re-open that, but i don't find how to use multiple runners config within a single instance. Has a solution been found ?

Thanks for your help.

AnthonyGWeb avatar Mar 02 '23 14:03 AnthonyGWeb

Wasn't closed 😄

Started to work on krzysztof-miemiec PR. But it's not that easy. But this feature is definitely wanted.

kayman-mk avatar Mar 02 '23 14:03 kayman-mk

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar May 02 '23 02:05 github-actions[bot]

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Jul 03 '23 03:07 github-actions[bot]

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Sep 05 '23 02:09 github-actions[bot]

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Nov 09 '23 02:11 github-actions[bot]

This issue was closed because it has been stalled for 15 days with no activity.

github-actions[bot] avatar Nov 24 '23 02:11 github-actions[bot]