简体   繁体   English

带有 ASG 和 ELB (bitbucket) 的 AWS CD/CI 管道

[英]AWS CD/CI pipeline with ASG and ELB (bitbucket)

I must first preface by saying I am relatively new to AWS but finding it immensely useful.我必须首先声明我对 AWS 比较陌生,但发现它非常有用。 Let me describe my scenario...让我描述一下我的场景......

What I have currently我目前拥有的

  • An Auto scaling group (ASG)自动缩放组 (ASG)
  • An Elastic Load Balancer (ELB)弹性负载均衡器 (ELB)
  • A CD/CI pipeline using CodeDeploy and Bitbucket使用 CodeDeploy 和 Bitbucket 的 CD/CI 管道
  • Node/Express app serving a custom API on EC2 instances Node/Express 应用程序在 EC2 实例上提供自定义 API
  • VPC and su.nets are working well VPC 和 su.nets 运行良好
  • An AMI with my app code带有我的应用程序代码的 AMI

My question我的问题

When the ASG decides to scale in a new EC2 instance using my launch template and AMI, it will use the application code from the AMI.当 ASG 决定使用我的启动模板和 AMI 扩展新的 EC2 实例时,它将使用 AMI 中的应用程序代码。 But if I deploy to master at some point, my AMI will not be updated, but instances within the ASG will be updated.但如果我在某个时候部署到 master,我的 AMI 将不会更新,但 ASG 中的实例会更新。 What is the best method for ensuring the new instances spawned by the ASG are running the latest code version (master)?确保 ASG 生成的新实例运行最新代码版本(master)的最佳方法是什么?

My initial thoughts我最初的想法

I am thinking to include a bash script in the launch config that will pull the latest code from Bitbucket and run any following steps to get my application running (such as "npm install", "npm run start" etc etc).我想在启动配置中包含一个 bash 脚本,它将从 Bitbucket 中提取最新代码并运行以下任何步骤以使我的应用程序运行(例如“npm install”、“npm run start”等)。 I'm sure someone has a more elegant solution, and I'd love to hear some suggestions.我相信有人有更优雅的解决方案,我很想听听一些建议。

To anyone coming to this, I did solve my problem.对于任何来到这里的人,我确实解决了我的问题。 I was correct initially.我一开始是对的。 The "user data" field within the Launch Template was a good place to bootstrap my app once the instance is up and running.一旦实例启动并运行,启动模板中的“用户数据”字段是引导我的应用程序的好地方。 It basically clones from the remote repo and performs any necessary steps to launch the app after that.它基本上从远程存储库克隆,然后执行任何必要的步骤来启动应用程序。

For example, in the launch configuration for EC2例如,在 EC2 的启动配置中

#cloud-boothook
#!/bin/bash
git clone myremoterepo.git
cd myremoterepo
npm install
npm run start

Also, if you're running a classic load balancer, CodeDeploy will attempt to start a deployment, based on your latest code repo in S3, when your ASG scales up the EC2 instances.此外,如果您运行的是经典负载均衡器,当您的 ASG 扩展 EC2 实例时,CodeDeploy 将尝试根据您在 S3 中的最新代码存储库开始部署。 So the above solution will be redundant.所以上述解决方案将是多余的。

thanks for this post.感谢这篇文章。 But it would help me a lot if you shared an example of your bitbucket pipeline yml, since I have a project that migrates it to the asg infrastructure with network load balancer, and I don't know how to configure a code deploy to integrate it with s3 and bitbucket.但是,如果您分享了您的 bitbucket 管道 yml 的示例,这将对我有很大帮助,因为我有一个项目可以将其迁移到带有网络负载均衡器的 asg 基础架构,而且我不知道如何配置代码部署以集成它使用 s3 和 bitbucket。 A guide would help me a lot to be able to configure the entire process of deploying my load balancer from bitbucket.一个指南可以帮助我配置从 bitbucket 部署负载均衡器的整个过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 BitBucket 和 VertexAI 的 CI/CD 管道 - CI/CD Pipeline using BitBucket and VertexAI 如何使用 AWS CodePipeline 为使用 Zappa 部署的 Flask 应用程序设置 CI/CD 管道? - How do I set up a CI/CD pipeline using AWS CodePipeline for a Flask application deployed using Zappa? botocore.exceptions.NoRegionError:您必须指定区域。 GitHub 使用 AWS 的 CI/CD 管道的操作 - botocore.exceptions.NoRegionError: You must specify a region. GitHub Actions with CI/CD Pipeline with AWS AWS Amplify - 我可以推送代码提交以启动 CI/CD 管道并构建新的后端资源吗? - AWS Amplify - Can I Push To Code Commit To Start The CI/CD Pipeline & Build The New Backend Resources? 在 Gitlab CI/CD 管道上获取最新的 git 标签 - Get latest git tags on Gitlab CI/CD pipeline 从 elb 在私人 su.net 中访问 ASG 的问题 - Problem with accessing ASG in private subnet from elb aws eks bitbucket 管道权限错误 - Aws eks bitbucket pipeline permission error 是否可以将 aws codepipeline 转换为 bitbucket 管道? - Is it possible to convert an aws codepipeline to bitbucket pipeline? Gitlab CI/CD:仅计划特定作业并将其从管道中排除 - Gitlab CI/CD: Schedule only for a particular job and exclude it from the pipeline Gitlab CI/CD 管道已通过,但未对服务器应用任何更改 - Gitlab CI/CD pipeline passed, but no changes were applied to the server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM