ECS
Elastic Container Service- Run docker containers in
EC2machines - Components
ECS CoreprovisionEC2instance to rundockercontainerFargaterunECStask toAWS Provide Compute, more serverless thanECS CoreEKSisElastic Kubernetes ServicebyAWSECRisElastic Container RegistrybyAWSIAM SecurityandRolesare inECS TasklevelECScan enable dynamic port mapping withALBNLBECSsetup- For regular
EC2 Instanceinstall theECS Agentand editconfigfile - For
ECS ready Linux AMI, no need to installECS Agent, only edit theconfigfile - Editing the
configfile- Location
/etc/ecs/ecs.config - There are
35 Configurationto edit ECS CLUSTERECS_ENGINE_AUTH_DATAECS_AVAILABLE_LOGGING_DRIVERECS_ENABLE_TASK_IAM_ROLE
- Location
- If the associated ec2 instances are in stopped state and we terminate ecs, it will not be de-registered automatically
- When ecs client is stopped, the instance remain active with agent connection status false
- Cluster name is set up in
/etc/ecs/ecs.configfile
ECS Components
Task Definition: Allow port mapping.Port Mappingallows the container to send and receive traffic through the host machineService Schedular: Allow to run tasks manuallyContainer Instance: On which the container runs on, typically theec2 instanceorecs ready ec2 instanceContainer Agent: Allows the containers to connect with the cluster
Task Placement Strategy
Determine how the tasks will be placed between instances. ECS supports 3 types of Task Placement Strategies
binpack: Placed task by using least amount of CPU or memory. This minimize the number of instances are being usedrandom: Place tasks randomly. Make sure tasks are scheduled in instances with enough resources.spread: Placed tasks based on specified value (key-value pairs, instanceId or host). For example, if the field isinstanceIdthe task will be distributed evenly in different instances. Another example, if thefieldisaz, the tasks will be evenly distributed among availability zones.
When a container requires to listen to specic port,
- Specify the port for the container
- Put
0as the host port
In this case, the ECS will automatically assign the port.
Cluster Query Language
- Allow more fine grained way to place tasks
Using environment variables
- Use advanced task definition
- Define environment parameters under the task definition environment variables