0
0
AWScloud~5 mins

EKS vs ECS decision in AWS - CLI Comparison

Choose your learning style9 modes available
Introduction
Choosing between EKS and ECS helps you decide how to run your container apps on AWS. Both let you run containers but differ in complexity and control. Picking the right one saves time and effort.
When you want full control over Kubernetes features and ecosystem, choose EKS.
When you want a simpler way to run containers without managing Kubernetes, choose ECS.
When your team already knows Kubernetes, EKS fits better.
When you want to quickly deploy containers with less setup, ECS is easier.
When you need to run containers alongside other AWS services tightly, ECS integrates well.
Commands
This command creates an EKS Kubernetes cluster named example-cluster in the us-east-1 region with specified subnets and security groups. It sets up the control plane for Kubernetes.
Terminal
aws eks create-cluster --name example-cluster --region us-east-1 --kubernetes-version 1.27 --role-arn arn:aws:iam::123456789012:role/EKSClusterRole --resources-vpc-config subnetIds=subnet-abc123,subnet-def456,securityGroupIds=sg-0123456789abcdef0
Expected OutputExpected
{ "cluster": { "name": "example-cluster", "arn": "arn:aws:eks:us-east-1:123456789012:cluster/example-cluster", "createdAt": "2024-06-01T12:00:00Z", "version": "1.27", "endpoint": "https://ABCDEF123456.gr7.us-east-1.eks.amazonaws.com", "roleArn": "arn:aws:iam::123456789012:role/EKSClusterRole", "resourcesVpcConfig": { "subnetIds": [ "subnet-abc123", "subnet-def456" ], "securityGroupIds": [ "sg-0123456789abcdef0" ], "endpointPublicAccess": true }, "status": "CREATING" } }
--name - Sets the cluster name
--kubernetes-version - Specifies Kubernetes version
--resources-vpc-config - Defines networking for the cluster
Waits until the EKS cluster is fully active and ready to use before proceeding.
Terminal
aws eks wait cluster-active --name example-cluster --region us-east-1
Expected OutputExpected
No output (command runs silently)
--name - Specifies the cluster to wait for
Creates a simple ECS cluster named example-ecs-cluster in the us-east-1 region to run container tasks.
Terminal
aws ecs create-cluster --cluster-name example-ecs-cluster --region us-east-1
Expected OutputExpected
{ "cluster": { "clusterArn": "arn:aws:ecs:us-east-1:123456789012:cluster/example-ecs-cluster", "clusterName": "example-ecs-cluster", "status": "ACTIVE", "registeredContainerInstancesCount": 0, "runningTasksCount": 0, "pendingTasksCount": 0 } }
--cluster-name - Names the ECS cluster
Lists all ECS clusters in the us-east-1 region to verify the cluster creation.
Terminal
aws ecs list-clusters --region us-east-1
Expected OutputExpected
{ "clusterArns": [ "arn:aws:ecs:us-east-1:123456789012:cluster/example-ecs-cluster" ] }
Key Concept

If you remember nothing else from this pattern, remember: EKS gives you full Kubernetes power but needs more setup, while ECS is simpler for running containers directly on AWS.

Common Mistakes
Trying to use Kubernetes commands directly on ECS clusters.
ECS does not use Kubernetes; it has its own API and commands.
Use ECS CLI or AWS CLI ECS commands for ECS clusters, and kubectl for EKS clusters.
Creating EKS clusters without specifying proper VPC subnets and security groups.
EKS needs networking configured correctly to work; missing this causes cluster creation failure.
Always provide valid subnet IDs and security group IDs in the create-cluster command.
Summary
Use 'aws eks create-cluster' to set up a Kubernetes cluster with control over pods and services.
Use 'aws ecs create-cluster' for a simpler container cluster managed by AWS without Kubernetes complexity.
Verify cluster creation with 'aws eks wait cluster-active' for EKS and 'aws ecs list-clusters' for ECS.