ECS, ECR, Fargate Flashcards
What is Docker?
- Docker is a software development platform to deploy apps
- Apps are packaged in containers that can be run on any OS
Where can you store Docker Images?
- Docker Hub (https://hub.docker.com)
- Public repository
- Amazon ECR (Amazon Elastic Container Registry)
– Private repository
– Public repository (Amazon ECR Public Gallery https://gallery.ecr.aws)
Describe how to run Docker
- Create a Docker file
- Build the image
- Push / pull from Docker repository
- Run the image on the container
What is Amazon ECS?
- Amazon Elastic Container Service (Amazon ECS)
- Amazon’s own container platform
What is Amazon EKS?
- Amazon Elastic Kubernetes Service (Amazon EKS)
- Amazon’s managed Kubernetes (open source)
What is AWS Fargate?
- Amazon’s own Serverless container platform
- Works with ECS and with EKS
What is Amazon ECR?
Store container images
Describe Amazon ECS - EC2 Launch Type
- Launch Docker containers on AWS = Launch ECS Tasks on ECS Clusters
- EC2 Launch Type: you must provision & maintain the infrastructure (the EC2
instances) - Each EC2 Instance must run the ECS Agent to register in the ECS Cluster
- AWS takes care of starting / stopping containers
Describe Amazon ECS - Fargate Launch Type
- You do not provision the infrastructure (no EC2 instances to manage)
- It’s all Serverless!
- You just create task definitions
- AWS just runs ECS Tasks for you based on the CPU / RAM you need
- To scale, just increase the number of tasks. Simple - no more EC2 instances
What are the 2 main IAM roles setting you have to know for ECS?
- EC2 Instance Profile
– Used by the ECS agent
– Makes API calls to ECS service
– Send container logs to CloudWatch Logs
– Pull Docker image from ECR
– Reference sensitive data in Secrets Manager or SSM Parameter Store - ECS Task Role
– Allows each task to have a specific role
– Use different roles for the different ECS Services you run
– Task Role is defined in the task definition
Which Load Balancer integrations are supported with Amazon ECS?
- ALP
- NLB
Whats the usage of Data Volumes (EFS) in ECS?
- Mount EFS file systems onto ECS tasks
- Works for both EC2 and Fargate launch types
- Tasks running in any AZ will share the same data in the EFS file system
- Fargate + EFS = Serverless
What is the typical use case of EFS in ECS?
Persistent multi-AZ shared storage for your containers
What is ECS Service Auto Scaling?
- Automatically increase/decrease the desired number of ECS tasks
- Amazon ECS Auto Scaling uses AWS Application Auto Scaling
What are the metrics that can be used to setup Service Auto Scaling in ECS?
- ECS Service Average CPU Utilization
- ECS Service Average Memory Utilization - Scale on RAM
- ALB Request Count Per Target – metric coming from the ALB
What are the 3 scaling type that can be set in ECS Service Auto Scaling?
- Target Tracking – scale based on target value for a specific CloudWatch metric
- Step Scaling – scale based on a specified CloudWatch Alarm
- Scheduled Scaling – scale based on a specified date/time (predictable changes)
What can you set for ECR Rolling updates?
- Min healthy percent
- Max percent
List 3 ways to invoke ECS Task
- Amazon EventBride invoke rule
- Amazon EventBride Scheduler
- SQS queue polling for messages
What are ECS Task Definitions?
- Task definitions are metadata in JSON form to tell
ECS how to run a Docker container - It contains crucial information, such as:
– Image Name
– Port Binding for Container and Host
– Memory and CPU required
– Environment variables
– Networking information
– IAM Role
– Logging configuration (ex CloudWatch) - Can define up to 10 containers in a Task Definition
What happens if you are using EC2 Launch Type with a load balancer and you don’t define the host port for the container?
- We get a Dynamic Host Port Mapping if you define only the container port in the task definition
- The ALB finds the right port on your EC2 Instances
- You must allow on the EC2 instance’s Security Group any port from the ALB’s Security Group
How to provide ports in Fargate launch type with a load balancer?
- each task has a unique private ip
- only define the container port
Give an example how to setup Security groups if you are using Fargate Launch type with a LB
- ECS ENI Security Group
– Allow port 80 from the ALB - ALB Security Group
– Allow port 80/443 from web
Whats the best practice for IAM Roles for ECS Task definition
One IAM role for each unique Task Definition
What type of environment variables can be set in ECS?
- Environment Variable
– Hardcoded – e.g., URLs
– SSM Parameter Store – sensitive variables (e.g., API keys, shared configs)
– Secrets Manager – sensitive variables (e.g., DB passwords) - Environment Files (bulk) – Amazon S3