Section 16: ECS, ECR & Fargate - Docker in AWS Flashcards
What’s ECS stand for?
Elastic container service
T/F: Docker is a software dev platform to deploy apps. Use cases include microservices architecture, lift and shifting apps from on premise to the cloud
T
Docker images are stored in Docker repositories Docker Hub and Amazon ECR (Amazon Elastic Container Registry). Identify whether those two have public and/or private repository options.
- Docker Hub: public repos only
- Amazon ECR: private and public repos.
What does ECR stand for?
Elastic Container Registry
Running apps using docker vs using virtual machines. Show the Docker stack and have an opinion about the difference.
Honestly, the difference seems like splitting hairs (which is an interesting idiom, why would I want to split hairs? But I guess that’s the point.) At the end of the day, I feel like I could just use one virtual machine to hold as many apps as I wanted. Maybe they recommend only using one VM per app, but I don’t get why that should be a hard rule. I suppose so that if I wanted to do an update to the VM it didn’t impact a bunch of apps at once. But depending on what my apps were and whether I had a way to put up another vm with the updates before taking away the other one and blah blah. meh.
Describe a docker flowchart. There are only 4 steps in this version of answer.
Start with a Dockerfile and end with a running docker image to create your container.
- Build Dockerfile
- Push docker image to docker repo (docker hub or amazon ecr)
- pull docker image from docker repo
- run docker image to create your container.
Amazon Elastic Container Service is AWS’s what? (two word answer)
Container platform
Amazon Elastic Kubernetes Service is Amazon’s what? (2 word answer + some helping words for describing Kubernetes in the context of something you use)
Managed Kubernetes (helm does the making/deploying of Kubernetes apps).
AWS Fargate is Amazon’s what? (3 word answer + tiny sentance on which of the other AWS docker management services Fargate works with).
Serverless container platform. It works with ECS and EKS.
Amazon Elastic Contaner Registry is used to do what? (3 words)
store container images
There are four Docker container management services provided by AWS. Name them and provide an accompanying one-ish line description of what each does
- Amazon Elastic Container Service (AWS’s container platform)
- Amazon Elastic Kubernetes Service (Amazon’s managed Kubernetes (helm does the making/deploying of Kubernetes apps))
- AWS Fargate (Amazon’s serverless container platform; works with ECS and EKS)
- Amazon Elastic Contaner Registry (store container images).
To launch Docker containers on AWS using ECS you… (6 words, assuming you use acronyms).
launch ECS tasks on ECS clusters
When you’re launching docker containers in aws you launch ecs tasks on ecs clusters and you want to use an ec2 launch type, what are your ecs clusters made of? Also, when using the ec2 launch type, who provisions and maintains the infrastructure (the ec2 instances)?
With the EC2 launch type these ECS clusters are made of EC2 instances.
When using an ec2 launch type in this way, you must provision and maintain the infrastructure yourself.
When you’re launching docker containers on aws using ecs tasks on ecs clusters with an ec2 launch type and ec2 instances, what does each ec2 instance have to do to connect to the ECS cluster?
Each ec2 instance must run the ecs agent to register in the ecs cluster.
Who starts/stops docker containers when using docker on AWS when ECS and an EC2 launch type?
AWS
What’s the difference between ecr and ecs?
ECR is the repo that holds all the docker images. ECS takes those images and uses them to deploy their applications.
What’s the difference between ECS and EC2?
ECS deploys/manages/scales aws-managed containerized applications (i think usually docker, though you can pull off kubernetes). EC2 is a lot more like a virtual machine. Or maybe it’s like actually buying a new computer. I think it’s the latter. Here’s a direct quote “Amazon Elastic Compute Cloud (Amazon EC2) offers the broadest and deepest compute platform, with over 750 instances and choice of the latest processor, storage, networking, operating system, and purchase model to help you best match the needs of your workload.(https://aws.amazon.com/ec2/?p=pm&c=mt&pd=ec2&z=4)”.
ECS with a Fargate Launch Type.
Of the options described so far in this section for getting a docker-containerized app out the door and into the world, this method seems the simplest. Describe what you do? Do you provision the infrastructure? Is it serverless? What do you need to create (in addition to your docker images)? How do you scale? Who determines cpu and ram?
Launch docker containers on aws. No, there are no ec2 instances to manage. Yes it’s serverless (that means you just charge based usage, not a predefined bandwodth or anything). You just need to create task definitions (ECS tasks). To scale it you just increase (or decrease) the number of tasks.It looks like you specify your own cpu and ram.
You need to deploy a docker app in aws and you can use ecs with a fargate launch type or ecs with an ec2 launch type. which type seems the easiest, and why?
ECS with a Fargate Launch Type.
Some notes from another answer about what ECS with Fargate Launch Type means.
No, there are no ec2 instances to manage. Yes it’s serverless (that means you just charge based usage, not a predefined bandwodth or anything). You just need to create task definitions (ECS tasks). To scale it you just increase the number of tasks.
IAM Roles for ECS with an EC2 launch type.
So how do you allow the ECS agents running your docker app to interact with other AWS services?
You create an ec2 instance profile. This gets used by your ecs agent. it can make api calls to ecs services, send container logs to cloudwatch, pull docker image from ecr, reference sensitive data in secrets manager or ssm parameter store.
Let’s say you have a specific task on the ec2 instance that you have your ecs agent/docker container on. how do you allow that task to do something like get to an s3 bucket (i think s3 buckets maybe need their own IAM roles? And i suppose an ec2 instance profile isn’t an IAM role?). Where is your task role defined?
you create an ECS task role. This allows each task to have a specific role. you need to use different roles (so i assume, a different task) for the difference ecs services you run (apparently s3 and dynamo db are examples of ecs services. I suppose the “service” is the connection to other aws services). Task role is defined in teh task definition.
Can you use ECS with Fargate and a classic load balancer? What about if you’re using ecs without fargate?
A* nope
B* supported but not reccomended.
Does Amazon ECS work with an application load balancer?
Mostly yes
Does amazon ECS work with a network load balancer?
Yes but it’s only reccommended for high throughput/high performance use cases, or with AWS Pricate Link
A) Can you use ECS (elastic container service) with EFS (elastic file system)?
B) Does it matter whether you’re using ec2 launch types or fargate launch types?
A) Yes
B) No. You can use EFS for ecs when using either ec2 or fargate launch types
When you use ECS with an EC2 launch type you can create an ec2 instance profile (or use an existing one). it’s possible you have to. not gonna lie, i’m not sure which.
In this situation, it is common to use an ec2 instance profile and ecs task roles, as needed. What does/can the ec2 instance profile do? what does/can the ecs task role do/when do you want to use either?
- This ec2 instance profile gets used by the ecs agent (whale). it makes calls to ecs services. it can send container logs to CloudWatch logs. it can pull the docker image from ecr. it can reference sensitive data in secrets manager ssm parameter store.
- the ecs task role allows each task to have a specific role. use different roles for the different ecs services you run. I beleive tasks might do things like enable you to make aws api calls from your ec2 instance (other than the ones you’d want your ecs agent to be making to ecs and or ecr and or cloudwatch). For example, you might want your ec2 instance to be able to connect to s3 and dynamodb. you could create task role A to allow your ec2 instance to connect to s3. you could create task role b to allow your ec2 instance access to dyanamo db.
when using efs mounted on (working with) ecs, will the ecs tasks share the same data in the efs file system, regardless of what AZ the ecs tasks are in?
Yes. Taks running in any AZ will share the same data in the EFS file system.
Is Fargate + EFS considered a serverless way to do ECS?
Yes
What’s the use gase for using EFS when you’re using ECS?
persistent multi az shared storage for your containers
Can S3 be mounted as a file system for ecs?
No. but i’m guessing people wonder about that pretty frequently, since the point was called out in the slides. I’m guessing the idea is really that if you want a file system for ecs, just use efs.
You want to automatically increase or decrease the desired number of ECS tasks. What can you use?
ECS Service Auto Scaling
ECS Auto Scaling
T/F
does amazon ecs auto scaling use AWS application auto scaling?
T
Does ECS Sercice Auto Scaling at the task level equal ec2 auto scaling at the ec2 instance level?
No. ECS Service auto scaling is not the same as ec2 auto scaling at the ec2 instance level. However, this does not mean you can’t choose to accommodate ecs service scaling by scaling ec2 instances. We’ll talk more about that later.
Can you setup auto scaling for fargate? If yes, is it supposed to be easier to harder to do?
yes. it’s even supposed to be easier, because it’s serverless.
What are three important options for ecs auto scaling?
- target tracking - scale based on target value for a specified CloudWatch Alarm
- step scaling - scale based on a specified CloudWatch Alarm
- scheduled scaling - scale based on a specified date/time etc
ECS Auto Scaling uses AWS Application Auto Scaling. ECS Auto Scaling features include:
- ecs service average cpu utilization (believe this may mean scale on cpu utilization)
- ecs service average memory utilization (scale on ram)
- alb request count per target (metric coming from the alb). Per https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html, this is talking about “The average number of requests received by each target in a target group. You must specify the target group using the TargetGroup dimension. This metric does not apply if the target is a Lambda function.” . But i’m still not 100% sure about what the options for targets are.maybe like sites and apps and stuff?