Day-48 - ECS ☁️

Day-48 - ECS ☁️

Today will be a great learning for sure. I know many of you may not know about the term "ECS". As you know, 90 Days Of DevOps Challenge is mostly about 'learning new' , let's learn then ;)

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.

1 . 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.

2 . 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.

3 . 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.

4 . 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.

5 . 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.

  • Open your AWS management console and search for Elastic Container Service, and your interface will open like this

  • Now click on Get Started in the left-side navigation panel. Click on cluster, and then click on create cluster.

  • After that, in the cluster configuration, write your cluster name and choose AWS Fargate (serverless), and the rest of them will keep it as default. Click on Create, and now your cluster will be created.

  • In the left-side navigation panel, click on task definition and click on Create New Task Definition.

  • In the task definition configuration, write the name of the task, and in the infrastructure requirements In task size, select the CPU size up to 5 vCPU, and in memory, select 1 GB.

  • In the task role condition, what you have to do is create an IAM role for an ECS instance and attach the AmazonECSTaskExecutionRolePolicy. For that, follow these steps 👇

  • On the task definitions page, you will see the task role conditions. On the right side, you will see the IAM Console with a blue color. Click on it, and the IAM page will open.

  • Now click on Create role, select trusted entity type AWS services, select use case as Elastic Container Service, choose Elastic Container Services task, and click on Next.

  • Now attach the policy to the Add Permissions page called AmazonECSTaskExecutionRolePolicy, click on Next, write the role name as nginx-ecs-task-execution-role, and click on Create role.

  • Now come back to your AWS ECS page, and in the task role-condition and task-execution role, select the IAM you have created.

  • Now scroll down and you will see the Container-1 in that you have to write the container details Name as Nginx and in the image URL you can select from this link👈 and write the port name as nginx-80-tcp,and the rest of them all keep it as default and click on create.

  • Now you have successfully created a task definition for NGINX.

  • Now you have to create a service for that. Click on cluster and select the service you created in the service section. Click on create.

  • Now in the environment, keep it as default and scroll down, and you will see deployment configuration. There, you will see family, in which you have to select the task definition that you have created and write the service name as nginx-service and rest of them keep it as default and click on create.

  • Now wait for your cluster overview to be successful. In the cluster that you created, you will see tasks listed on it. Click on your task, and you will see Public IP Copy that and paste it in your new browser, and you will see that nginx is running on your server.


Happy Learning

Thanks For Reading! :)

-DevOpsParthu💝💥