Skip to main content

GitLab

Using GitLab Runner's autoscaling feature you can now configure Docker-Machine to provision Spot instances on Elastigroup. This gives both the cost savings of Spot instances and the 100% availability that Elastigroup provides while retaining full control over your CI/CD with GitLab Runners.

What's Covered

The following tutorial covers how to start running GitLab Runner's autoscaling feature with Elastigroup as the instance provider. If you're already using GitLab Runner simply skip to Step 4.

Prerequisites

A verified Spot Elastigroup account.

Procedure

  1. Create an Elastigroup in your account with the following parameters:

  2. Install Git Runner on Linux machine

  3. On the same machine, install Docker-Machine.

  4. Install Spot driver on Docker-Machine. The driver can be found here.

  5. Register your Runner.

  6. Open the GitLab Runner configuration file

    :/etc/gitlab-runner/config.toml

  7. Add configuration of Spot provider under [runners.machine]:

    [runners.machine]

    IdleCount = 0

    IdleTime = 1800

    MachineDriver = "spotinst"

    MachineName = "runner-%s"

    MachineOptions = [ "spotinst-account=<Account-ID>", "spotinst-token=<Token>", "spotinst-elastigroup-id=<ElastigroupId>", "spotinst-sshkey-path=<LocalPath>"]

The following table covers the MachineOptions parameters used above. Note that these parameters are all required. The full parameter documentation can be found here.

Option NameDescription
--spotinst-accountSpot Account ID
--spotinst-elastigroup-idElastigroup ID in the relevant account to fill in servers
--spotinst-tokenSpot token from your organization
--spotinst-sshkey-pathLocal path to the pem file of the Elastigroup

You just configured Docker-Machine to provision instances through Elastigroup.

To learn more about the Elastigroup Docker-Machine integration, click here.