我是否可以使用AWS code部署拉应用code,而自动缩放? [英] Can I use AWS code Deploy for pulling application code while autoscaling?

查看:289
本文介绍了我是否可以使用AWS code部署拉应用code,而自动缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要自动缩放的基础架构时,负载变高。我在 AWS 运行我的基础架构。我有一个要求,我需要从 Github上拉应用code时,自动缩放发生。由于code勤换,我们不能把一个 AMI 并从 AMI 启动一个实例。所以我想从拉最新code。 AWS刚刚推出了一个名为 AWS codeDeploy 服务。 我如何使用这项服务来自动拉动code的过程中,当实例启动?

I want to autoscale the infrastructure when load gets high. I am running my infrastructure on AWS. I have a requirement where I need to pull the application code from Github when autoscaling happens. As the code changes frequently, we can't take an AMI and launch an instance from that AMI. So I want to pull the latest code from repositories. AWS just launched a service called AWS CodeDeploy. How can I use this service to automate the process of pulling the code when the instances start?

P.S。我写了初始化脚本自动附加一个 EIP ,白名单的IP不同的安全组,并把实例下一个负载均衡当实例启动和撤销一切,当实例终止的自动缩放。

P.S. I have written an init script to automatically attach an EIP, whitelist that IP on different Security Groups and put the instance under a load-balancer when the instance boots and revoking everything when instance is terminated in autoscaling.

PPS:有人请创建标签aws- code-部署,并把它添加到的问题

P.P.S : someone please create tag aws-code-deploy and add it to the question.

推荐答案

codeDeploy是一个很好的解决您的问题。如果配置正确,它可以自动部署到纺由自动缩放新的EC2实例。为了得到这个工作,你需要三样东西:

CodeDeploy is a great solution to your problem. If configured correctly, it can automatically deploy to new EC2 instances that are spun up by Autoscaling. To get this working you'll need three things:

  1. 在一个自动缩放组推出了最新的主机代理实例的安装和运行。
  2. 系统code配置为部署到自动缩放组部署的部署组(作为自动缩放组不标记)。
  3. 将目标修订为自动部署到新的实例。如果没有为c部署没有目标的修订,$ C $将看到实例启动,但不会部署任何东西。

下面是一个教程,你可以用它来帮助上手:<一href="https://docs.aws.amazon.com/$c$cdeploy/latest/userguide/auto-scaling-integ-tutorial.html">Tutorial:使用AWS codeDeploy将应用程序部署到自动缩放集团。这个教程将引导您完成烘烤的AMI与代理安装和设置部署组来部署code到新的实例。

Here's a tutorial you can use to help get started: Tutorial: Using AWS CodeDeploy to Deploy an Application to an Auto Scaling Group. That tutorial will walk you through baking an AMI with the agent installed and setting up the deployment group to deploy your code to new instances.

如果你烤AMI与代理pre-安装,你需要经常更新的形象代理发行。一旦安装了代理会自动更新,但自动缩放可能会失败,如果代理的版本是由code部署不再支持您的实例启动。在实际生产中使用,我建议不要烘烤的AMI,而是安装最新的代理,当你的实例启动。 (本教程应更新为尽快使用此方法。)

If you do bake a AMI with the agent pre-installed, you would need to update that image regularly with agent releases. Once the agent is installed it will update itself, but Auto Scaling might fail your instance launches if the agent version is no longer supported by Code Deploy. For actual production use, I would recommend not baking an AMI and instead installing the latest agent when your instances are launched. (The tutorial should be updated to use this method soon.)

您可以设置你的情况下自动下载和启动运行最新的安装程序。从本质上讲,你在一个shell脚本作为用户数据创建自动缩放组时粘贴。

You can setup your instances to automatically download and run the latest installer on boot. Essentially, you paste in a shell script as user data when creating the Auto Scaling group.

例如,我测试了亚马逊的Linux下面的脚本(从的设置新的Amazon EC2实例与AWS codeDeploy )工作:

For example, I tested the following script on Amazon Linux (taken from Set Up a New Amazon EC2 Instance to Work with AWS CodeDeploy):

#!/bin/bash
yum -y update
yum install -y aws-cli
cd /home/ec2-user
aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
chmod +x ./install
./install auto

您应该能够粘贴在作为用户数据当你创建的自动缩放组。对于自动缩放,在创建下配置的详细信息启动配置时设置了 - >高级详细信息

You should be able to paste this in as user data when you are creating the Auto Scaling group. For Auto Scaling, you set that up when creating the launch configuration under configure details -> advanced details.

要设置部署组,并设置目标修订:

To set up the deployment group and set the target revision:

  1. 创建或编辑调配组,包括自动缩放组。 (注:在自动缩放组必须存在,首先这个工作)
  2. 确保有自动缩放组中至少有1个实例。
  3. 部署神器捆绑你想被自动部署到部署组。
  4. 假设第3步成功,部署集团现在有优惠套装,因为它的目标修订。对于自动部署,这成为已知良好版本进行部署。

新的实例将自动部署到他们的部署组的目标修订。从手动部署失败的修订将不会自动自动部署。

New instances that are launched by Auto Scaling in that Auto Scaling group will have the target revision of the deployment group automatically deployed to them. Revisions from failed manual deployments won't be automatically deployed automatically.

这篇关于我是否可以使用AWS code部署拉应用code,而自动缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆