ECS Fargate and multi‐container deployments - rajeshamdev/containers-orchestration GitHub Wiki
Containers Orchestration Components
Control plane and the data plane:
The control plane consists of the cluster control components that expose APIs and interfaces to define, deploy, and manage the lifecycle of containers. For Amazon Elastic Container Service (ECS), you interact with the control plane by using the Amazon ECS API.
The data plane is the infrastructure that provides the capacity for containers to run, such as CPU, memory, network, and storage.
Amazon ECS
Amazon ECS is a highly scalable and fast container-management service. You can use it to run, stop, and manage containers on a cluster. With Amazon ECS, your containers are defined in a task definition that you use to run an individual task or a task within a service. In this context, a service is a configuration that you can use to run and maintain a specified number of tasks simultaneously in a cluster. You can run your tasks and services on a serverless infrastructure that's managed by AWS Fargate. Alternatively, for more control over your infrastructure, you can run your tasks and services on a cluster of Amazon Elastic Compute Cloud (Amazon EC2) instances that you manage. For more information about Amazon ECS, see What is Amazon Elastic Container Service
Core concepts for Amazon ECS
-
Cluster: A logical grouping of tasks or services. Your tasks and services are run on infrastructure that’s registered to a cluster, such as AWS Fargate nodes, EC2 instances, or remote virtual machines (VMs). For more information about clusters for Amazon ECS, see Amazon ECS clusters.
-
Container instances: A container instance is an EC2 instance that’s a part of your Amazon ECS cluster. A container instance isn’t the same as a task, which contains a running instance of your container. For more information about container instances, see Amazon ECS container instances.
-
Container agent: The container agent allows container instances to connect to your Amazon ECS cluster. For more information about the Amazon ECS container agent, see Amazon ECS container agent
-
Task definition: A task definition contains configuration information for the containers you want to run on Amazon ECS. You need to create a task definition to run containers on Amazon ECS. Task definitions include parameters, such as the following:
- The Docker image to use with each container in your task.
- How much CPU and memory to use with each task or each container within a task.
- The launch type to use, which determines the infrastructure where your tasks are hosted.
- The Docker networking mode to use for the containers in your task.
- The logging configuration to use for your tasks.
- Whether the task should continue to run if the container finishes or fails.
- The command the container should run when it’s started.
- Any data volumes that should be used with the containers in the task.
- The AWS Identity and Access Management (IAM) role that your tasks should use.
For more information about task definitions, see Amazon ECS task definitions.
- Task: A task is a running instantiation of your task definition.
- Service: A service runs a specified number of tasks simultaneously on your cluster. For more information about services, see Amazon ECS services
Scheduling tasks with Amazon ECS
To run a task on Amazon Elastic Container Service (Amazon ECS), you must schedule it. The scheduling engine determines how and when to launch a task. There are multiple ways you can schedule tasks: through service scheduling, manual scheduling, cron scheduling, or by using custom schedulers. For more information about scheduling tasks on Amazon ECS, see Scheduling Amazon ECS tasks.
Placing tasks with Amazon ECS
After you determine when you want to run a task through scheduling, Amazon ECS then needs to determine where to run the task, and how to place that task based on requirements that you define. For more information about task placement on Amazon ECS, see Amazon ECS task placement.
Launch types
For Amazon ECS, the launch type you choose, either EC2 or Fargate, is chosen when you run a service or launch a task.
- Fargate launch type: Run your containerized applications without the need to provision and manage the backend infrastructure. AWS Fargate is the serverless way to host your Amazon ECS workloads.
- EC2 launch type: Run your containerized applications on Amazon EC2 instances that you register to your Amazon ECS cluster and manage yourself.
For more information about launch types, see Amazon ECS Launch types.
Capacity providers
Capacity providers manage the infrastructure that the tasks in your clusters use. For more information about capacity providers and how to use them, see this blog post by Adam Keller: Managing compute for Amazon ECS clusters with capacity providers. For more detailed information about capacity providers, see Amazon ECS capacity providers.
Scaling your cluster
Amazon ECS cluster auto scaling provides control over how you scale the Amazon Elastic Compute Cloud (Amazon EC2) instances within a cluster. When you use managed scaling, Amazon ECS creates the infrastructure for the Auto Scaling group capacity provider, and manages the scale-in and scale-out actions of the Auto Scaling group based on your clusters' task load. For more information about cluster auto scaling, see Amazon ECS cluster auto scaling.
Scaling your tasks
To scale your tasks automatically based on demand, you can use service auto scaling. Amazon ECS publishes Amazon CloudWatch metrics with your service’s average CPU and memory usage. You can then use these metrics to scale your service as demand changes. For more information about scaling tasks, see Service auto scaling.
Service Discovery with AWS Cloud Map
Amazon ECS uses AWS Cloud Map for service discovery. For more information about how Amazon ECS integrates with AWS Cloud Map, see Service Discovery
For more information about Amazon Elastic Container Service (Amazon ECS), consider watching AWS conference talks on YouTube, such as AWS re:Invent 2021 - The powerful simplicity of Amazon ECS.
Amazon ECS best practices
For more information about best practices with Amazon ECS, see Amazon Elastic Container Service Best Practices Guide.
Amazon ECS troubleshooting To collect diagnostic information and troubleshoot issues quickly, you can Use Amazon ECS exec for debugging. For more information about troubleshooting Amazon ECS deployments, see Amazon ECS troubleshooting.