In AWS, you can deploy containers in two methods. Those are EC2 and Fargate. AWS ECS Fargate is a compute engine for deploying containers without needing to configure too many services.
AWS ECS Fargate
Specifically, Fargate makes the process of deploying containerized applications simply because you Don’t need to provision servers, storage, and other infrastructure.
The only thing you need to do is provide AWS Fargate with a container image and deploy it as a service or a single task (container) to ECS.
In addition, if you use ECR, you can connect the two services and run your containers using an ECR stored image.
ECS was first released in 2017 and now is the recommended deployment method for most containerized applications.
Core services (AWS ECS)
Here are three core services that are needed to deploy containers into ECS. You must remember these three services, as you will need to follow the sequence of executing them.
Tasks are also important; however, they are limited and not likely to be used in large or production environments.
In an existing ECS cluster, you only need to create a task definition and a service to run your containers.
You can create task definitions without an existing ECS cluster.
AWS ECS EC2 Cluster
An AWS ECS EC2 cluster is the “old” deployment method of containers on AWS and is considered more complicated.
With ECS EC2, you need to provision EC2 instances that will run Docker; act as your container hosts; and manage storage, firewalls, and networking.
The setup time/effort to get an ECS EC2 cluster up and running is about ten times more than running ECS Fargate.
- Use an ECS EC2 cluster over Fargate if you have very specific requirements.
- You can’t run Windows containers on ECS Fargate and can run them only on ECS EC2 clusters.
- An ECS cluster is a logical unit of core services and tasks that form the ECS cluster; once the cluster is configured, containers can be deployed to it using task definitions.
- The cluster type defines which type of containers you can run, Linux or Windows.
- You can also define in which region your cluster will run and if you will use a Fargate or EC2 launch type. The difference between the two services is explained later in this chapter.
- You can have multiple clusters; for example, you can have Production, Test, and Development clusters, or you can have a Windows cluster for Windows containers and a Linux cluster for Linux containers.
- If needed, you can scale your cluster up or down using the ECS instances menu. You can also delete the cluster if you no longer need it.
To run a Docker container in ECS, you need a task definition that defines which image to use in the container, how much memory and CPU the container will use, the launch type (Fargate or EC2), networking options (the subnet and security group), logging options, the commands to run, and the volumes to use.
As you can see, the task definitions are important because they control the deployment type.
- If you need to run a single container without load balancing and more advanced features, ECS tasks can get the job done.
- Tasks are designed to help you deploy single containers; if you need a more advanced feature such as multiple containers, you use the next type of service, which is an ECS service.
To run a group of containers in ECS with multiple instances and load balancing, you create a service from a task definition and run your containers. An ECS service completes the process and deploys your container or containers.
Best Reference Book
Get new content delivered directly to your inbox.