Service discovery on aws ECS EC2 using bridge network

291 views Asked by At

we are running 8 micro services here we have client server and bfm (backed for fronted) need to talk other micro services (internally) how to configure this using bridge network because host port is dynamically allocated. i try to configure using cloud map with same namespace and try to access using (private)dns name but iam not getting any response please help me out

thank you in-advance.

In cloud map i have created namespace and choose instance discovery as API calls and DNS queries in VPCs to communicate each micro services here reference image in below

cloud map namespace info.

In task definition Launch type= Amazon EC2 instances, Network mode= bridge, Port mapping host port has = 0, container port as 3030, protocal= tcp, portname= master-3030-tcp, App protocol= HTTP,

create services using this task definition services name as "xyz", enable services discovery and select an existing namespace (created in aws cloud map), and services discovery service created new services discovery name as "abc", by default DNS record as SRV has show in below image DNS record type .

like same way i have created other services name as 123 and here am not enable services discovery becouse i need to talk to xyz services using 123 micro-services

i login to that ec2 instance try to communicate using dns to xyz microservices

using curl cmd: curl http://./path

curl: (6) Could not resolve host: . am geeting this error

1

There are 1 answers

0
Mark B On

There are a couple things wrong with your test:

  1. You used . as the hostname. It's entirely unclear what you are trying to do here, but . is surely not the name you used for your SRV record.

  2. curl isn't going to work with an SRV record. The curl command (and most other tools) will only look for DNS hostnames that are defined by A or CNAME records. You generally have to write your own code to query the SRV record, pull out the IP address and port from the response, and then pass those values into whatever tool you are using to make the actual connection to your service.

From the command line you would use nslookup -q=srv YOUR-SRV-RECORD-NAME to get the IP address and port. Then you would use curl http://HOSTNAME:PORT/path to connect to the service.