FoxuTech

How to Create ECS Cluster on AWS

How to Create ECS Cluster on AWS

ECS is the AWS Docker container service that handles the orchestration and provisioning of Docker containers. This is a beginner level introduction to AWS ECS. I’ve seen some nightmare posts and some glowing reviews about the ECS service so I knew it was going to interesting to get my hands dirty and see what ECS was all about.

Summary of the ECS Terms

First we need to cover ECS terminology:

Some of AWS terms will confuse while we start working on it. Better to refer AWS provided detailed diagrams to help explain it.

In this tutorial example will create the sample httpd web service with Amazon sample webpage.

The ECS First Run Wizard provided in the Getting Started with Amazon ECS documentation performs the similar above with a CloudFormation template and ECS API calls. Will do it one by one, step by step to understand better.

Step1: Create Task Definition

In this step we have to mention the task definition name and container name and which image we would like to use in image section. And also we can limit the container usage using hard limit and soft limit. Once hard/soft limit set, have to set the port forwarding with hostport:containerport with protocol details either TCP or UDP.

If you like to limit the container usage or want to add more parameters like storage, mount point, entry point etc click advanced options for that.

Once you done, all click next step to proceed.

Step2: Configure service

Create a service with no of task you would like to and in network access select the container name which we created on last step.

If you would like to add application load balancer select the option “use the application Loadbalancer” and mention the port details as mentioned and mention the “Application Load Balancer target group name”.

You can select the IAM Role which is already exist or create the new one based on the requirement.

Once you done all required details, client next step to configure the cluster.

Step3: Configure the Cluster

In this mention the cluster name and EC2 instance type which you would like to create. And number of instance you would like to create.

Read More: What is Amazon Container Server

Then select the keyfile which you have for SSH a instance. If you missed, you cannot SSH a machine, so make sure you picked one.

And Securitygroup which you would like to use select it and Pick or create IAM role and click next to proceed.

Step4: Launch

Check each details and click launch instance to create the First ECS Cluster.

Once all launched successfully, you will see all Green. Like below. 

Step5: Confirm Everything is Working

Confirm that the service is running properly. You want to be thorough about confirming that all is working by checking a few things.

Read More: What is Amazon Container Server

Check that my-target-group is showing and maintaining healthy targets. Under Load Balancing / Target Groups, click on my-target-group and check the Targets tab. You should see a Target that is reporting healthy.

# ssh ec2-54-201-158-18.us-west-2.compute.amazonaws.com
# docker ps
# curl ec2-54-201-158-18.us-west-2.compute.amazonaws.com

Step6: Scale Up the Service to 4 Tasks

This is the easiest part. To scale up and add more containers simply go to Clusters / my-cluster / my-service and click on “Update Service”. You can change “Number of tasks” from 1 to 4 there. After only a few moments you should see 4 running tasks. That’s it!

Read More: What is Amazon Container Server

Exit mobile version