AWS Elastic Container Service

Mudit Mathur
7 min readJun 21, 2023

--

TABLE OF CONTENTS

1. What is ECS?

2. Difference between EKS and ECS

3. Task: Set up ECS (Elastic Container Service) by setting up Nginx on ECS.

3.1. Create an ECS cluster

3.2. Create a task definition

3.3. Create a service

3.4. Test the Nginx container

1. What is ECS?

ECS is a fully-managed container orchestration service offered by Amazon Web Services (AWS). It enables you to deploy and manage Docker containers on a cluster of virtual machines (EC2 instances) without the need to handle the underlying infrastructure.

ECS simplifies the process of running containerized applications by providing features such as automatic scaling, load balancing, and integration with other AWS services. It supports both the “Fargate” and “EC2 launch types,” giving you the choice to run containers on AWS-managed infrastructure or your own EC2 instances.

By leveraging ECS, you can easily deploy and scale containerized applications using the AWS Management Console, AWS CLI, or API. ECS integrates seamlessly with various AWS services like Elastic Load Balancing, Auto Scaling, and Amazon VPC, enabling you to build highly available and scalable applications.

Moreover, ECS offers compatibility with Docker Compose and Kubernetes, allowing you to leverage existing container workflows and tools. This flexibility makes ECS suitable for a wide range of containerized application deployments.

In summary, ECS is a robust and adaptable container orchestration service that streamlines the deployment and management of Docker containers within the AWS ecosystem.

2. Difference between EKS and ECS

EKS and ECS are both container orchestration platforms offered by Amazon Web Services (AWS), but they differ in their architecture and level of flexibility.

Architecture: ECS has a centralized architecture where a control plane manages container scheduling on EC2 instances. EKS, on the other hand, follows a distributed architecture where the Kubernetes control plane is distributed across multiple EC2 instances.

Kubernetes Support: EKS is a fully managed Kubernetes service, providing native support for running Kubernetes workloads on AWS without managing the control plane. ECS, however, has its proprietary orchestration engine and does not natively support Kubernetes.

Scalability: EKS is designed to automatically scale your Kubernetes cluster based on demand, handling the scaling of nodes and applications. ECS requires manual configuration of scaling policies for tasks and services.

Flexibility: EKS offers more flexibility as it allows you to customize and configure Kubernetes to meet specific requirements. ECS, being an AWS-managed service, has limited options for container orchestration compared to the extensibility of Kubernetes.

Community: EKS benefits from the large and active open-source Kubernetes community, which contributes to its ongoing development and support. ECS has a smaller community and relies more on AWS-driven development and support.

In summary, EKS is a suitable choice if you prefer the flexibility and extensibility of Kubernetes for managing container workloads on AWS. ECS is a more managed and streamlined option, providing simplicity and ease of use for running containerized applications.

3. Task: Set up ECS (Elastic Container Service) by setting up Nginx on ECS.

3.1. Create an ECS cluster

In the ECS service, click on “Create Cluster”.

Configure the cluster settings, such as the cluster name, VPC, and subnet.

We are using Fargate as Serverless and now Click on ‘Create’.

The cluster is successfully created.

In the CloudFormation-Stack we can view the logs of Cluster Creation.

In the Cloud Formation, we can see the events of cluster creation.

3.2. Create a task definition

In the ECS service, click on “Task Definitions”, and then click on “Create new Task Definition”.

Set the container name to “nginx”, and copy and paste the Image URL from the ‘Amazon ECR public gallery’ site. Specify the port mappings for HTTP, by setting the “Container port” to 80.

Configure the details

Browse Amazon ECR public gallery and search for nginx image and copy that image URL.

ECR Public Gallery

Official NGINX Docker Image ECR

Click on ‘Next’

Choose the Fargate launch type, Configure the task settings, such as the task memory and CPU limits, here CPU is .5vCPU and the memory is 3GB.

We can Monitor & Logging in using CloudWatch.

Once review all the details, now click on ‘Create’.

The task definition is successfully created.

3.3. Create a service

In the ECS, click on “Clusters”, and select the cluster that you created.

Click on “Create Service.

Choose the task definition that you created in the above steps.

In the Task Definition provide all the service names and task names.

In the Networking Tab, configure the service settings, such as the VPC, subnet, and security group settings.

Create a new security group. Specify the port mappings for HTTP with port 80.

Once review all the details, then click on ‘Create’.

Service is successfully created.

Once the ECS service is running, test the Nginx container by accessing the public IP address of the Fargate task in a web browser. You can find the public IP address in the “Tasks” tab of the ECS service, under the “Configuration” section.

3.4. Test the Nginx container

Click on the ‘Cluster’ that you created.

Click on ‘Task’.

In the task, go to the ‘configuration’ section, there you can find public IP.

Browse the Public IP address, you can see the default Nginx welcome page.

Browse the Public IP address, you can see the default Nginx welcome page.

Browse the Public IP address, you can see the default Nginx welcome page

Thank You,

I want to express my deepest gratitude to each and every one of you who has taken the time to read, engage, and support my journey.

Feel free to reach out to me if any corrections or add-ons are required on blogs. Your feedback is always welcome & appreciated.

~Mudit Mathur🙂

https://www.linkedin.com/in/mudit-mathur-535786146/

--

--

Mudit Mathur
Mudit Mathur

No responses yet