Scripting deployment of clusters in asgard

综合编程 Onoffswitch (源链)

We use asgard at work to do deployments in both qa and production. Our general flow is to check in, have jenkins build, an AMI is created, and then … we have to manually go to asgard and deploy it. That sucks.

However, its actually not super hard to write some scripts to find the latest AMI for a cluster and prepare an automated deployment pipeline from a template. Here you go:

function asgard(){
  verb=$1
  url="https://my.asgard.com/us-east-1/$2"
  shift
  http ${VERB} --verify=no "$url" -b
}

function next-ami(){
  cluster=$1

  prepare-ami $cluster true | 
    jq ".environment.images | reverse | .[0]"
}

function prepare-ami(){
  cluster=$1

  includeEnv=$2

  asgard GET "deployment/prepare/${cluster}?deploymentTemplateName=CreateAndCleanUpPreviousAsg&includeEnvironment=${includeEnv}"
}

function get-next-ami(){
  cluster=$1

  next=`next-ami ${cluster} | jq ".id"`

  prepare-ami ${cluster} "false" | jq ".lcOptions.imageId |= ${next}"
}

function start-deployment(){
  cluster=$1
  payload=$2

  echo $payload | asgard POST "deployment/start/${cluster}"
}

The gist here is to

  • Find the next AMI image of a cluster
  • Get the prepared JSON for the next deployment
  • Update the prepared json with the new ami image

To use it you’d do

> clusterName="foo"
> next=`get-next-ami $clusterName`
> start-deployment $clusterName $next
{
    "deploymentId": "1773"
}

And thats it!

您可能感兴趣的

PSScriptAnalyzer deep dive – Part 1 of 4 Summary: Thomas Rayner, Microsoft Cloud and Datacenter Management MVP, shows the basics about how to use PSScriptAnalyzer. Hello! I’m Thomas Rayn...
项目经验:组织会议中的“小心思” 本文作者以会议为例说明了一个事情从最开始的组织,到后续的执行,再到后续的结果落地过程中的一些“小心思”,主要是为了让大家在日常的工作中把握一些关键细节点,有效推动事项的完成,提高自己的工作效率。 在平时的工作中,我们总是会参与各种各样的会议,可能是别人组织,也可能是我们自己组织的,而这...
Data at rest encryption done right Introduction Encrypting network traffic is becoming the default. There are standardized protocols like SSH and TLS as well as projects like Let’s En...
A manager’s manager Are you a new group manager? Many folks become group managers in the late fall. If you’ve never managed managers before, it can be a disorienting ex...
责编内容来自:Onoffswitch (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » Scripting deployment of clusters in asgard



专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录