简体   繁体   English

如何将Spring Cloud服务正确部署到AWS ECS

[英]How to properly deploy Spring Cloud services to AWS ECS

I've spent the last week trying to find a good example on how to properly achieve this but the internet doesn't seem to have anything out there... 我花了最后一周试图找到一个很好的例子来说明如何正确实现这一点,但互联网似乎没有任何东西......

I have what I'd say is a pretty basic Spring Cloud service. 我有一个非常基本的Spring Cloud服务。 It includes Eureka, Zuul, Spring Config, and a handful of services. 它包括Eureka,Zuul,Spring Config和一些服务。

I've worked out using the esc-cli how I can easily create new tasks based on my docker-compose.yml files. 我已经开始使用esc-cli如何根据我docker-compose.yml文件轻松创建新任务。 So I have two tasks 所以我有两个任务

A management task which has basic things that at this stage don't need to scale, and having one instance of them is just fine for this project. 一个管理任务,它具有在此阶段不需要扩展的基本事物,并且具有它们的一个实例对于该项目来说是正常的。

version: '2'
services:

  mongo:
    image: mongo
    cpu_shares: 300
    mem_limit: 268435456
    ports:
      - 27017:27017   

  config-service:
    image: config-service
    cpu_shares: 300
    mem_limit: 268435456
    ports:
      - 8888:8888
    environment:
      - SPRING_PROFILES_ACTIVE=cloud

  edge-service:
    image: edge-service
    cpu_shares: 300
    mem_limit: 268435456
    ports:
      - 80:8080
    environment:
      - SPRING_PROFILES_ACTIVE=cloud

My second task has the clients of the above task. 我的第二项任务是上述任务的客户。

version: '2'
services:

  instance-service:
    image: instance-service
    cpu_shares: 300
    mem_limit: 268435456
    ports:
      - 8081:8081
    environment:
      - SPRING_PROFILES_ACTIVE=cloud

  restore-service:
    image: restore-service:latest
    cpu_shares: 300
    mem_limit: 268435456
    ports:
      - 8082:8082
    environment:
      - SPRING_PROFILES_ACTIVE=cloud

I can easily create these tasks with a simple command such as ecs-cli compose --file management-task.yml --project-name management-task up No problem there. 我可以使用简单的命令轻松创建这些任务,例如ecs-cli compose --file management-task.yml --project-name management-task up没问题。

Where I hit an issue nothing can reach the Eureka or the Config services, so they all die. 在我遇到问题的地方,没有任何东西可以到达EurekaConfig服务,所以他们都死了。 I've read all over the place that I can use an application load balance to allow the containers to talk to each other, however I can't actually find any information on how to do this. 我已经阅读了所有可以使用应用程序负载平衡以允许容器相互通信的地方,但是我实际上无法找到有关如何执行此操作的任何信息。

The closest I've managed to find is a blog post here http://www.rahulkatte.com/index.html#!/microservice-part-V however they're not making use of Eureka being inside a task, nor a config server. 我设法找到的最近的是一篇博客文章http://www.rahulkatte.com/index.html#!/microservice-part-V但是他们没有利用Eureka在任务中,也没有配置服务器。

So, is there any comprehensive examples out there on how exactly you deploy a modern Spring Cloud app to AWS? 那么,有没有关于如何将现代Spring Cloud应用程序部署到AWS的全面实例? Or does anyone have any pointers as to how to get my tasks/containers talking to each other, without just saying "Use a load balancers..."? 或者,有没有人指出如何让我的任务/容器相互交谈,而不只是说“使用负载平衡器......”?

Thanks for your time. 谢谢你的时间。

So I know this is sort of necro'ing a post, but there are no answers on here yet, so for posterity of anyone finding it in the future: 所以我知道这是一个坏消息的帖子,但是这里还没有答案,所以对于未来发现它的人的后代:

You're dealing with a "service discovery" problem here, and there are multiple ways to solve it: 您在这里处理“服务发现”问题,有多种方法可以解决它:

  1. You can use load balancers as you state. 您可以使用负载平衡器。 The way you do this is by creating an ALB, then creating a target group within that ALB. 执行此操作的方法是创建ALB,然后在该ALB中创建目标组。 The target group's health check must the string literal "traffic port", because each ECS container will have a random port. 目标组的运行状况检查必须是字符串文字“流量端口”,因为每个ECS容器都有一个随机端口。 Make sure that the security group for the EC2 instances attached to your ECS cluster allow incoming on all TCP ports. 确保连接到ECS群集的EC2实例的安全组允许在所有TCP端口上传入。 Note that if your ALB health check fails for whatever reason, the container will set to "draining" and be shut down. 请注意,如果您的ALB运行状况检查因任何原因失败,容器将设置为“耗尽”并关闭。

  2. ECS also recently (after your post, but is now GA) announced ECS service discovery. ECS最近(在你的职位之后,但现在是GA)宣布了ECS服务发现。 See this post . 看这篇文章

  3. You could use Kubernetes (EKS), which supports service discovery natively. 您可以使用Kubernetes(EKS),它本身支持服务发现。

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

相关问题 如何在谷歌云中部署 spring 启动应用程序? - How to deploy a spring boot app in google cloud? 如何使用 Spring 正确关闭执行程序服务? - How to properly shutdown executor services with Spring? 播放2:如何将dist应用程序部署到Windows Azure云服务(不是VM) - Play 2: How to deploy dist app to the Windows Azure Cloud Services (not VM) 寻找 Spring 云 ECS 连接器文档 - Looking for Spring Cloud ECS Connector Documentation 如何使用注解配置Spring Cloud AWS消息传递? - How to configure Spring Cloud AWS messaging with annotations? AWS ECS 中的 Spring Boot:应用程序配置更新 - Spring Boot in AWS ECS: Application Configuration Updates 如何部署“使用Spring构建REST服务”教程? - How do you deploy the “Building REST Services with Spring” tutorial? 如何在云端Jelastic上使用PostgreSQL部署Spring Boot应用程序? - How to deploy Spring Boot application with PostgreSQL on the cloud Jelastic? 如何在 Google Cloud Compute Engine 中部署 Spring Boot 应用程序? - How to deploy Spring Boot application in Google Cloud Compute Engine? Cloud Foundry:如何使用额外的 JVM 命令部署 Spring Boot 应用程序 - Cloud Foundry : How to deploy spring boot app with an additional JVM command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM