fbpx
Intro

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. All 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 Runners simply skip to Step 4.

Prerequisites
  1. A verified Spotinst Elastigroup account. For more information on getting started with Spotinst’s Elastigroup head here.
Steps
  1. Create an Elastigroup in your account with the following parameters (The complete Elastigroup tutorial can be found here):

    1. Docker-Machine Supported OS AMI
    2. Create Security Group with inbound SSH (22) and Docker-Machine (2376) ports open
  2. Install Git Runner on Linux machine
  3. On the same machine install Docker-Machine.
  4. Install Spotinst driver on Docker-Machine. The driver can be found here: https://github.com/spotinst/docker-machine-driver-spotinst/releases
  5. Register your Runner.
  6. Open the Gitlab Runner configuration file 
 /etc/gitlab-runner/config.toml

and add configuration of Spotinst provider under [runners.cache]:

 

 [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 parameters documentation can be found here.

 

Option Name Description
--spotinst-account Spotinst Account ID
--spotinst-elastigroup-id Elastigroup ID in the relevant account to fill in servers
--spotinst-token Spotinst token from your organization
--spotinst-sshkey-path Local path to the pem file of the Elastigroup

 

You just configured Docker-Machine to provision instances through Elastigroup, congrats!

 

What’s next
  • You can read more about how Elastigroup works in our Introduction to Elastigroup.
  • To learn more about the Elastigroup Docker-Machine integration click here.