To set up an AWS EKS cluster using a YAML configuration file, you'll use eksctl , a command-line tool designed for managing EKS clusters. Below is a step-by-step guide:
Prerequisites
AWS Account : Ensure you have an AWS account with appropriate IAM permissions (e.g., AdministratorAccess).
AWS CLI : Install and configure the AWS CLI:
bash Copy code
# Install AWS CLI (Linux/macOS)
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip && sudo ./aws/install
# Configure AWS credentials
aws configure
eksctl : Install eksctl:
bash Copy code
# Install eksctl (Linux/macOS)
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
1. Create a YAML Configuration File
Define your EKS cluster in a YAML file (e.g., cluster-config.yaml). Here's a basic example:
yaml Copy code
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: my-eks-cluster # Cluster name
region: us-west-2 # AWS region
version: "1.27" # Kubernetes version (check AWS docs for supported versions)
nodeGroups:
- name: ng-default # Node group name
instanceType: t3.medium # EC2 instance type
desiredCapacity: 2 # Number of nodes
ssh:
publicKeyName: my-keypair # Optional: SSH key for node access (must exist in AWS)
Advanced Options
Add additional configurations as needed:
VPC/Subnets :
yaml Copy code
vpc:
cidr: "192.168.0.0/16"
subnets:
public:
us-west-2a: { cidr: "192.168.0.0/19" }
us-west-2b: { cidr: "192.168.32.0/19" }
IAM Roles :
yaml Copy code
iam:
withOIDC: true
Managed Node Groups (recommended for production):
yaml Copy code
managedNodeGroups:
- name: ng-managed
instanceType: m5.large
minSize: 1
maxSize: 3
2. Create the Cluster
Run the following command to create the cluster:
bash Copy code
eksctl create cluster -f cluster-config.yaml
This will:
Provision the EKS control plane.
Launch worker nodes in the specified region.
Configure IAM roles and networking.
⏱️ Time : This takes ~10-15 minutes.
3. Verify the Cluster
After creation, update your kubeconfig to access the cluster:
bash Copy code
aws eks update-kubeconfig --name my-eks-cluster --region us-west-2
Check nodes and cluster info:
bash Copy code
kubectl get nodes
kubectl cluster-info
4. (Optional) Add-ons
Install add-ons like the AWS Load Balancer Controller or Metrics Server using eksctl or Helm.
5. Clean Up
To delete the cluster:
bash Copy code
eksctl delete cluster -f cluster-config.yaml
This removes all AWS resources created for the cluster.
Key Notes
IAM Permissions : Ensure your AWS user has permissions for EKS, EC2, VPC, and IAM.
Region Support : Check AWS EKS Regions for availability.
Advanced Docs : eksctl.io
Let me know if you need help with specific configurations (e.g., GPU nodes, private clusters, or integration with AWS services)!