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
- A verified Spotinst Elastigroup account. For more information on getting started with Spotinst’s Elastigroup head here.
Steps
- Create an Elastigroup in your account with the following parameters (The complete Elastigroup tutorial can be found here):
- Docker-Machine Supported OS AMI
- Create Security Group with inbound SSH (22) and Docker-Machine (2376) ports open
- Docker-Machine Supported OS AMI
- Install Git Runner on Linux machine
- On the same machine install Docker-Machine.
- Install Spotinst driver on Docker-Machine. The driver can be found here: https://github.com/spotinst/docker-machine-driver-spotinst/releases
- Register your Runner.
- Open the Gitlab Runner configuration file
/etc/gitlab-runner/config.toml
and add configuration of Spotinst 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 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.