What you’ll build, and what it costs
You will create a small Amazon EKS cluster, connect kubectl to it, deploy a test web server and remove everything at the end.
Be aware of the cost before you start. EKS charges a fixed fee of $0.10 per hour for each cluster’s control plane, which is about $73 a month if it runs all month. You also pay for the worker nodes (EC2 instances or Fargate), storage, and any load balancers or NAT gateways the setup creates. Plan to delete the cluster the same day you create it, unless you have a reason to keep it.
Before you start
- An AWS account and an IAM user with permissions to create EKS, EC2, VPC and CloudFormation resources. Using an administrator role for a learning account is common, but do not use the root user.
- The AWS CLI version 2, configured with
aws configure. kubectl. Install a version within one minor release of the cluster’s Kubernetes version.eksctl, the command-line tool for creating EKS clusters.
Step 1: Install and check the tools
Check that each tool is installed and that the AWS CLI can reach your account:
aws --version
aws sts get-caller-identity
kubectl version --client
eksctl version
If get-caller-identity returns an error, fix your credentials before you continue.
Step 2: Create the cluster with eksctl
Run this command. It creates a cluster named demo with two t3.medium worker nodes in us-east-1:
eksctl create cluster \
--name demo \
--region us-east-1 \
--nodegroup-name ng1 \
--node-type t3.medium \
--nodes 2
eksctl creates a CloudFormation stack for the VPC, the control plane and the node group. Expect it to take 15 to 20 minutes. Keep the terminal open until it reports that the cluster is ready.
To pin a Kubernetes version, add --version with a version that is currently supported. Check the EKS version list first, because older versions move to extended support and cost more.
Step 3: Connect kubectl to the cluster
eksctl usually updates your kubeconfig for you. If you need to set it again, run:
aws eks update-kubeconfig --region us-east-1 --name demo
kubectl get nodes
Both nodes should show Ready. If they show NotReady for a long time, see Troubleshooting.
Step 4: Deploy a test app and expose it
Create a deployment running the public nginx image, then expose it with a load balancer:
kubectl create deployment hello --image=nginx
kubectl expose deployment hello --type=LoadBalancer --port=80
kubectl get service hello
The EXTERNAL-IP column can take a few minutes to fill in. When it does, open that address in your browser. You should see the nginx welcome page.
The LoadBalancer service creates an AWS load balancer, and that load balancer bills while it exists. Remember to delete it in the clean-up step.
Step 5: Understand who can access the cluster
EKS uses two layers of access control. AWS IAM decides who can call the EKS API, and Kubernetes RBAC decides what each user can do inside the cluster. Current clusters grant access through EKS access entries, which map IAM principals to Kubernetes permissions. Older guides edit the aws-auth ConfigMap instead. AWS recommends access entries for new clusters.
The identity that created the cluster gets administrator access by default. Other IAM users and roles get no access until you add an access entry for them. If a teammate gets Unauthorized errors from kubectl, check their access entry first.
Step 6: Clean up in the right order
Delete the Kubernetes objects that created AWS resources before you delete the cluster. If you delete the cluster first, the load balancer can be left behind and keep billing.
kubectl delete service hello
kubectl delete deployment hello
Wait until the load balancer disappears from the EC2 console (under Load Balancers). Then delete the cluster:
eksctl delete cluster --name demo --region us-east-1
After the command finishes, check the EC2 console for leftover volumes and the VPC console for NAT gateways and Elastic IPs. eksctl normally removes what it created, but confirm it.
Before you use EKS for real work
- Control plane versions. Each Kubernetes minor version gets 14 months of standard support. After that, extended support costs $0.60 per hour per cluster, about six times the standard rate. Upgrade one minor version at a time: the control plane first, then the nodes and add-ons.
- Node options. You can use managed node groups, self-managed nodes, AWS Fargate, or EKS Auto Mode, which manages more of the node layer and adds its own management fee.
- Networking. Nodes in private subnets reach the internet through a NAT gateway, which bills by the hour and by the gigabyte. Subnets must span at least two Availability Zones.
- Network access to the API. For production, restrict the public API endpoint to specific address ranges, or use a private endpoint.
- Add-ons. Install the AWS Load Balancer Controller to create ALBs and NLBs from Kubernetes objects. Install the EBS CSI driver if pods need persistent volumes.
Troubleshooting
- Nodes stay
NotReady. Check the node group status in the EKS console and the node’s events withkubectl describe node <name>. Private subnets without a NAT gateway or VPC endpoints are a common cause. kubectlreturnsUnauthorizedorforbidden. The identity you are using has no access entry for the cluster. The cluster creator has access by default. Other users need an access entry.- The
EXTERNAL-IPstays<pending>. Check the events on the service withkubectl describe service hello. The subnets may lack the tags the load balancer needs, or the cluster may lack the required controller. - The cluster deletion fails. Look for leftover load balancers, then delete them and run the
eksctl delete clustercommand again.
Next steps
- Read the guide to why EKS can be expensive before you leave a cluster running.
- Compare EKS with the simpler ECS container deployment.
- For background on Kubernetes and how it relates to EKS, read what Kubernetes vs. EKS means.
- Check the guide to avoiding unexpected AWS charges for alerts to set up.