ECS - Elastic Container Service Flashcards

1
Q

What is ECS?

A

Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service

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

What is popular for ECS and Docker?

A

microservices and migration

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

Where are apps packaged in Docker?

A

in containers

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

What OSs, languages and technologies can be run into Docker containers?

A

any OS, language, or technology

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

How interact and how are impacted the Docker containers that are running on the same machine

A

they don’t interact with each other unless we tell them to and they don’t impact each other, so if one application is going crazy the other ones won’t be impacted

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

Where are Docker images stored?

A

Docker images are stored in Docker Repositories and there are two types of repositories:
o Public: Docker Hub https://hub.docker.com/
Find base images for many technologies or OS:
- Ubuntu
- MySQL
- NodeJS
- Java…
o Private: Amazon ECR (Elastic Container Registry)

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

What is the main difference between Docker and a VM?

A

Docker containers run on the Docker Engine which uses just 1 Guest OS.
Each app in a VM run on a Guest OS and these OS run on the Hypervisor

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

Whar are the ECS flavors?

A
  • ECS “Classic”
  • Fargate: ECS
  • EKS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is ECS “Classic”?

A

Provision EC2 instances to run containers onto.

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

What you must configure in EC2 to use ECS “Classic”?

A

We must configure the file /etc/ecs/ecs.config with the cluster name.

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

What is Fargate?

A

ECS Serverless, no more EC2 to provision

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

What is EKS?

A

Managed Kubernetes by AWS

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

What are ECS clusters?

A

logical grouping of EC2 instances running the ECS agent

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

What is the job of the ECS agent?

A

to register the instance to the ECS cluster

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

What can you say about the EC2 instances AMI used in an ECS cluster?

A

The EC2 instances run a special AMI, made specifically for ECS

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

Can you create an empty ECS cluster?

A

Yes, by just defining its name

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

In ECS “Classic” what kind of Instance Launch types can be used?

A

On-demand and spot instances

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

What Instance configuration can you define in an ECS “classic” definition?

A
o	EC2 instance launch type
o	EC2 instance type
o	# of instances.
o	EC2 AMI id.
o	EBS storage (GB).
o	Key pair.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How is CloudWatch integrated to ECS?

A

CloudWatch Container Insights: Each container will have a different log stream.

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

How is used the EC2 instances CPU and memory in ECS?

A

The EC2 instances in the cluster each have CPU and Memory values that are going to be shared among the containers.

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

What is created by default when you finish defining the ECS instance configuration?

A

By default, an Auto Scaling Group is created in the cluster based on your instance configuration provided in the cluster

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

When an instance in ECS starts how does it know to register to the cluster?

A

It uses the Instance User Data

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

What are ECS tasks definitions?

A

Tasks definitions are 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
24
Q

What are the 4 most important aspects defined in an ECS task definition?

A

o Docker Image
o Port Binding for Container and Host (no needed for Fargate)
o Memory and CPU required
o IAM Task Role

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

What is the network mode used by Fargate?

A

awsvpc

26
Q

What is an ECS Service?

A
  • ECS Services help define how many tasks should run and how they should be run
  • They ensure that the number of tasks desired is running across our fleet of EC2 instances.
27
Q

What you need to do when you update your ECS task definition?

A

Whenever you update the Task Definition you must update your Service to use latest task definition revision.

28
Q

What are the ECS service types?

A

Replica

Daemon

29
Q

What is the ECS service type used by Fargate?

A

Replica

30
Q

What is the ECS service type replica?

A

Places and maintains the desired number of tasks across your cluster. By default, the service scheduler spreads tasks across Availability Zones.

31
Q

What is the ECS service type daemon?

A

1 task per ECS instance. No need to specify a desired number of tasks, a task placement strategy, or use Service Auto Scaling policies. Useful for monitoring

32
Q

What are the most important aspects defined in an ECS service?

A
  • Launch type (EC2 or Fargate)
  • Task definition revision
  • Cluster
  • Number of tasks
  • Task placement (not in Fargate)
  • Load Balancing
  • Service Auto Scaling
33
Q

What are the ECS Service deployment types?

A
  • Rolling update

- Blue/green powered by CodeDeploy

34
Q

What you must do to define a Load Balancer for an ECS service?

A

a Load Balancer can only be set at service creation level, so you must create a new service

35
Q

What you must do to delete a service?

A

set the number of tasks to 0

36
Q

What happens if you have 1 instance running in your cluster running 1 task which has a port mapping 8080 -> 80 and you try to run a second task?

A

it will try to run it in the same instance with the same port mapping configuration and you will get this error. You can update your cluster number of instances to 2 and then it will deploy the second task in the second instance.

37
Q

What feature is provided by ALB for ECS?

A

The ALB has a feature named dynamic port forwarding which basically will route the traffic to the random port and basically spread our load on our different containers. This is how you run multiple same tasks on the same EC2 instance.

38
Q

What must be done in ECS task definition to work with the ALB?

A

You must create a new task definition revision by excluding any host ports. What will happen is that we just specify a container port and the host port becomes random.

39
Q

What you need to do on your EC2 instances if you set an ALB in front of your ECS cluster?

A

You need to update the EC2 instances security group to accept all protocols traffic from all the ports from the ALB security group

40
Q

What is ECR?

A

• A fully-managed container registry that makes it easy for developers to store, manage, and deploy container images.

41
Q

What if you get a permission error while trying to access ECR?

A

Check the IAM policy

42
Q

What you need to have in your computer to push an image to ECR?

A

Make sure you have Docker installed in your computer and either
• latest version of AWS tools for PowerShell (Windows)
• latest version of the AWS CLI (Mac/Linux).

43
Q

What are the steps to push an image to ECR?

A
  1. Create a Repository in ECR
  2. Authenticate in ECR using the CLI
  3. Build your docker image
  4. Tag the image so you can push it to the repository
  5. Push the image
44
Q

How can you authenticate in ECR using the CLI?

A
  • AWS CLI v1 login command

- AWS CLI v2 login command (newer)

45
Q

What is it about AWS CLI v1 login command in ECR?

A

It is about executing the output of

$(aws ecr get-login –no-include-email –region REGION)

46
Q

What is it about AWS CLI v2 login command in ECR?

A

1st part before the pipe (|) gives you the password used by the 2nd part to login.
aws ecr get-login-password –region REGION | docker login –username AWS –password-stdin ACCOUNT.dkr.ecr.REGION.amazonaws.com

47
Q

How do you scale in Fargate?

A

By increasing the number of tasks

48
Q

What you don’t define in Fargate?

A

Nothing related to EC2 instances. It is serverless

49
Q

What are the 2 most important ECS IAM Roles?

A
  • EC2 Instance Profile or ECS Instance Role

* ECS Task Role

50
Q

What is ECS EC2 Instance Profile?

A

Used by the ECS agent to make API calls to ECS service like sending container logs to CloudWatch Logs or pulling docker images from ECR

51
Q

What is ECS Task Role?

A

Allows each task to have a specific role with the minimum permissions. Use different roles for the different ECS Services you run. Task Role is defined in the task definition, 1 task role per task.

52
Q

What are the ECS Task Placement Strategies?

A
  • Binpack
  • Random
  • Spread
  • A combination of these
53
Q

What is Binpack ECS Task Placement Strategy?

A
  • Place tasks based on the least available amount of CPU or memory (it puts the tasks in the instance with more tasks).
  • This minimizes the number of instances in use (cost savings)
54
Q

What is Spread ECS Task Placement Strategy?

A
  • Place the task evenly based on the specified value.

* Example: instanceId, attribute:ecs.availability-zone

55
Q

What are the ECS Task Placement Constrains?

A
  • distinctInstance

- memberOf

56
Q

What is distinctInstance ECS Task Placement Constrain?

A

place each task on a different container instance

57
Q

What is memberOf ECS Task Placement Constrain?

A

places task on instances that satisfy an expression. Uses the Cluster Query Language (advanced).
I.e.: all the tasks should be placed on t2 instances

58
Q

What are the scaling policies used by ECS Service Auto Scaling

A

It uses the same auto scaling service as used in EC2 auto scaling groups
o Target Tracking
o Step Scaling
o Scheduled Scaling

59
Q

What can you do if you want to do ECS Service Auto Scaling + EC2 Auto Scaling in your cluster

A

Use ECS Cluster Capacity Provider

60
Q

What is ECS Cluster Capacity Provider?

A

A Capacity Provider is used in association with a cluster to determine the infrastructure that a task runs on

61
Q

What are FARGATE and FARGATE_SPOT capacity providers?

A

The FARGATE and FARGATE_SPOT capacity providers are added automatically to Fargate

62
Q

What you need to do to add a Capacity Provider to ECS “classic”?

A

For Amazon ECS on EC2, you need to associate the capacity provider with an auto-scaling group