[Hands-On] Master ECS: Deploying Containers on AWS

Amazon Elastic Container Service (ECS) is a fully managed container orchestration service provided by Amazon Web Services (AWS).

Deploying Containers on AWS

Containers have revolutionized cloud deployments, and AWS offers two powerful services to run them: Amazon ECS (Elastic Container Service) and Amazon EKS (Elastic Kubernetes Service). But which one should you use?

ECS (Elastic Container Service)

Features:

Fully managed container orchestration
Deep AWS integration (IAM, ALB, Fargate, etc.)
Easier to set up and manage
Ideal for teams looking for simplicity

Key concepts related to ECS

Task Definition: A task definition is a blueprint for our application. It defines various parameters, including the Docker image, CPU and memory requirements, network settings, and other configurations. It is used to create tasks, which represent the running containers in your cluster.

Service: A service is a long-running task definition that runs and maintains a specified number of instances of a task definition. It ensures that the desired number of tasks are constantly running in the cluster.

Services enable you to define the desired state of your applications, such as the number of tasks, the task definition to use, and the network configuration.

ECS Cluster: An ECS cluster is a logical grouping of tasks or services. It is the compute infrastructure that ECS uses to run your applications. A cluster can span multiple Availability Zones for high availability.

Application Load Balancer (ALB): An Application Load Balancer is a service that automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, and IP addresses.

[Hands-ON]

  1. Creating a Cluster using EC2 Launch type

  2. Create a Task Definition File

  3. Create a service

  4. Set up Load Balancer

Steps

  1. Open aws account , and in the search bar type ECS

  2. You will see something like then click on cluster button

3. Select or type all the selected/higlighed options . I have named cluster myCluster but you can name it anything. We are going to use EC2 launch type for our running our container instance .

4. This is going to create a auto scaling template for our cluster . We can practically select any AMI. I have selected t2.micro instance as this is free under free tier .

  1. Rest option we will leave as default and click on create cluster .

    1. It will take some time to create cluster.

    2. In the meantime, we will create our task definition.

    8. Now click on create task definition

    9. Click on create task definition , and select the following values .

    we will name our task myTask . Again we specify that we want to run our task on EC2 instance .

    1. We will select linux as the operating system ,and select awsvpc as the networking model. We will select 0.25 as the vCPU , and 0.25 GB RAM as in t2.micro instance we have 1 vCPU and 1GB ram.

    1. Now we have to select image for our container , I have selected nginx image, this is being host on the docker hub . You can select any image on the docker or even on the ecr , and as this is a public image , we don’t need to provide any credentials.

    1. Now both our task and cluster has been created. Its time to create a service to deploy on our cluster and configure load balancer .

    2. Now both our task and cluster has been created. Its time to create a service to deploy on our cluster and configure load balancer.

    3. Now go back to the cluster , and click on it .

    1. We will keep most of the setting default, In the family section , we will select the task we have just created and we will keep desired task to 1 , this refer to number of tasks we want to run in this service.

    1. Now we will configure the load balancer , scroll down you can find the load balancer option. Select these settings, most of the option are pre filled we just have to specify the name of the target group.

    17. This will take some time for ALB to be created and service to be started on the cluster.

    18. To connect to our application , we have to find the DNS name of the ALB .

    19. In the EC2 section , you will find the ALB section at bottom.

    20. Click on the Load Balancer and copy the DNS of the ALB we have created and open this in the browser.

    EKS (Elastic Kubernetes Service)

Features:
Fully managed Kubernetes on AWS
More flexibility & portability (multi-cloud, hybrid)
Best for teams familiar with Kubernetes
Requires more setup and management

Hands-on for EKS- Will cover later.

Hands-on AWS content is highly valuable for practical learning. As part of AWS Hands-on Topics covering all major AWS services. Today as this is our first hands-on,so starting with Launching of EC2 instance.

Featured

DevOps is a set of practices, tools, and a cultural philosophy that automate and integrate the processes between software development and IT teams.

In this article, we will discuss most important Interview Questions related with different tools, practices and culture.

The Essentials

Linux is an open-source, Unix-like operating system kernel that powers a wide range of devices, from servers and supercomputers to smartphones and embedded systems.

Shell scripting is the process of writing scripts using a shell (like Bash, Zsh, or KornShell) to automate tasks in Linux and Unix-based systems.

Amazon Web Services (AWS) is a cloud computing platform that provides scalable, on-demand computing, storage, and networking services.

Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications.

Kubernetes - Errors, Troubleshooting & Fix

In this article, I have discussed different Kubernetes errors, Causes, Troubleshooting steps , fixxing issue and also suggesting preventive tips for every issue.

Connect with Me

Until next time,

Reply

or to participate.