DevOps, Day - 48

DevOps, Day - 48

ECS

ยท

4 min read

What is ECS?

  • ECS (Elastic Container Service) is a fully managed container orchestration service provided by Amazon Web Services (AWS). It allows you to run and manage Docker containers on a cluster of virtual machines (EC2 instances) without having to manage the underlying infrastructure.

  • With ECS, you can easily deploy, manage, and scale your containerized applications using the AWS Management Console, the AWS CLI, or the API. ECS supports both "Fargate" and "EC2 launch types", which means you can run your containers on AWS-managed infrastructure or your own EC2 instances.

  • ECS also integrates with other AWS services, such as Elastic Load Balancing, Auto Scaling, and Amazon VPC, allowing you to build scalable and highly available applications. Additionally, ECS has support for Docker Compose and Kubernetes, making it easy to adopt existing container workflows.

Overall, ECS is a powerful and flexible container orchestration service that can help simplify the deployment and management of containerized applications in AWS.

Difference between EKS and ECS?

  • EKS (Elastic Kubernetes Service) and ECS (Elastic Container Service) are both container orchestration platforms provided by Amazon Web Services (AWS). While both platforms allow you to run containerized applications in the AWS cloud, there are some differences between the two.

  • Architecture: ECS is based on a centralized architecture, where there is a control plane that manages the scheduling of containers on EC2 instances. On the other hand, EKS is based on a distributed architecture, where the Kubernetes control plane is distributed across multiple EC2 instances.

  • Kubernetes Support: EKS is a fully managed Kubernetes service, meaning that it supports Kubernetes natively and allows you to run your Kubernetes workloads on AWS without having to manage the Kubernetes control plane. ECS, on the other hand, has its own orchestration engine and does not support Kubernetes natively.

  • Scaling: EKS is designed to automatically scale your Kubernetes cluster based on demand, whereas ECS requires you to configure scaling policies for your tasks and services.

  • Flexibility: EKS provides more flexibility than ECS in terms of container orchestration, as it allows you to customize and configure Kubernetes to meet your specific requirements. ECS is more restrictive in terms of the options available for container orchestration.

  • Community: Kubernetes has a large and active open-source community, which means that EKS benefits from a wide range of community-driven development and support. ECS, on the other hand, has a smaller community and is largely driven by AWS itself.

In summary, EKS is a good choice if you want to use Kubernetes to manage your containerized workloads on AWS, while ECS is a good choice if you want a simpler, more managed platform for running your containerized applications.


1. Create an ECS Cluster:

  1. Sign in to the AWS Management Console and navigate to the Amazon ECS dashboard.

  2. Click on "Create Cluster."

  3. Choose the cluster type (EC2 or Fargate), configure the cluster, and create it.

    Our Cluster is created : )


2. Define a Task Definition:

  1. In the ECS dashboard, click on "Task Definitions."

  2. Click "Create new Task Definition."

  3. Choose the launch type compatibility (EC2 or Fargate).

  4. Configure the task definition, including the container image (e.g., Nginx), resource limits, and any environment variables.

    • Give the NGINX container image

    • Open gallery.ecr.aws/nginx/nginx

    • Copy the image URL

    • and paste it here as shown below.

    • Create the task definition.

    • Created successfully.


3. Create an ECS Service:

  1. In the ECS dashboard, click on "Clusters" and select your cluster.

  2. Click on "Create" in the "Services" tab.

  3. Configure the service, including the launch type (EC2 or Fargate), the number of desired tasks, the task definition created in the previous step, and networking settings.

  4. Create the service.

  5. Created the service.


4. Run Nginx in a Container:

  1. Your ECS service will start running Nginx containers based on the task definition.

  2. Access the running Nginx containers via the public IP or domain name associated with your EC2 instances or Fargate tasks. You may need to configure security groups and networking settings to allow inbound traffic on port 80 (HTTP) for Nginx.

  3. Zoom and check the path, down in containers we can see our image is created...

  4. click the image name, to see the port mappings (if required)

  5. To see our final result., we need to create a load balancer and target group

    please refer to my previous blogs to learn, how to create those : )

    Created target group

    created load balancer

  6. Now go to ECS --> select your cluster --> click on your cluster --> down in the service section, click on create --> scroll down to load balancer, and do as shown below --> click Create.

    Our service is created

  7. Now go to your load balancer --> copy your DNS and paste into the browser.


Thank you so much for reading

Follow me on LinkedIn to see interesting posts like this : )

Linkedin

ย