Aws ECS - Elastic Container Service

Aws ECS - Elastic Container Service

·

3 min read

AWS ECS is a container service provided by AWS. AWS ECS simplifies the deployment, management, and scaling of containerized applications.

Components of ECS :

  1. Clusters - Clusters are grouping of EC2 instances or Fargate on which the containers are deployed.

  2. Task Definition - It defines how the containers should run. It includes informations like Docker image, CPU and memory requirements, networking, and more.

  3. Task - A task is an instantiation of a task definition.

  4. Services - Helps to maintain the running of specific number of instances.

Example :

Let's say you are ECS for microservice architecture.

  1. Clusters - Suppose your microservice based application has following services like user service, product service and order service. ECS cluster can be created to manage these services.

  2. Task Definition - You specify the docker image, amount of CPU and memory requirements and networks configurations for your services(user service, product service and order service).

  3. Task - It represents the running container. If you have a task definition for your user service, running a task using that task definition will start a container running the user service.

  4. Services - you can create a service for your user service that maintains three instances of the user service task at all times. If a task fails or becomes unhealthy, ECS automatically restarts it to maintain the desired count.

Working with ECS :

  1. Go to AWS console -> Search ECS -> Select create cluster.

  2. Give the ECS cluster name and select infrastructure and select create.

    Infrastructure - Can choose to use manual or serverless.

    i) Manual - Amazon EC2 can be created and used for running container.

    ii) Serverless - For serverless, AWS provides Fargate which allows to run containers without the need of managing the underlying infrastructures.

  3. Now we need to create task definition. Select task definition option under ECS and select new task definition.

  4. Enter the task definition family and infrastructure requirements for the container.

  5. Enter the container details, resource allocation limits and create the task definition.

    In this, I have used the container taken from Amazon ECR Public Gallery.

  6. Task definition is created and its status is Active.

  7. Now we need to create service. Go to Cluster -> Open the created cluster.

  8. Edit the deployment configuration.

  9. Create the service and you can see the status of service.

  10. Open the service-> select the tasks

  11. Open the task and copy the public Ip.

  12. Paste the IP in browser and the container is up and running.

    Conclusion :

    In this blog, we have seen about how to deploy and manage the conatiners using AWS ECS.

Did you find this article valuable?

Support Gopinath by becoming a sponsor. Any amount is appreciated!