简体   繁体   English

使用随机主机端口将ELB注册到ECS服务

[英]Registering an ELB to an ECS service with random host port

I'm working with the ECS service on AWS and I have this problem - the docker containers I need to run on ECS are webservices, each container should have its internal port 80 mapped to a random port on the container host. 我正在使用AWS上的ECS服务,我遇到了这个问题 - 我需要在ECS上运行的docker容器是webservices,每个容器应该将其内部端口80映射到容器主机上的随机端口。 I don't want to specify the host port for the 80 container port beforehand, I'd like to let docker daemon to find a host port for the container. 我不想事先指定80容器端口的主机端口,我想让docker守护程序找到容器的主机端口。

But, how the ELB fits here? 但是,ELB如何适合这里? For me it looks that I have to know the host port to be able to create the ELB for the service. 对我来说,看起来我必须知道能够为服务创建ELB的主机端口。

Is it so? 是这样吗?

This is now possible using Application load balancer 现在可以使用Application负载均衡器

However, if you need to open up inbound traffic on the security group, security group's port mapping is not updated automatically. 但是,如果需要在安全组上打开入站流量,则不会自动更新安全组的端口映射。

ELB does not allow binding to random port. ELB不允许绑定到随机端口。

We have recently implemented service discovery with ECS and CONSUL. 我们最近使用ECS和CONSUL实现了服务发现。 We had to introduce Zuul as intermediate layer between the ELB and our apps. 我们不得不介绍Zuul作为ELB和我们的应用程序之间的中间层。

ELB maps to zuul on a static port, but Zuul discovers the backend services dynamically and routes traffic. ELB在静态端口上映射到zuul,但Zuul动态发现后端服务并路由流量。

您需要一个服务发现系统,例如Hashicorp的Consul ,然后您需要将其与AWS基础架构集成: https//aws.amazon.com/blogs/compute/service-discovery-via-consul-with-amazon-ecs/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM