I'm trying to setup an AWS ECS service with service discovery using ansible using the following AWS ECS task definition:
- name: (define) Create gRPC AWS task definition
ecs_taskdefinition:
family: "my-grpc"
region: us-west-1
network_mode: bridge
state: present
execution_role_arn: "arn:aws:iam::495388981531:role/ecs-runtime-agent"
force_create: yes
containers:
- name: "my-grpc"
image: "my-custom-grpc-image"
essential: true
memoryReservation: 256
portMappings:
- containerPort: 9000
healthCheck:
command:
- "CMD-SHELL"
- "grpc_health_probe -addr=localhost:9000"
and the following AWS ECS service configuration:
- name: (deploy-commit) Start grpc service
ecs_service:
name: grpc
cluster: "my-cluster"
state: present
launch_type: EC2
force_new_deployment: yes
region: us-west-1
task_definition: "my-grpc"
scheduling_strategy: REPLICA
desired_count: 1
deployment_configuration:
deployment_circuit_breaker:
enable: true
rollback: true
maximum_percent: 200
minimum_healthy_percent: 100
service_registries:
- registryArn: "my-aws-cloud-map-service-discovery-arn"
containerName: "my-grpc"
containerPort: 9000
I've also created the service discovery service through the AWS web console beforehand.
When I run it, the service running on the container was able to run with the health check succeeding, but the ECS task was stopped with the following stopped reason:
The Service Discovery instance could not be registered.
What's wrong here? I can't find any way to debug this.
It turns out I did not enable DNS queries on the AWS Cloud Map Namespace. After enabling it, service discovery is working and the ECS service ran successfully.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.