How to Create an AWS EKS Cluster: Step-by-Step Guide
To create an
EKS cluster, use the AWS CLI command aws eks create-cluster with parameters for cluster name, role ARN, and VPC configuration. This sets up the Kubernetes control plane managed by AWS, ready for worker nodes to join.Syntax
The basic syntax to create an EKS cluster using AWS CLI is:
aws eks create-cluster: Command to create the cluster.--name: The name you choose for your cluster.--role-arn: The IAM role ARN that EKS uses to manage AWS resources.--resources-vpc-config: VPC settings including subnet IDs and security group IDs.
bash
aws eks create-cluster --name <cluster-name> --role-arn <IAM-role-ARN> --resources-vpc-config subnetIds=<subnet-ids>,securityGroupIds=<security-group-ids>
Example
This example creates an EKS cluster named my-eks-cluster using a specified IAM role and VPC subnets. It shows a complete command you can run in your terminal.
bash
aws eks create-cluster \ --name my-eks-cluster \ --role-arn arn:aws:iam::123456789012:role/EKSClusterRole \ --resources-vpc-config subnetIds=subnet-0bb1c79de3EXAMPLE,subnet-064f5c1a2EXAMPLE,securityGroupIds=sg-0a1b2c3d4e5f6g7h8
Output
An EKS cluster creation request is submitted. The cluster status will be "CREATING" until ready.
Common Pitfalls
Common mistakes when creating an EKS cluster include:
- Using an IAM role without the correct permissions for EKS.
- Specifying subnet IDs that are not private or not in the same VPC.
- Not waiting for the cluster status to become
ACTIVEbefore adding worker nodes. - Forgetting to configure your
kubectlto connect to the new cluster.
bash
## Wrong: Using a role without EKS permissions aws eks create-cluster --name test-cluster --role-arn arn:aws:iam::123456789012:role/NoEKSAccessRole --resources-vpc-config subnetIds=subnet-12345,securityGroupIds=sg-12345 ## Right: Use a role with EKS permissions aws eks create-cluster --name test-cluster --role-arn arn:aws:iam::123456789012:role/EKSClusterRole --resources-vpc-config subnetIds=subnet-12345,securityGroupIds=sg-12345
Quick Reference
Remember these tips when creating your EKS cluster:
- Use an IAM role with AmazonEKSClusterPolicy attached.
- Choose subnets in your VPC that have internet access or NAT for worker nodes.
- Check cluster status with
aws eks describe-cluster. - Configure
kubectlusingaws eks update-kubeconfigafter creation.
Key Takeaways
Use the AWS CLI command
aws eks create-cluster with proper parameters to create your EKS cluster.Ensure the IAM role has the necessary EKS permissions before creating the cluster.
Specify valid VPC subnet IDs and security groups in the cluster creation command.
Wait for the cluster status to be ACTIVE before adding worker nodes or deploying workloads.
Configure your local Kubernetes tool
kubectl to connect to the new cluster using aws eks update-kubeconfig.