简体   繁体   English

如何在 Java Springboot 中使用 AWS ECS 服务发现端点

[英]How to use AWS ECS Service Discovery Endpoint in Java Springboot

I am new to AWS ECS.我是 AWS ECS 的新手。 I am developing two services in Java Spring Boot, Service 1 and Service 2. I have created two ECS services with one task each, in the same clsuter.我正在 Java Spring Boot 中开发两个服务,Service 1 和 Service 2。我在同一个 clsuter 中创建了两个 ECS 服务,每个服务有一个任务。

I can see that there is a "Service Discovery Endpoint" Service2.local and "Service discovery name" Service2.我可以看到有一个“服务发现端点”Service2.local 和“服务发现名称”Service2。 I can also see SRV and Type A record in Route 53 for Service 2. I do not know how do I call Service 2 from Service 1. Before I could try from SpringBoot, I tried the following curl command to try to get status from Service2.我还可以在 Route 53 中看到 Service 2 的 SRV 和 Type A 记录。我不知道如何从 Service 1 调用 Service 2。在从 SpringBoot 尝试之前,我尝试了以下 curl 命令以尝试从 Service2 获取状态.

curl service2.local/status curl service2.local/status

I get the error could not resolve host service2.local .我收到错误无法解析主机 service2.local 。 I want to understand how to use the service discovery entpoint or name correctly.我想了解如何正确使用服务发现入口点或名称。

Edit:编辑:

I have tried to execute the following command, but it returns nothing.我试图执行以下命令,但它什么也没返回。

dig +short service2.local dig +short service2.local

If如果

  1. you have the entry in your hosted zone您在托管区域中有条目

and

  1. you can curl using the posted IP inside your hosted zone (so the ports are correct and the security groups work, and the app is up) then:您可以使用托管区域内发布的 IP 卷曲(因此端口正确且安全组正常工作,并且应用程序已启动)然后:

Check that your VPC has both DNS hostnames and DNS resolution otherwise AWS will not resolve the DNS server correctly.检查您的 VPC 是否同时具有 DNS 主机名和 DNS 解析,否则 AWS 将无法正确解析 DNS 服务器。 (NB it can take a while for it to come online, go brew a cuppa while you wait) (注意它可能需要一段时间才能上线,等待的时候去冲一杯咖啡)

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

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