Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
61eed644
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
61eed644
编写于
11月 10, 2017
作者:
A
Achilleas Pipinellis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add skeleton
上级
c69e9d28
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
115 addition
and
1 deletion
+115
-1
doc/articles/index.md
doc/articles/index.md
+1
-0
doc/articles/runner_autoscale_aws/index.md
doc/articles/runner_autoscale_aws/index.md
+114
-1
未找到文件。
doc/articles/index.md
浏览文件 @
61eed644
...
...
@@ -26,6 +26,7 @@ Build, test, and deploy the software you develop with [GitLab CI/CD](../ci/READM
| Article title | Category | Publishing date |
| :------------ | :------: | --------------: |
|
[
Autoscaling GitLab Runners on AWS
](
runner_autoscale_aws/index.md
)
| Tutorial | 2017-11-10 |
|
[
How to test and deploy Laravel/PHP applications with GitLab CI/CD and Envoy
](
laravel_with_gitlab_and_envoy/index.md
)
| Tutorial | 2017-08-31 |
|
[
How to deploy Maven projects to Artifactory with GitLab CI/CD
](
artifactory_and_gitlab/index.md
)
| Tutorial | 2017-08-15 |
|
[
Making CI Easier with GitLab
](
https://about.gitlab.com/2017/07/13/making-ci-easier-with-gitlab/
)
| Concepts | 2017-07-13 |
...
...
doc/articles/runner_autoscale_aws/index.md
浏览文件 @
61eed644
...
...
@@ -4,12 +4,125 @@ last_updated: 2017-11-10
# Autoscaling GitLab Runner on AWS
GitLab Runner has the ability to autoscale which means automatically spawning
new machines on demand. This proves very useful in situations where you
don't use your Runners 24/7 and want to have a cost-effective and scalable
solution.
## Introduction
In this tutorial, we'll explore how to properly configure a GitLab Runner in
AWS that will serve as the bastion where it will spawn new Docker machines on
demand.
## Installation and configuration
## Save money with AWS spot instances
The bastion will not run any jobs itself.
Edit
`/etc/gitlab-runner/config.toml`
:
```
toml
concurrent
=
3
check_interval
=
0
[[runners]]
name
=
"gitlab-aws-autoscaler"
url
=
"<url to your GitLab CI host>"
token
=
"<registration token>"
executor
=
"docker+machine"
environment
=
["GODEBUG=netdns=cgo"]
output_limit
=
16384
limit
=
4
[runners.docker]
image
=
"ruby:2.1"
privileged
=
true
disable_cache
=
false
volumes
=
["/cache"]
extra_hosts
=
[
"gitlab.thehumangeo.com:<our internal GitLab IP>"
,
"nexus.thehumangeo.com:<our internal Nexus IP>"
]
[runners.cache]
Type
=
"s3"
ServerAddress
=
"s3.amazonaws.com"
AccessKey
=
"<your AWS Access Key ID>"
SecretKey
=
"<your AWS Secret Access Key>"
BucketName
=
"<the bucket where your cache should be kept>"
BucketLocation
=
"us-east-1"
Shared
=
true
[runners.machine]
IdleCount
=
1
IdleTime
=
1800
MaxBuilds
=
100
MachineDriver
=
"amazonec2"
MachineName
=
"gitlab-docker-machine-%s"
OffPeakPeriods
=
[
"* * 0-7,19-23 * * mon-fri *"
,
"* * * * * sat,sun *"
]
OffPeakIdleCount
=
0
OffPeakIdleTime
=
1200
MachineOptions
=
[
"amazonec2-access-key=XXXX"
,
"amazonec2-secret-key=XXXX"
,
"amazonec2-region=us-east-1"
,
"amazonec2-vpc-id=vpc-xxxxx"
,
"amazonec2-subnet-id=subnet-xxxxx"
,
"amazonec2-use-private-address=true"
,
"amazonec2-tags=Name,gitlab-runner-autoscale"
,
"amazonec2-security-group=docker-machine-scaler"
,
"amazonec2-instance-type=m4.2xlarge"
,
"amazonec2-ssh-user=ubuntu"
,
"amazonec2-ssh-keypath=/etc/gitlab-runner/certs/gitlab-aws-autoscaler"
,
"amazonec2-ami=ami-996372fd"
,
"amazonec2-zone=a"
,
"amazonec2-root-size=32"
,
]
```
## Cutting costs with AWS spot instances
>
Amazon EC2 Spot instances allow you to bid on spare Amazon EC2 computing capacity.
Since Spot instances are often available at a discount compared to On-Demand
pricing, you can significantly reduce the cost of running your applications,
grow your application’s compute capacity and throughput for the same budget,
and enable new types of cloud computing applications.
-
https://aws.amazon.com/ec2/spot/
-
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html
-
https://aws.amazon.com/blogs/aws/focusing-on-spot-instances-lets-talk-about-best-practices/
In
`/etc/gitlab-runner/config.toml`
under the
`MachineOptions`
section:
```
toml
MachineOptions
=
[
"amazonec2-request-spot-instance=true"
,
"amazonec2-spot-price=0.03"
,
"amazonec2-block-duration-minutes=180"
]
```
### Caveats of spot instances
If the spot price raises, the auto-scale Runner would fail to create new machines.
This eventually eats 60 requests and then AWS won't accept any more. Then once
the spot price is acceptable, you are locked out for a bit because the call amount
limit is exceeded.
You can use the following command in the bastion machine to see the Docker Machines
state:
```
sh
docker-machine
ls
-q
--filter
state
=
Error
--format
"{{.NAME}}"
```
NOTE:
**Note:**
Follow
[
issue 2771
](
https://gitlab.com/gitlab-org/gitlab-runner/issues/2771
)
for more information.
## Conclusion
Using the autoscale feature of GitLab Runner can save you both time and money.
Using the spot instances that AWS provides can save you even more.
You can read the following user cases from which this tutorial was influenced:
-
[
HumanGeo - Scaling GitLab CI
](
http://blog.thehumangeo.com/gitlab-autoscale-runners.html
)
-
[
subtrakt Health - Autoscale GitLab CI Runners and save 90% on EC2 costs
](
https://substrakthealth.com/news/gitlab-ci-cost-savings/
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录