The primary API endpoint for deployments in 1.5 is:
http://<host>/<region>/deployment
where <host> is the host, and <region> is the EC2 region, such as us-west-2. So a full deployment endpoint might look something like this:
http://asgard.jonfenner.com/us-west-2/deployment
Steps for a deployment are:
- Prepare for a deployment
- Start a deployment
Prepare for a deployment
Endpoint: http://<host>/<region>/deployment/prepare?id=<asg>
Start a deployment
Endpoint: http://<host>/<region>/deployment/start
The deployment consists of "steps". We've implemented the following:
- Create the new ASG (always starts out with 0 instances)
- Resize it to the appropriate # of instances
- Disable the old ASG
- Delete the old ASG
Each step is self-checking, so if it fails, none of the succeeding steps will execute.
Below is a sample python script to implement this:
- Create the new ASG (always starts out with 0 instances)
- Resize it to the appropriate # of instances
- Disable the old ASG
- Delete the old ASG
Each step is self-checking, so if it fails, none of the succeeding steps will execute.
Below is a sample python script to implement this:
#!/usr/bin/python
import sys
import urllib2
import jsonbr /> import requests
version = '1.0'
print 'AMI Asgard Deployment Script V' + version
asgardhost = 'localhost:8080'
ec2region = 'us-west-2'
baseurl = 'http://' + asgardhost + '/' + ec2region + '/deployment'
notify = 'xxx@yyy.com'
if (len(sys.argv) != 3):
print 'Syntax: launch.py <ASG Id> <AMI Id>'
sys.exit()
asgid=sys.argv[1]
amiid=sys.argv[2]
print 'Asgard Host: ' + asgardhost
print 'EC2 Region: ' + ec2region
print 'ASG: ' + asgid
print 'AMI to Launch: ' + amiid
query = baseurl + '/prepare?id=' + asgid
f = urllib2.urlopen(query)
deflcjson = f.read()
f.close()
deflc = json.loads(deflcjson)
deflc['lcOptions']['imageId'] = amiid
deflc['deploymentOptions'] = {
"clusterName": asgid,
"notificationDestination": notify,
"steps": [
{ "type": "CreateAsg" },
{ "type": "Resize", "targetAsg": "Next", "capacity": deflc['asgOptions']['minSize'], "startUpTimeoutMinutes": 41},
{ "type": "DisableAsg", "targetAsg": "Previous" },
{ "type": "DeleteAsg", "targetAsg": "Previous" },
]
}
posturl = baseurl + '/start'
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
response = requests.post(posturl, data=json.dumps(deflc), headers=headers)
print response
print response.text
import sys
import urllib2
import jsonbr /> import requests
version = '1.0'
print 'AMI Asgard Deployment Script V' + version
asgardhost = 'localhost:8080'
ec2region = 'us-west-2'
baseurl = 'http://' + asgardhost + '/' + ec2region + '/deployment'
notify = 'xxx@yyy.com'
if (len(sys.argv) != 3):
print 'Syntax: launch.py <ASG Id> <AMI Id>'
sys.exit()
asgid=sys.argv[1]
amiid=sys.argv[2]
print 'Asgard Host: ' + asgardhost
print 'EC2 Region: ' + ec2region
print 'ASG: ' + asgid
print 'AMI to Launch: ' + amiid
query = baseurl + '/prepare?id=' + asgid
f = urllib2.urlopen(query)
deflcjson = f.read()
f.close()
deflc = json.loads(deflcjson)
deflc['lcOptions']['imageId'] = amiid
deflc['deploymentOptions'] = {
"clusterName": asgid,
"notificationDestination": notify,
"steps": [
{ "type": "CreateAsg" },
{ "type": "Resize", "targetAsg": "Next", "capacity": deflc['asgOptions']['minSize'], "startUpTimeoutMinutes": 41},
{ "type": "DisableAsg", "targetAsg": "Previous" },
{ "type": "DeleteAsg", "targetAsg": "Previous" },
]
}
posturl = baseurl + '/start'
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
response = requests.post(posturl, data=json.dumps(deflc), headers=headers)
print response
print response.text
Also, be sure you've implemented Eureka and healthchecks for all services. Asgard waits for both a Eureka UP and a positive healthcheck.
No comments:
Post a Comment