skip to Main Content

In Kubernetes cluster pods can easily communicate using its dns names or ip. Like this how can I know dns name of any container and communicate between two containers between 2 different EC2 machines.

2

Answers


  1. In Kubernetes, cluster pods use kube-dns to connect between them.

    So in ECS, it has its service discovery itself. Or if you want to connect tasks in the same cluster, you can use their names to connect.

    An example is here

    Login or Signup to reply.
  2. For other people that come here, if your containers are in the same cluster but in different services a good choice can be aws Ecs Service Connect
    Try to make your implementation by aws cli or by cloudformation. At least until today(20.03.2023) I found the info for implementation via the aws console confusing.
    So if you decide by console pay attention to the task definition json and check the following fields, in your Task Definition, have been properly configured:

     "portMappings": [
                {
                    "name": "port_name",
                    "containerPort": port_numb,
                    "hostPort": 9000,
                    "protocol": "tcp",
                    "appProtocol": "http"
                }
    

    And pay attention to the network mode documentation explaining that the default value is bridge but you need to specify:

       ......
      "networkMode": "bridge",
       ......
    

    The rest of explanation is quite well explained and keep in mind with network mode bridge you can control and to see containers at docker level but with is awsvpc you need to create security groups for containers and save DNS records pointed on AWS Cloud Map and I think this can be another scenario

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search