What is ECS?
Elastic Container Service(ECS) 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.
Task: Set up ECS (Elastic Container Service) by setting up Nginx on ECS.
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.
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 "NginxTask", 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.
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 Monitoring & Logging using CloudWatch.
Once review all the details, now click on 'Create'.
The task definition is successfully created.
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.
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.
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.
~ Abhisek Moharana ๐