ECS, ECR & Fargate - Docker in AWS Flashcards

1
Q

How is Docker different from a Virtual Machine?

A

Resources are shared with the host -> many containers on one server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the EC2 Launch type work?

A

You must provision & maintain the infrastructure - the EC2 instances
- Each EC2 instance must run the ECS agent to register in the ECS cluster
- AWS starts/stops docker containers on the provisioned instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does ECS Fargate Launch type differ from EC2 Launch type?

A

You do not provision the infrastructure - no EC2 instances to manage.
- Serverless launch type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the EC2 Instance Profile used by and for?

A

EC2 Launch Type only:
- Used by the ECS agent
- Makes API calls to the ECS service
- Send container logs to CloudWatch logs
- Pull Docker image from ECR
- Reference sensitive data in Secrets Manager or SSM Parameter Store

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the ECS Task Role?

A
  • Allows each task to have a specific role (e.g., one task might fetch from S3, another from DynamoDB
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If you were to integrate ECS with a load balancer, which would be recommended out of ALB, NLB and Elastic Load Balancer and why?

A

ALB - works for most use cases
NLB - recommended only for high throughput / performance use cases, or to pair it with AWS Private Link
ELB - no advanced features, no Fargate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does EFS stand for?

A

Elastic File System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a use case for EFS, and why not S3?

A

Persistent multi-AZ shared storage for your containers - mount the EFS onto ECS tasks (works for both launch types), and any AZ will share the same data in the file system
- S3 cannot be mounted as a file system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What options can you scale on for ECS Application Auto Scaling?

A
  • ECS service average CPU utilization
  • ECS service average memory utilization (RAM)
  • ALB Request count per target (metric from the ALB)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Target Tracking?

A

Scale based on a target value for a Cloudwatch metric

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Step Scaling?

A

Scale based on a specific Cloudwatch alarm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Scheduled Scaling?

A

Scale based on a specified data/time (predictable changes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between ECS Service Auto Scaling and EC2 Auto Scaling?

A

ECS Service Auto Scaling - Fargate scales the number of taskst
EC2 Auto Scaling - EC2 scales the number of instances

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe two ways of Auto Scaling EC2 Instances

A

Auto Scaling Group Scaling:
- Scale your ASG based on CPU Utilization
- Add EC2 instances over time

ECS Cluster Capacity Provider
- Automatically provision and scale the infrastructure for you ECS tasks
- Capacity Provide is paired with an ASG
- Add EC2 instances when you’re missing capacity (CPU, RAM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is ECS Rolling Update?

A

Update from V1 to V2
Set min and max percentage of healthy tasks
- ECS will scale to provide new V2 tasks
- Terminate some V1 tasks, ECS will again scale to provide new V2 tasks
- Repeat until all tasks at V2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are Task Definitions?

A

Metadata in JSON form to tell ECS how to run a docker container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What information is listed in a Task Definition?

A
  • Image name
  • Port Binding for Container and Host
  • Memory and CPU required
  • Environment variables
  • Networking information
  • IAM role
  • Logging configuration (e.g., Cloudwatch)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Describe how you would set up ECS for Dynamic Host Port Mapping

A
  • EC2 Launch Type, ALB as Load Balancer
  • Within the Task Definition, only define the container port (not the host port)
  • Allow on the EC2 instance Security Group ANY PORT from the ALB’s Security Group
  • ALB will find the right port on the EC2 instances
19
Q

How does Fargate manage Load balancing?

A
  • Each task has a unique private IP
  • Only define the container port (not host port)
  • Fargate will expose that port on the private IP of each ECS task.
  • ECS ENI (Elastic Network Interface) Security group needs to allow the defined port from the ALB
  • ALB Security Group needs to allow 80/443 from the web.
20
Q

How do IAM Roles work with Task Definitions?

A
  • One IAM Role per Task Definition
  • Role is defined at the Task Definition level, not at the Service level.
21
Q

How could you provide a public URL to a Task Definition?

A

Hardcode the URL as an Environment Variable

22
Q

How could you provide sensitive data to a Task Definition?

A

SSM Parameter Store - sensitive variables (e.g., API keys, shared configs)
Secrets Manager - sensitive variables (e.g., DB passwords)

23
Q

How could you load many environment variables from a file to a Task Definition?

A

Load environment variables from an S3 bucket - bulk environment variables loading

24
Q

What is a Bind Mount?

A

A Data Volume mounted within the ECS task, allowing multiple containers in the same task definition to share data

25
Q

What Bind Mount do EC2 tasks use, and how is the data tied?

A

EC2 instance storage - data is tied to the lifecycle of the EC2 instance

26
Q

What Bind Mount do Fargate tasks use, how much data can you store, and how is the data tied?

A

Ephemeral storage - 20GiB-> 200GiB, data is tied to the container(s) using them

27
Q

What is a use case for Bind Mounts?

A
  • Share ephemeral data between multiple containers
  • “Sidecar” container pattern, where the “sidecar” container is used to send metrics/logs to other destinations
28
Q

What is ECS Task Placement, and where is it applicable?

A
  • ECS must determine where to place a new task of type EC2, with the constraints of CPU, memory and available port
  • The same for when a service scales in -> which task should be terminated.
  • Only applicable for ECS with EC2, not for Fargate
29
Q

What is the order in which ECS tries to place a task?

A
  1. Identify instances that satisfy the CPU, memory and port requirements found in the task definition
  2. Identify instances that satisfy the task placement constraints
  3. Identifier instances that satisfy the task placement strategies
  4. Select the instances for placement.
30
Q

What is the Binpack placement strategy?

A

Place tasks based on the least available amount of CPU or memory
- Pack as many tasks into as small a number of instances as possible (cost savings)

31
Q

What is the Random placement strategy?

A

Place the task randomly in the instances.

32
Q

What is the Spread placement strategy?

A

Place the task evenly based on the specified value, e.g., instanceId, availability-zone (can be used to maximize availability through spreading tasks across difference AZ)

33
Q

What is the distinctInstance placement constraint?

A

Place each task on a different container instance.

34
Q

What is the memberOf placement constraint?

A

Places task on instances that satisfy an expression (defined with the Cluster Query Language, e.g., “expression”:”attribute:ecs.instance-type =~ t2.*” - place only on instances that are of tier t2.)

35
Q

Where can you store Docker images in AWS?

A

ECR - Elastic Container Repository

36
Q

Describe at a high level how to log in to ECR via the CLI

A

Use AWS CLI to get login credentials from ECR, then pass these credentials into a docker login command - this will allow you to run docker commands like pull and push image.

37
Q

What does EKS stand for, and what does it do?

A

Elastic Kubernetes Service - Allows you to launch managed Kubernetes clusters on AWS.

38
Q

Why might you use EKS over ECS?

A

Kubernetes is open source, used by many cloud providers (which allows for a level of standardization).

39
Q

What is a use case for EKS?

A

Company is already using Kubernetes on-premises or in another cloud, and wants to migrate to AWS using Kubernetes

40
Q

Describe what is meant by EKS worker nodes and pods

A

Worker nodes - can be EC2 instances or Fargate serverless containers (and can be part of an ASG)
EKS pods - equivalent to tasks in ECS

41
Q

What is Managed Node Groups?

A

EKS creates and manages nodes (EC2 instances) for you
- Nodes are part of an ASG managed by EKS
- Supports On-Demand or Spot Instances

42
Q

What is Self-Managed Nodes?

A

Nodes created by you and registered to the EKS cluster and managed by an ASH
- Can use prebuilt AMI - Amazon EKS Optimized AMI
- Supports On-Demand or Spot Instances

43
Q

How would you attach data volumes to an EKS cluster?

A

Need to specify StorageClass manifest on you EKS cluster
- Leverages a Container Storage Interface (CSI) compliant driver