AWS ECS集群任务在GitHub操作CI/CD中的动态IP到静态IP。

huangapple go评论71阅读模式
英文:

AWS ECS cluster task dynamic IP to static on Github action CI/CD

问题

我设法设置了Git Actions的CI/CD到AWS ECS Fargate,并且它确实有效。但目前我有一个问题,一开始我找不到我的应用程序的URL或IP地址。我看到它已经部署了,但我不知道它部署在哪里。后来我发现在我的集群里有一个任务,而且这个任务有一个IP地址。我可以访问它,但每次重新部署我的应用程序时,IP地址都会变化,因为会创建一个新的任务。

我向Chat GPT询问过这个问题,它给了我一百万个愚蠢的答案,其中一个“似乎可以工作”的答案是创建一个应用程序负载均衡器(Application Load Balancer),但我在这方面遇到了问题,因为它是Fargate,我没有任何EC2实例,我也没有可以选择的目标组,所以我猜可能无法创建ALB。但我该如何获取静态IP,以便将其添加到我的域名中呢?

英文:

I've somehow managed to set up Git actions CI/CD to AWS ECS fargate, and it does work. But I have one problem for now, at first I could not find the url or ip for my app. I saw that it IS deployed, but I did not know where it is deployed. Then I figured out that there is task inside my cluster and the task has an ip. And it I can access it, but every time I redeploy my app, ip changes because there it new task created.

I've asked Chat GPT about it, it gave me a billion stupid answer, and one of "seems to work" was to create Application Load Balancer, but I have a problem with it, since it is fargate and I don't have any EC2 instances, I don't have anything to select in target group, so it is impossible to create ALB, I guess. But how I can get static ip so that I can add it to my domain?

答案1

得分: 1

> 我没有任何内容可以选择在目标组中,所以创建ALB是不可能的,我猜。

您需要创建一个应用程序负载均衡器,并将其与目标组关联起来。目标组一开始可以完全没有目标,这完全没有问题。一个空的目标组不会阻止您创建负载均衡器。

创建ALB和目标组后,您需要配置您的ECS服务以使用负载均衡器/目标组。在这一点上,ECS服务本身将自动将ECS任务注册到负载均衡器,并在它们被移除时自动注销。

英文:

> I don't have anything to select in target group, so it is impossible to create ALB, I guess.

You need to create an application load balancer, and associate it with the target group. The target group can be completely empty of targets at first, that is totally fine. An empty target group does not prevent you from creating a load balancer.

After you have the ALB and Target Group created, you would configure your ECS service to use the load balancer/target group. At that point the ECS service itself will automatically register your ECS tasks with the load balancer, and automatically deregister then when they are removed.

huangapple
  • 本文由 发表于 2023年6月13日 04:00:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76459930.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定