[英]how to deploy code on multiple instances Amazon EC2 Autocaling group?
So we are launching an ecommerce store built on magento. 因此,我们正在建立一个基于magento的电子商务商店。 We are looking to deploy it on Amazon EC2 instance using RDS as database service and using amazon auto-scaling and elastic load balancer to scale the application when needed. 我们希望使用RDS作为数据库服务,并在需要时使用Amazon自动缩放和弹性负载平衡器来将其部署在Amazon EC2实例上。
What I don't understand is this: I have installed and configured my production magento enviorment on an EC2 instance (database is in RDS). 我不明白的是:我已经在EC2实例(数据库位于RDS中)上安装并配置了生产magento环境。 This much is working fine. 这样很好。 But now when I want to dynamically scale the number of instances 但是现在当我想动态扩展实例数时
A detailed explanation or direction towards some resources on the topic will be greatly appreciated. 对于该主题的一些资源的详细解释或方向将不胜感激。
You do this in the AutoScalingGroup Launch Configuration. 您可以在AutoScalingGroup启动配置中执行此操作。 There is a UserData section in the LaunchConfiguration in CloudFormation where you would write a script that is ran when ever the ASG scales up and deploys a new instance. CloudFormation中的LaunchConfiguration中有一个UserData部分,您可以在其中编写一个脚本,该脚本在ASG扩大规模并部署新实例时运行。
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html#cfn-as-launchconfig-userdata https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html#cfn-as-launchconfig-userdata
This is the same as the UserData section in an EC2 Instance. 这与EC2实例中的UserData部分相同。 You can use LifeCycle hooks that will tell the ASG not to put the EC2 instance into load until everything you want to have configured it set up. 您可以使用LifeCycle挂钩,该挂钩将告诉ASG在您要配置的所有内容都设置好之前不要将EC2实例加载。
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-lifecyclehook.html https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-lifecyclehook.html
I linked all CloudFormation pages, but you may be using some other CI/CD tool for deploying your infrastructure, but hopefully that gets you started. 我链接了所有CloudFormation页面,但是您可能正在使用其他CI / CD工具来部署基础架构,但是希望可以帮助您入门。
To start, do check AWS CloudFormation . 首先,请检查AWS CloudFormation 。 You will be creating templates to design how the infrastructure of your application works ~ infrastructure as code. 您将创建模板来设计应用程序的基础结构的工作方式〜基础结构作为代码。 With these templates in place, you can rollout an update to your infrastructure by pushing changes to your templates and/or to your application code. 有了这些模板后,您可以通过推送对模板和/或应用程序代码的更改来向基础结构推出更新。
In my current project, we have a github repository dedicated for these infrastructure templates and a separate repository for our application code. 在我当前的项目中,我们有一个专用于这些基础结构模板的github存储库,以及一个用于我们的应用程序代码的单独存储库。 Create a pipeline for creating AWS resources that would rollout an updated to AWS every time you push to the repository on a specific branch. 创建用于创建AWS资源的管道,该管道将在您每次推送到特定分支上的存储库时将更新发布到AWS。
how will I deploy the code on the dynamically generated instances each time? 每次如何在动态生成的实例上部署代码?
containers
work, it would be better and will greatly supplement on your learning on how launching new version of application work. 检查containers
工作方式,这样会更好,并且将大大补充您对启动新版本应用程序的工作方式的学习。 To begin, see docker , but feel free to check any resources at your disposal 首先,请参阅docker ,但请随时检查可用的任何资源 image
that will become a container ~ from the docker documentation. 我们的应用程序管道旨在通过AWS Codebuild构建应用程序的新版本,这将创建一个image
,该image
将成为docker文档中的一个容器。 Will aws copy the whole instance assign it a new ip and spawn it as a new instance or will I have to write some code to automate this process? 将aws复制整个实例,为它分配一个新的ip,并将其作为新实例生成,还是我必须编写一些代码来自动化该过程?
Plus will it not be an overhead to pull code from git and deploy every time a new instance is spawned? 加上每次生成新实例时从git中提取代码并进行部署都不会产生开销吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.