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
-
Create an Elastigroup in your account with the following parameters:
- Docker-Machine Supported OS AMI
- Create Security Group with inbound SSH (22) and Docker-Machine (2376) ports open
-
Install Git Runner on Linux machine
-
On the same machine, install Docker-Machine.
-
Install Spot driver on Docker-Machine. The driver can be found here.
-
Open the GitLab Runner configuration file
:/etc/gitlab-runner/config.toml
-
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 Name | Description |
---|---|
--spotinst-account | Spot Account ID |
--spotinst-elastigroup-id | Elastigroup ID in the relevant account to fill in servers |
--spotinst-token | Spot 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.
To learn more about the Elastigroup Docker-Machine integration, click here.