Amazon EKS — eksctl create cluster
eksctl create cluster
Let’s create your very first EKS cluster. One command, about 15 minutes, and you’ll have a fully functional Kubernetes cluster on AWS.
The Simplest Way to Create a Cluster
$ eksctl create cluster \
--name demo \
--region us-east-1 \
--nodegroup-name demo-nodes \
--node-type t3.medium \
--nodes 2 \
--nodes-min 1 \
--nodes-max 3
Expected output (takes ~15 minutes):
2024-01-15 10:00:00 [ℹ] eksctl version 0.175.0
2024-01-15 10:00:00 [ℹ] using region us-east-1
2024-01-15 10:00:01 [ℹ] subnets for us-east-1a - public:192.168.0.0/19 private:192.168.64.0/19
2024-01-15 10:00:01 [ℹ] subnets for us-east-1b - public:192.168.32.0/19 private:192.168.96.0/19
2024-01-15 10:00:01 [ℹ] nodegroup "demo-nodes" will use "" [AmazonLinux2/1.29]
2024-01-15 10:00:02 [ℹ] using Kubernetes version 1.29
2024-01-15 10:00:02 [ℹ] creating EKS cluster "demo" in "us-east-1" region
2024-01-15 10:00:02 [ℹ] will create 2 separate CloudFormation stacks for cluster itself and the initial managed nodegroup
...
2024-01-15 10:14:30 [ℹ] node "ip-192-168-75-112.ec2.internal" is ready
2024-01-15 10:14:30 [ℹ] node "ip-192-168-98-43.ec2.internal" is ready
2024-01-15 10:14:32 [✔] EKS cluster "demo" in "us-east-1" region is ready
What Just Happened?
That single command created over 30 AWS resources:
eksctl create cluster ──▶ CloudFormation Stacks
│
├── eksctl-demo-cluster
│ ├── VPC
│ ├── 4 Subnets (2 public, 2 private)
│ ├── Internet Gateway
│ ├── 2 NAT Gateways
│ ├── Route Tables
│ ├── EKS Cluster
│ ├── IAM Cluster Role
│ ├── Security Groups
│ └── OIDC Provider
│
└── eksctl-demo-nodegroup-demo-nodes
├── IAM Node Role
├── Launch Template
├── Auto Scaling Group
└── 2 EC2 Instances (t3.medium)
Understanding the eksctl Flags
| Flag | Purpose | Default |
|---|---|---|
--name |
Cluster name | Auto-generated |
--region |
AWS region | Your CLI default region |
--nodegroup-name |
Name for the node group | Auto-generated |
--node-type |
EC2 instance type | m5.large |
--nodes |
Number of worker nodes | 2 |
--nodes-min |
Minimum nodes (for auto-scaling) | Same as --nodes |
--nodes-max |
Maximum nodes (for auto-scaling) | Same as --nodes |
Verify the Cluster Was Created
# Check cluster exists in AWS
$ aws eks describe-cluster --name demo --query 'cluster.status'
"ACTIVE"
# Check nodes are ready
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-192-168-75-112.ec2.internal Ready <none> 5m v1.29.0-eks-...
ip-192-168-98-43.ec2.internal Ready <none> 5m v1.29.0-eks-...
# Check system pods
$ kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
aws-node-xxxxx 2/2 Running 0 5m
coredns-xxxxxxxxxx-xxxxx 1/1 Running 0 10m
coredns-xxxxxxxxxx-xxxxx 1/1 Running 0 10m
kube-proxy-xxxxx 1/1 Running 0 5m
kube-proxy-xxxxx 1/1 Running 0 5m
Deploy a Quick Test App
Let’s prove the cluster works:
# Deploy nginx
$ kubectl create deployment nginx --image=nginx --replicas=2
# Check pods
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-7854ff8877-abcde 1/1 Running 0 30s
nginx-7854ff8877-fghij 1/1 Running 0 30s
# Expose it
$ kubectl expose deployment nginx --port=80 --type=LoadBalancer
# Wait for external IP (takes ~2 minutes)
$ kubectl get svc nginx -w
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx LoadBalancer 10.100.200.10 a1234567890abcdef-1234567890.us-east-1.elb.amazonaws.com 80:31234/TCP 2m
# Test it
$ curl a1234567890abcdef-1234567890.us-east-1.elb.amazonaws.com
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...
Clean up the test app:
$ kubectl delete service nginx
$ kubectl delete deployment nginx
Common Mistakes
| Mistake | Impact | Fix |
|---|---|---|
Not specifying --region |
Cluster created in wrong region | Always specify --region |
Using m5.large (default) |
More expensive than needed for learning | Use --node-type t3.medium |
| Forgetting to delete cluster | Ongoing charges (~$170/month) | eksctl delete cluster --name demo |
| Running as root AWS account | Security risk | Use IAM user/role |
Quick Reference
# Create cluster
$ eksctl create cluster --name demo --region us-east-1 --node-type t3.medium --nodes 2
# Check status
$ eksctl get cluster --name demo --region us-east-1
# List node groups
$ eksctl get nodegroup --cluster demo --region us-east-1
# Delete cluster (IMPORTANT!)
$ eksctl delete cluster --name demo --region us-east-1
What’s Next?
The CLI approach is great for quick clusters, but production teams use config files. Let’s learn about Cluster Config YAML.