ECS(Elastic Container Service) ECS is one of the container services used in the aws, which is also called a container orchestration...
ECS(Elastic Container Service)
ECS is one of the container services used in the aws, which is also called a container orchestration service. It is easy to run, stop, and manage Docker containers on a cluster. Ecs was highly scalable and faster. It can Host a cluster on a serverless infrastructure managed by ECS. It launches services or tasks by using the fargate launch type.
We have Two Types of ECS launch types.
ECS launch types:
Fargate Launch Type
EC2 Launch Type
Fargate Launch Type: AWS Fargate is a technology that you can use with Amazon ECS to run containers without having to manage servers or clusters of Amazon EC2 instances
it allows to the running of a containerized application without provision and manage backend infrastructure, just register a task definition it will launch the container.
Ec2 launch type: EC2 launch type allows you to run your containerized applications on a cluster of Amazon EC2 instances that you manage.
Amazon ECS is a regional service that simplifies running application containers in a highly available manner across multiple Availability Zones within a Region.
You can create Amazon ECS clusters within a new or existing VPC.
After a cluster is up and running, you can define task definitions and services that specify which Docker container images to run across your clusters.
Container images are stored in and pulled from container registries, which may exist within or outside of your AWS infrastructure.
Container and images:
A Docker container is a standardized unit of software development, containing everything that your software application needs to run: code, runtime, system tools, system libraries, etc. Containers are created from a read-only template called an image.
Images are typically built from a Docker file, a plain text file that specifies all of the components that are included in the container. These images are then stored in a registry from which they can be downloaded and run on your cluster.
Task definition:
To run your prepared application in ECS to create a task definition. It is a text file in JSON format, that describes one or more containers, up to a maximum of ten, that form your application.
Tasks and Scheduling:
Creating a task definition for the application within the ECS can specify no of the tasks that will run on your cluster.
Each task uses the fargate launch type is own isolated boundary. It cannot shares the underlying kernel, CPU resources, memory resources, or elastic network interface with another task.
Scheduler placing the tasks within the cluster
Types of scheduling
Service scheduler:
It is suitable for long-running tasks and applications
It has a strategy to reschedule tasks once the already scheduled task failed
Two service scheduler:
Replica:---> it maintains the desired number of tasks across the cluster. The default task scheduler spread tasks across the availability zone.
Daemon:--> it deploys one task for each active container instance that meets the task placement constraints specified in your cluster. there is no need to specify a desired number of tasks, a task placement strategy, or use Service Auto Scaling policies
Manually Running Tasks--> The Run Task action is ideally suited for processes such as batch jobs that perform work and then stop
Running Tasks on Schedule(LIKE CRON)--> If the tasks are set to run in a particular interval in the cluster. Tasks like backup, and log scan.
Create a log watch event rule to run one or more tasks in the cluster at a specific time like a cron job.
Custom Schedulers--> ECS allows the third party scheduler. we can create our own scheduler.
Custom schedulers are only compatible with tasks using the EC2 launch type. If you are using the Fargate launch type for your tasks, the Start Task API does not work.
Cluster:
When you run tasks using Amazon ECS, you place them on a cluster, which is a logical grouping of resources. When using the Fargate launch type with tasks within your cluster, Amazon ECS manages your cluster resources.
When using the EC2 launch type, then your clusters are a group of container instances you manage.
An Amazon ECS container instance is an Amazon EC2 instance that is running the Amazon ECS container agent.
Amazon ECS downloads your container images from a registry that you specify and runs those images within your cluster.
Container agent:
It allows the container instances to connect with the cluster.
It has already been included in the ECS-optimized Ami’s but can also install ec2 instance, ec2 only supports container agents.
The architecture of an Amazon ECS environment run on AWS Fargate: