EKS and ECS Pricing confusion - amazon-web-services

I have one confusion, did we need to pay for ECS separately, if i had already EKS cluster with t3.medium EC2 instance as worker node. Because in documentation i found that there is no addition charge for ECS if we have EC2 instance.

EKS (Elastic Kubernetes Service) and ECS (Elastic Container Service) are two distinct services on AWS. Both are used for container orchestration. EKS, as the name suggests, is a managed Kubernetes cluster whereas ECS is an AWS-native solution.
Both EKS and ECS can be used on top of either EC2 instances or on Fargate. Fargate is a “serverless” solution in the sense that it manages the underlying servers and the autoscaling for you.
If you run ECS on EC2 instances instead of Fargate, you will only pay for the EC2 instances, just like normal. There is no additional cost for the fact that you run an ECS cluster on top of them. EKS however does charge you for the cluster itself, regardless of the underlying launch type.

Related

AWS ECS Fargate: What is the role of ECS Container Instance

I am learning docker and containerization in AWS, so i may be asking a very trivial question. I want some clarification on the ECS Fargate concept.
I understand from the documentation, that when i run my ECS cluster with Fargate for managing my containers (TASKS) , all the compute is handled by AWS Fargate. With the same idea in mind, I created a sample application.
Uploaded the docker image in ECR
Created task definition
Launched an ECS Cluster and Started a service referencing the above created Task definition
However, the tasks kept on failing to start. When I linked an EC2 instance to the cluster(also called as ECS Container instance), only then my tasks ran(started).
Can someone please explain me the below -
What role does ECS container instance (EC2) plays in ECS with fargate?
Why is it needed? Can an application run without EC2 instance in this case?
How would you determine the size of EC2 instance to link with ECS Fargate?
Appreciate your time and help.
Thank you.
However, the tasks kept on failing to start. When I linked an EC2 instance to the cluster(also called as ECS Container instance), only then my tasks ran(started).
You've missed a configuration setting somewhere, either on the ECS cluster or the task. Your service is trying to deploy to EC2 instead of Fargate. You do not need an EC2 instance in your cluster when you are using Fargate.

Does Fargate need HA

I have an auto scaling ECS cluster backed by fargate. The lower bound is 1 instance. Would i need to worry about HA? Lets say an AZ crashes, wouldnt the cluster logic spawn it in another AZ, does this imply that among other benefits, Fargate cuts out the HA/redundancy cost as well, with some service degrade of course
Only if you run your ECS service in vpc with subnets in more then one AZ. If you just run a single ECS task (not ECS service), you will not have HA.

Is Amazon Elastic Kubernetes Service can use fargate spot instance?

I'm using Is Amazon Elastic Kubernetes Service, I need to run fargate service on the Spot node.
Is it possible for EKS? Currently, I can find information about ECS only. So what steps I should follow to achieve this?
Fargate for EKS does not support spot instance yet. You can upvote here for the feature.
In the documentation it is mentioned
With AWS Fargate, there are no upfront costs and you pay only for the
resources you use. You pay for the amount of vCPU, memory, and storage
resources consumed by your containerized applications running on
Amazon Elastic Container Service (ECS) or Amazon Elastic Kubernetes
Service (EKS).
reference: https://aws.amazon.com/fargate/pricing/
This shows that Fargate Spot should work just fine for AWS EKS

Differences between EC2 Auto Scaling Group (EC2 ASG) and Elastic Container Service (ECS)

From what I've read so far:
EC2 ASG is a simple solution to scale your server with more copies of it with a load balancer in front of the EC2 instance pool
ECS is more like Kubernetes, which is used when you need to deploy multiple services in docker containers that works with each other internally to form a service, and auto scaling is a feature of ECS itself.
Are there any differences I'm missing here? Because ECS is almost always a superior choice to go with if they work as I understand.
You are right, in a very simple sense, EC2 Autoscaling Groups is a way to add/remove (register/unregister) EC2 instances to a Classic Load Balancer or Target Groups (ALB/NLB).
ECS has two type of scaling as does any Container orchestration platform:
Cluster Autoscaling: Add remove EC2 instances in a Cluster when tasks are pending to run
Service Autoscaling: Add/remove tasks in a service based on demand, uses Application AutoScaling service behind the scenes

How to scale ecs cluster with autoscaling?

I think you have 2 scaling
1 for ec2 instance
1 for ecs task
So I think flow goes like
You get more requests
Your tasks need more resources (cpu/memory)
Your ecs task autoscaling kicks in and creates more task
your ec2 autoscaling also kicks in and creates more ec2
Questions
your ecs needs to know newly launched ec2 (from ec2 autoscaling group) is the host that it can run on (how?)
I want the number of ec2 instance starts from one.
I think one instance is already running in the ecs cluster
Do I make ec2 autoscaling group start from 0?
ec2 autoscaling group has pricing option to use spot instance, but I didn't see such option when I created ecs cluster instances. To be clear, can I make ecs cluster with 0 ecs-instance, and let ec2 autoscaling group starts with 1 instance?
Your ecs task autoscaling kicks in and creates more task
your ec2 autoscaling also kicks in and creates more ec2
Your ECS task scale if there is a memory so fine it will scale and launch new container, if not enough memory then it will not launch an instance, you need to configure cloud watch alarm to scale ECS cluster based on the task scaling.
Tutorial: Scaling Container Instances with CloudWatch Alarms
your ecs needs to know newly launched ec2 (from ec2 autoscaling group)
is the host that it can run on (how?)
ECS agent registers the new instance with the same cluster, and the new task can be placed in any instance that have available resources to handle and launch the container.
I want the number of ec2 instance starts from one. I think one
instance is already running in the ecs cluster Do I make ec2
autoscaling group start from 0?
You should start from 1 otherwise no container will launch and will throw error no instance found in the cluster. if you do not want run container for now then you can start from 0.
ec2 autoscaling group has pricing option to use spot instance, but I
didn't see such option when I created ecs cluster instances. To be
clear, can I make ecs cluster with 0 ecs-instance, and let ec2
autoscaling group starts with 1 instance?
You can read about spot ECS cluster instance here.
Amazon ECS is a highly scalable, high performance, container
management service that supports Docker containers and allows you to
run applications on a managed cluster of Amazon EC2 instances easily.
ECS already handles the placement and scheduling of containers on EC2
instances. When combined with Spot fleet, ECS can deliver significant
savings over EC2 on-demand pricing.