Day-48 ECS(Elastic Container Service) (Jan 13, 2024)
Hey Learners! Welcome back. Today will be a great learning for sure. As we know, the 90DaysOfDevOps challenge is mostly about "Learning New" so in this challenge we'll learn about AWS service ECS. Let's start...
What is ECS?
Elastic Container Service (ECS) is a fully managed container orchestration service provided by AWS. It allows us to run and manage Containers on a cluster of EC2 instances without having to manage the underlying infrastructure.
With ECS, we can easily deploy, manage, and scale containerized applications using AWS CLI, AWS Management Console, or the APIs. ECS supports both Fargate and EC2 launch types, which means we can our container on AWS-managed infrastructure (Fargate) or your own created infrastructure on AWS (EC2 instances).
ECS also integrates with other AWS services, such as ELB, Auto-Scaling and VPC, allowing you to build scalable and highly available applications. Additionally, ECS has support for Docker Compose and K8s, making it easy to adopt existing container workflow.
Overall, ECS is a powerful and flexible container orchestration service that can help simplify the deployment and management of containerized applications on 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 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.
Task:- Set up ECS (Elastic Container Service) by setting up Nginx on ECS
First, we have to create a cluster. Search for ECS service select Clusters from the left navigation pane and click Create cluster.
Enter the name for Cluster and select AWS Fargate as infrastructure for cluster configuration. Leave another setting as default and click Create.
You will get your ECS cluster created successfully.
Now, we have to create a Task definition as a service or task. Select Task definition from the left navigation pane and click Create new task definition.
Enter the name for the task definition. Select AWS Fargate as the Launch type. Choose OS and size for CPU and Memory. Choose the Task role as None and the Task execution role as Create new role.
In the container section, we have to put details of the container like Name, Image URL, etc. To store custom container images AWS provides ECR service where you can store your container images publically or privately.
For this demo, we can directly have images from a public repository.
Do the Port Mapping as per the requirement of the application.
Leave the other setting as default and click Create.
Now task definition is created successfully and It is Active but container is not Active yet to do so select the Task definition created. Select Deploy and choose Run task.
Choose the cluster from the drop-down menu and click Create.
Now select the cluster goto Tasks section.
Select the listed task which is running. you will see the details for the same.
Copy the Public IP and enter it on the new tab you'll see the welcome page for Nginx.
This is how you can deploy any container with the help of ECS service. This service is not Free so don't forget to delete the created resources. To delete the Task definition first Deregister the same then only it will allow you to delete.
Thank you so much for taking the time to read till the end! Hope you found this blog informative.