How to Setup AWS EKS Cluster using eksctl
You’ll learn to set up all the resources you’ll need to start using Amazon Elastic Kubernetes Service (Amazon EKS) using eksctl, a straightforward command-line interface for establishing and managing Kubernetes clusters on Amazon EKS. After this tutorial, you will have a fully operational Amazon EKS cluster on which you can install apps.
Many resources that you would otherwise have to establish manually when setting up your cluster using the AWS Management Console are automatically generated due to the methods in this guide. Suppose you’d prefer to create most of the resources manually to understand better how they interact with one another. AWS Management Console can be used in that case to set up a cluster and compute. For further information, visit Getting Started with Amazon EKS – AWS Management Console and AWS CLI for more details on how to get started.
First, you must install and configure the tools and resources listed below, which are required to establish and operate an Amazon EKS cluster. Before proceeding with this guide, you must complete the prerequisites.
- kubectl – kubectl is a command-line utility for working with Kubernetes clusters that can be found here. This instruction requires you to be using version 1.22 or later of the software. More information can be found at Installing kubectl.
- eksctl – To interact with EKS clusters, eksctl is a command-line utility that automates many individual activities. You must be using version 0.95.0 or later to follow this guide. More information can be found at Installing eksctl.
- Required IAM permissions – The IAM security principal you’re using must have rights to work with Amazon EKS IAM roles and service-linked roles, AWS CloudFormation, and a VPC and associated resources to use Amazon EKS IAM roles service-linked roles, AWS CloudFormation, and a VPC and related resources. More information may be found in the IAM User Guide in the sections Actions, resources, and condition keys for Amazon Elastic Container Service for Kubernetes and Using service-linked roles. This instruction requires utilizing the same user account to accomplish all stages.
Step 1: Create a cluster and nodes in Amazon EKS.
This subject covers procedures to construct a cluster and nodes with default configurations to help you get started as quickly as possible. We recommend that you acquaint yourself with all options and deploy a cluster and nodes with the parameters that fit your requirements before deploying a cluster and nodes for production use. See Creating an Amazon EKS Cluster and Amazon EKS Nodes for further details. Some options are only available while building up your cluster and nodes.
One of the following node types can be used to build a cluster. See Amazon EKS nodes for further information on each category. You can add more node types after your group has been deployed.
- Fargate – Linux – If you wish to execute Linux applications on AWS Fargate, choose this node type. Fargate is a serverless compute engine for deploying Kubernetes pods without managing Amazon EC2 instances.
- Nodes that are managed – Linux – If you want to execute Amazon Linux apps on Amazon EC2 instances, choose this node type. You can also add Windows self-managed and Bottlerocket nodes to your cluster, albeit this is not addressed in this guide.
With the following command, you can create an Amazon EKS cluster. You can use your value in place of my cluster. Only alphanumeric characters (case-sensitive) and hyphens are allowed in the cluster name. It must begin with an alphabetic character and cannot exceed 128 characters in length. Any AWS Region supported by Amazon EKS can be substituted for region-code. See Amazon EKS endpoints and quotas in the AWS General Reference Handbook for a list of AWS Regions.
Fargate – Linux
eksctl create cluster --name my-cluster --region region-code --fargate
Managed Nodes- Linux
eksctl create cluster --name my-cluster --region region-code
You will need to wait several minutes for the cluster to be created. Several lines of output will appear during the creation process. The last line of production is similar to the example line below.
... [✓] EKS cluster "my-cluster" in "region-code" region is ready
eksctl either created a kubectl config file in /.kube on your machine or appended the new cluster’s configuration to an existing config file in /.kube.
View the AWS CloudFormation stack named eksctl-my-cluster-cluster in the AWS CloudFormation interface at https://console.aws.amazon.com/cloudformation to see all of the resources that were produced when cluster construction is complete.
Step 2: See a list of Kubernetes resources.
View the nodes in your cluster.
kubectl get nodes -o wide
Managed Node – Linux
kubectl get pods -A -o wide
View Kubernetes resources for further information on what you see in the output.
Step 3: Remove all nodes and clusters from your system.
When you’ve finished utilizing the cluster and nodes you generated for this tutorial, it would be best to clean up by using the following command to delete the group and nodes. See the Next steps if you wish to do more with this cluster before cleaning it up.
eksctl delete cluster --name my-cluster --region region-code