moved autospotting to infra and added spot instance helper (#636)

This commit is contained in:
chrisurwin
2017-10-13 17:18:17 +01:00
committed by Bill Maxwell
parent 1dccf899ab
commit 3508bcab48
10 changed files with 61 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
# Autospotting
### Info
This service builds upon the open source autospotting at [https://github.com/cristim/autospotting](https://github.com/cristim/autospotting)
This has been turned into a Rancher catalog entry with a couple of minor tweaks and the removal of the requirement to run it as a lambda function, it now runs as a docker container.
Autospotting works by taking a tag that you specify and adding it to an AWS Auto-Scaling Group with a value of true.
The container will then run and check for on-demand instances and replace them with cheap spot instances. This is a gradual process and will only replace one host in an ASG at a time.
@@ -0,0 +1,13 @@
aws-spot-instance-helper:
image: chrisurwin/autospotting:v0.1.0
tty: true
labels:
io.rancher.container.pull_image: always
environment:
AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY_ID}"
AWS_SECRET_ACCESS_KEY: "${AWS_SECRET_ACCESS_KEY}"
regions: "${regions}"
min_on_demand_number: "${min_on_demand_number}"
min_on_demand_percentage: "${min_on_demand_percentage}"
allowed_instance_types: "${allowed_instance_types}"
tag_name: "${tag_name}"
@@ -0,0 +1,51 @@
.catalog:
name: "Autospotting"
version: "v0.1.0"
description: "Autospotting"
minimum_rancher_version: v1.0.0
questions:
- variable: "AWS_ACCESS_KEY_ID"
description: "AWS Access Key"
label: "AWS Access Key"
required: true
type: "string"
- variable: "AWS_SECRET_ACCESS_KEY"
description: "AWS Secret Key"
label: "Access Secret"
required: true
type: "string"
- variable: "regions"
description: "Regions where it should be activated (comma or whitespace separated list, also supports globs), by default it runs on all regions. Example: 'eu-*,us-east-1"
label: "AWS Regions"
required: false
type: "string"
- variable: "min_on_demand_number"
description: "On-demand capacity (as absolute number) ensured to be running in each of your groups"
label: "Minimum on demand number"
required: false
type: "string"
- variable: "min_on_demand_percentage"
description: "On-demand capacity (percentage of the total number of instances in the group) ensured to be running in each of your groups. Defaults to 0"
label: "Minimum on demand percentage"
required: false
type: "string"
- variable: "allowed_instance_types"
description: "If specified, the spot instances will have a specific instance type"
label: "Allowed instance types"
required: false
type: "string"
- variable: "tag_name"
description: "If specified you can tag instances with a specific tag to process, default is spot-enabled"
label: "Tag name"
required: false
type: "string"
aws-spot-instance-helper:
health_check:
port: 9777
interval: 2000
unhealthy_threshold: 3
strategy: recreate
response_timeout: 2000
request_line: GET /ping HTTP/1.0
healthy_threshold: 2
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 29 KiB

+5
View File
@@ -0,0 +1,5 @@
name: AutoSpotting
description: |
Replaces AWS On-Demand instances with cheaper Spot-Instances where possible
version: v0.1.0
category: Infrastructure Services
@@ -0,0 +1,7 @@
# AWS Spot Instance Helper
### Info
This is a simple service that runs globally. It monitors the state of the host, if the host is running on a spot instance it will check to see if the host is scheduled for termination then it will automatically deactive the host and evaculate the containers.
The source code is available at [https://www.github.com/chrisurwin/aws-spot-instance-helper](https://www.github.com/chrisurwin/aws-spot-instance-helper)
@@ -0,0 +1,8 @@
aws-spot-instance-helper:
image: chrisurwin/aws-spot-instance-helper:v0.1.0
tty: true
labels:
io.rancher.container.create_agent: 'true'
io.rancher.container.agent.role: environment
io.rancher.container.pull_image: always
io.rancher.scheduler.global: 'true'
@@ -0,0 +1,16 @@
.catalog:
name: "AWS Spot Instance Helper"
version: "v0.1.0"
description: "AWS Spot Instance Helper"
minimum_rancher_version: v1.5.5
aws-spot-instance-helper:
health_check:
port: 9777
interval: 2000
unhealthy_threshold: 3
strategy: recreate
response_timeout: 2000
request_line: GET /ping HTTP/1.0
healthy_threshold: 2
@@ -0,0 +1,25 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="1200.000000pt" height="1200.000000pt" viewBox="0 0 1200.000000 1200.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,1200.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M0 6000 l0 -6000 6000 0 6000 0 0 6000 0 6000 -6000 0 -6000 0 0
-6000z m6369 5085 c174 -42 319 -177 377 -355 17 -50 18 -112 22 -717 l3 -663
-1798 0 c-1983 0 -1850 4 -1977 -63 -118 -61 -226 -200 -255 -327 -7 -30 -11
-651 -11 -1882 l0 -1838 -602 0 c-368 0 -628 4 -667 11 -228 37 -401 216 -432
447 -6 51 -9 910 -7 2527 l3 2450 23 66 c43 129 132 234 250 297 121 64 -55
60 2592 61 2121 1 2423 -1 2479 -14z m2142 -2183 c164 -46 299 -177 349 -340
19 -61 20 -94 20 -728 l0 -664 -1804 0 c-1771 0 -1805 0 -1868 -20 -161 -50
-286 -176 -344 -350 -18 -53 -19 -133 -22 -1892 l-2 -1838 -628 0 c-684 0
-689 0 -796 58 -28 15 -81 57 -119 93 -78 78 -130 177 -147 279 -14 90 -14
4900 0 4990 30 189 188 365 371 414 46 13 394 15 2489 15 2331 1 2438 0 2501
-17z m2160 -2190 c82 -27 175 -88 230 -150 50 -57 105 -167 119 -241 15 -79
14 -4962 -1 -5033 -40 -192 -212 -361 -404 -398 -44 -8 -715 -10 -2490 -8
l-2430 3 -58 22 c-150 57 -263 170 -320 320 l-22 58 -3 2495 c-1 1709 1 2511
8 2546 43 209 223 375 435 404 33 4 1142 7 2465 6 l2405 -1 66 -23z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,5 @@
name: AWS Spot Instance Helper
description: |
Automatically evacuates spot instances that are marked for termination
version: v0.1.0
category: Rancher Services