问题描述
我设法在本地和 AWS上运行
,但是现在我想知道如何设置某种负载平衡以使我的两个具有随机IP的服务对公众可用。 Traefik
ECS
I've managed to run Traefik
locally and on AWS ECS
but now I'm wondering how should I setup some sort of load balancing to make my two services with random IPs available to the public.
[Internet]
|
[Load balancer on port 443 + ALB Security group on 443]
|
[Target group on port 443 + Security group from *any* port]
|
[cluster]
|
[service1 container ports "0:5000"]
虽然可行,但我想现在想添加另一个容器,例如。 service2
也具有随机端口,例如 0:8000
。这就是为什么我需要类似 Traefik
的原因。
While this works, I'd now like to add another container, eg. service2
also with random ports eg 0:8000
. And that's why I need something like Traefik
.
此处是Toml文件:
[api]
address = ":8080"
[ecs]
clusters = ["my-cluster"]
watch = true
domain = "mydomain.com"
region = "eu-central-1"
accessKeyID = "AKIA..."
secretAccessKey = "..."
我也在 / etc / hosts
中添加了主机条目:
Also I've added the host entry in /etc/hosts
:
127.0.0.1 service1.mydomain.com
127.0.0.1 service2.mydomain.com
以及容器上的相对标签,我可以 curl service1.mydomain.com/status
并获取一个 200
。
And the relative labels on the containers and I can curl service1.mydomain.com/status
and get a 200
.
现在我的最后一个问题是:
Now my last bit is just the following question:
- 应如何将所有这些内容发布到互联网上?
AWS ALB
?AWS Network LB
?网络桥/主机/其他?
- How should publish all this to the internet?
AWS ALB
?AWS Network LB
? Network Bridge/host/other?
推荐答案
AWS ALB与AWS Network LB取决于谁做您想要处理SSL。
AWS ALB vs AWS Network LB depends on who do you want to handle SSL.
-
如果您具有通配符证书,并且所有服务都是同一域的子域,则ALB可能是一个不错的选择
If you have a wildcard certificate and all your services are subdomains of the same domain ALB may be a good choice
如果要使用让我们用traefik Network LB加密可能是一个更好的选择
If you want to use Let's encrypt with traefik Network LB may be a better choice
在两种情况下,您的设置都将如下所示:
In both case your setup will look something like this :
[Internet]
|
[LB]
|
[Target group]
|
[Traefik]
| |
[service1] [service2]
在两种情况下,最简单的方法是使traefik ecs服务自动注册到目标组。
In both case, easiest way to get this is to make traefik ecs services to auto register to the target group.
这可以在创建服务(网络配置部分)时完成,以后不能再执行。
This can be done at service creation (network configuration section) and can not be done later. Link to documentation
这篇关于如何在ECS上设置Traefik?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!