Please enable JavaScript.
Coggle requires JavaScript to display documents.
ECS PART 1 - Coggle Diagram
ECS PART 1
-
ECS with EC2
- You need to create the EC2
- You need to take care of EC2 instances
- You need to define CPU and memory for these EC2s
We have two types of lunch ECS. They are Fargate, and EC2
ECS with Fargate
- It's serverless
- You don't need to provision the infrastructure
- You just need to have the image and be happy
- You need to create a task definition
- You can define CPU and RAM
- You can scale in and out
ECS with EC2 Instance (IAM ROLE)
- You can create EC2 instance profile (IAM ROLE) to connect to others AWS services
ECS with ECS TASK ROLE (IAM ROLE)
- You can define a specific role for each task
- You can use different roles for the different ECS services
- You define it in the task definition
ECS with ELB
- You can use it using ALB, NLB (you can use AWS Private Link), and Classic Load Balance (only with EC2)
ECS with EFS (Storage)
- Mount EFS file system onto ECS Task
- Works with both EC2 and Fargate
- Each task are going to have access to the file system
- Fargate + EFS = serveless
- You can use persistent muilti AZ shared storage
ECS Auto Scaling
- You can increase and decrease the number of the tasks
- You can do it using CPU, Memory, Request Count Per Target (metric coming from the ALB)
- You can use target tracking = sacle in and out using cloud watch metric
- You can use step scaling = scale in and out using cloud watch alarm
- You can use schedule scaling = scale in and out specific date and time
- ECS scaling is different between EC2 auto scaling
- Fargate is simpler than ec2
ECS Rolling Updates
- You can control how many tasks can be started and stopped and which order
- Minimun health percet 100 x Maximum percent 200
- Min 50% and Max 100% -> In this case with 4 tasks, you are going to lose 2 (50%) and create 2 with v2 until get 100% again
- Min 100% and Max 150% -> In this case with 4 tasks, you are going to add 2 tasks and delete 2 old tasks until get 100% again
ECS tasks invoked by Event Bridge
- Event Bridge is an aws service to receive events
- After receive the events it's going to create a tasks to process it on S3 and put it in the database
ECS tasks invoked by schedule
- You can do the same thing before but in this time you are going to process by time
ECS tasks invoked by SQS
- You can do the same thing before but in this time you are going to process by message
ECS - Intercept Stopped Tasks using Event Bridge
- This way you can receive if there is some tasks that died
- Task died -> Event Bridge -> SNS (AWS service to send email) -> EMAIL
ECS Task Definition - EC2
- Task definition is a JSON form to tell ECS how to run a docker container
- Image name, port binding, host, memory, CPU, environment variables, networking information, IAM ROLE, Logging configuration (ex cloud watch)
- You can define 10 containers in 1 task definition
- If you use task definition with ELB. The ELB is going to define the port dynamically
Fargate
- Each task is going to have a unique private IP
- Only define the container port (host port is not applicable)
ECS + IAM ROLE
- You need to define IAM ROLE
ECS + ENVIRONMENT VARIABLES
- Hardcoded
- SSM Paramater Store - sensitive variables (API keys, shared configs)
- Secrets Manager - sensitive variables (DB passwords)
- You can add these variables using S3 with a file
- Sidecar container pattern
-