amazon-ecs-cli icon indicating copy to clipboard operation
amazon-ecs-cli copied to clipboard

Service Discovery Problem

Open aanno opened this issue 4 years ago • 2 comments

Summary

Service Discovery Problem

Description

  • Which version of the CLI you are using? (Run: ecs-cli --version) ecs-cli version 1.21.0 (bb0b8f0)
  • What platform are you using to run ECS CLI commands? (E.g. Linux, macOS, Windows) Linux (Debian Buster/10)

Config files

  • docker-compose.yml
---
version: '3'
services:
  matching:
    image: ****.dkr.ecr.eu-central-1.amazonaws.com/matching
    ports:
      - "8080:8080"
    container_name: matching
    entrypoint: [
        "java",
        "-Xms512m", "-Xmx512m",
        "-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager",
        "-Dlog4j2.configurationFile=/app/resources/log4j2.xml",
        "-Dspring.profiles.active=aws_test",
        "-classpath", "/app/classes:/app/libs/*",
        "de.siteos.toyota.matching.tomcat.TomcatWithMatching"
    ]
    logging:
      driver: awslogs
      options:
        awslogs-stream-prefix: m
        awslogs-group: /ecs/matching
        awslogs-region: eu-central-1
  • ecs-params.yml
---
version: 1
# https://docs.aws.amazon.com/de_de/AmazonECS/latest/developerguide/cmd-ecs-cli-compose-ecsparams.html
task_definition:
  # ecs_network_mode: bridge
  # https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html
  ecs_network_mode: awsvpc
  task_size:
    cpu_limit: 512
    mem_limit: 1024
  services:
    matching:
      essential: true
run_params:
  network_configuration:
    awsvpc_configuration:
      subnets: 
        - subnet-***** 
      assign_public_ip: DISABLED
  service_discovery:
    container_name: matching
    container_port: 8080
    private_dns_namespace:
      id: ns-*****
    service_discovery_service:
      name: matching
      dns_config:
        type: A
        ttl: 120
  • ~/.ecs/config
version: v1
default: matching
clusters:
  matching:
    cluster: matching
    region: eu-central-1
    default_launch_type: EC2

Expected Behavior

As dns namespace ns-***** is 'local', I would expect to see my (successfully started) ecs instance having an DNS A record entry (at Route54) as matching.local. As the network mode is awsvpc, I would expect to see a (private) IP associated with the service. Both is not the case.

Observed Behavior

$ ecs-cli compose -p matching2 --verbose service up

Output:

DEBU[0000] Parsing the compose yaml...                  
DEBU[0000] Docker Compose version found: 3              
DEBU[0000] Parsing v3 project...                        
WARN[0000] Skipping unsupported YAML option for service...  option name=container_name service name=matching
DEBU[0000] Parsing the ecs-params yaml...               
DEBU[0000] Parsing the ecs-registry-creds yaml...       
DEBU[0000] Transforming yaml to task definition...      
DEBU[0000] Finding task definition in cache or creating if needed  TaskDefinition="{\n  ContainerDefinitions: [{\n      Command: [],\n      Cpu: 0,\n      DnsSearchDomains: [],\n      DnsServers: [],\n      DockerSecurityOptions: [],\n      EntryPoint: [\n        \"java\",\n        \"-Xms512m\",\n        \"-Xmx512m\",\n        \"-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager\",\n        \"-Dlog4j2.configurationFile=/app/resources/log4j2.xml\",\n        \"-Dspring.profiles.active=aws_test\",\n        \"-classpath\",\n        \"/app/classes:/app/libs/*\",\n        \"de.siteos.matching.tomcat.TomcatWithMatching\"\n      ],\n      Environment: [{\n          Name: \"JAVA_OPTS\",\n          Value: \"nothing\"\n        },{\n          Name: \"test\",\n          Value: \"test\"\n        }],\n      Essential: true,\n      ExtraHosts: [],\n      Image: \"986139801873.dkr.ecr.eu-central-1.amazonaws.com/toyotamatching\",\n      Links: [],\n      LinuxParameters: {\n        Capabilities: {\n\n        },\n        Devices: []\n      },\n      LogConfiguration: {\n        LogDriver: \"awslogs\",\n        Options: {\n          awslogs-stream-prefix: \"tm\",\n          awslogs-group: \"/ecs/matching\",\n          awslogs-region: \"eu-central-1\"\n        }\n      },\n      Name: \"matching\",\n      PortMappings: [{\n          ContainerPort: 8080,\n          HostPort: 8080,\n          Protocol: \"tcp\"\n        }],\n      Privileged: false,\n      PseudoTerminal: false,\n      ReadonlyRootFilesystem: false\n    }],\n  Cpu: \"512\",\n  ExecutionRoleArn: \"\",\n  Family: \"matching2\",\n  Memory: \"1024\",\n  NetworkMode: \"awsvpc\",\n  RequiresCompatibilities: [\"EC2\"],\n  TaskRoleArn: \"\",\n  Volumes: []\n}"
INFO[0000] Using ECS task definition                     TaskDefinition="matching2:1"
INFO[0000] Auto-enabling ECS Managed Tags               
INFO[0010] (service matching2) has started 1 tasks: (task 82aced7520af4194bf1eb985eba61320).  timestamp="2021-05-03 14:13:36 +0000 UTC"
INFO[0030] Service status                                desiredCount=1 runningCount=1 serviceName=matching2
INFO[0030] ECS Service has reached a stable state        desiredCount=1 runningCount=1 serviceName=matching2
INFO[0030] Created an ECS service                        service=matching2 taskDefinition="matching2:1"

Problems:

  • no expected service discovery DNS A record entry
  • no expected IP address for service

For me, it looks like awsvpc and service_discovery configuration in ecs-params.yml is (at least) partly ignored.

aanno avatar May 03 '21 14:05 aanno

Hi @aanno, did you had any luck resolving that? I'm facing a very similar issue.

qmihau avatar Oct 26 '22 16:10 qmihau

No, this project seems to be dead, and amazon is advertising https://github.com/aws/copilot-cli

aanno avatar Oct 27 '22 18:10 aanno