4
votes

Ok, I am lost with where to to even troubleshoot this. I am trying to spin up a stack that has a basic app running in ECS. I will show the cloudformation below. But I keep getting:

service sos-ecs-SosEcsService-1RVB1U5QXTY9S was unable to place a task because no container instance met all of its requirements. Reason: No Container Instances were found in your cluster. For more information, see the Troubleshooting section.

I get 2 EC2 instances up and running but neither appear in the ECS cluster instances.

Here are a few of my theories:

  • is my user_data correct? do i need to sub the values?
  • what about the health check
  • my app is a sinatra app that uses port 4567. am i missing something with that?

Also, I basically started with this, http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-ecs.html and just streamlined it. So here is my current json, https://gist.github.com/kidbrax/388e2c2ae4d622b3ac4806526ec0e502

On a side note, how could I simplify this to take out all autoscaling? Just want to get it working in some form or fashion?

3

3 Answers

3
votes

In order for the ECS instance to join the cluster, the following conditions must be met:

  1. The agent must be configured correctly to connect to the correct cluster via the /etc/ecs/ecs.config file.
  2. The ECS instance must be assigned the correct IAM role to allow the ECS agent to access the ECS endpoints.
  3. The ECS instance must have a connection to the Internet to contact the control plane, either via igw or NAT.
  4. The ECS agent on the ECS Instance should be running.

UserData that should be used to configure /etc/ecs/ecs.config file.

#!/bin/bash
echo ECS_CLUSTER=ClusterName >> /etc/ecs/ecs.config

You can check reason for COntainer Instance not registering with Cluster in /var/log/ecs/ecs-agent.log*

1
votes

After reading Why can't my ECS service register available EC2 instances with my ELB? I realized the issue was my userdata. The values were not being substituted correctly and so the instances were joining the defualt cluster.

0
votes

Unable to place a task because no container instance met all of its requirements. Reason: No Container Instances were found in your cluster.

This usually means that your instances booted, but they're not healthy to register to cluster.

Navigate to Load Balancing Target Group of your cluster, then check the following

  • Health status of the instances in Targets tab.
  • Attributes in Description tab (the values could be off).
  • Health checks parameters.

If your instances are terminated, check system logs of terminated instances, and for any errors in your userdata script (check in Launch Configurations).

If the instances running, SSH to it, and verify the following:

  • The cluster is correctly configured in /etc/ecs/ecs.config.
  • ECS agent is up and running (docker ps). If it's not, start manually by: start ecs.
  • Check ECS logs for any errors by: tail -f /var/log/ecs/*.

Related: