Creating Your First Cluster
Introduction: Building Your First EKS Cluster
In the previous lesson, you prepared your environment by installing the aws, kubectl, and eksctl command-line tools. Now, you'll use those tools to create your first EKS cluster. This is the foundational step for the rest of the course, as you need a running cluster before you can deploy any applications.
By the end of this lesson, you'll have a fully functional, two-node Kubernetes cluster running on AWS. You will define the cluster's configuration in a YAML file, create it with a single eksctl command, connect to it with kubectl, verify its status, and finally, learn how to delete it to avoid extra costs. We use a configuration file because it provides a clear, reproducible, and versionable specification for your infrastructure, which is far more reliable than typing a long series of command-line flags.
Understanding the Cluster Configuration
A cluster configuration file is a structured document that describes exactly what you want your EKS cluster to look like. We use YAML format because it's human-readable and widely used in the Kubernetes ecosystem. YAML uses indentation to show structure, similar to how Python uses indentation, and it's designed to be easy to read and write by hand.
The configuration file has two main sections that work together to define your cluster. The first section contains metadata about the cluster itself, such as its name, which AWS region it should run in, and which version of Kubernetes to use. The second section describes your node groups, which are the worker nodes where your containers will actually run. Each section serves a distinct purpose, and eksctl uses both sections to create all the necessary AWS resources.
When you run eksctl create cluster with a configuration file, it doesn't just create a Kubernetes cluster. Behind the scenes, it creates a complete AWS infrastructure: a VPC with public and private subnets, security groups that control network access, IAM roles with appropriate permissions, the EKS control plane, and EC2 instances configured as Kubernetes worker nodes. All of these resources are created and configured to work together seamlessly. This is why using eksctl is so much easier than trying to set everything up manually with the aws CLI.
Breaking Down the Cluster Specification
Let's look at a complete cluster configuration file and understand each part. Here's the configuration you'll use to create your first cluster:
This file declaratively defines every important aspect of your cluster. Let's examine the key components of this configuration.
apiVersionandkind: These fields telleksctlthat this is aClusterConfigfile and which version of the configuration schema to use. This is a standard pattern in Kubernetes configuration.metadata: This section defines the cluster's core identity. It includes thename(dev-eks-cluster), the AWSregion(us-east-1), and the Kubernetesversion("1.29"). The version is quoted to ensure it is passed as a string literal to the API, avoiding potential floating-point precision issues and ensuring the schema validation receives the exact version string expected.managedNodeGroups: This section defines your worker nodes. "Managed" means AWS handles patching and maintenance of the underlying EC2 instances.- Capacity Settings:
desiredCapacity,minSize, andmaxSizeare all set to2. This creates a fixed-size node group with two worker nodes, which is simple and predictable for learning. - Instance Configuration:
instanceTypesspecifies the EC2 instance size (t3.small), which is cost-effective for this course.amiFamilysets the operating system toAmazonLinux2, which is optimized for EKS. - IAM Add-on Policies: The
iamsection grants worker nodes specific permissions to interact with other AWS services. We enablecloudWatchfor logging andebsfor persistent storage, which are common requirements for real applications.
By defining these settings in one file, you create a single source of truth for your cluster's architecture. The comment at the bottom highlights that eksctl automatically adds permissions for nodes to pull images from Amazon ECR and creates public subnets by default, which provides the internet connectivity needed for pulling container images.
