ECS
Elastic Container Service
- Run docker containers in
EC2
machines - Components
ECS Core
provisionEC2
instance to rundocker
containerFargate
runECS
task toAWS Provide Compute
, more serverless thanECS Core
EKS
isElastic Kubernetes Service
byAWS
ECR
isElastic Container Registry
byAWS
IAM Security
andRoles
are inECS Task
levelECS
can enable dynamic port mapping withALB
NLB
ECS
setup- For regular
EC2 Instance
install theECS Agent
and editconfig
file - For
ECS ready Linux AMI
, no need to installECS Agent
, only edit theconfig
file - Editing the
config
file- Location
/etc/ecs/ecs.config
- There are
35 Configuration
to edit ECS CLUSTER
ECS_ENGINE_AUTH_DATA
ECS_AVAILABLE_LOGGING_DRIVER
ECS_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.config
file
ECS Components
Task Definition
: Allow port mapping.Port Mapping
allows 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 instance
orecs ready ec2 instance
Container 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 isinstanceId
the task will be distributed evenly in different instances. Another example, if thefield
isaz
, 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
0
as 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