How to Set Up an EKS Cluster Using eksctl

How to Set Up an EKS Cluster Using eksctl

This project demonstrates setting up an EKS cluster with eksctl utility.

·

2 min read

Setting up an Amazon EKS (Elastic Kubernetes Service) cluster can seem daunting, but with the right tools and a clear guide, it becomes much more manageable. In this blog post, we'll walk through the steps to create an EKS cluster using the eksctl utility. By the end, you'll have a functional EKS cluster ready to deploy applications.

Prerequisites

Before we dive into the steps, ensure you have the following:

  • An AWS account with necessary permissions to create EKS resources.

  • AWS CLI configured on your local machine.

  • kubectl installed on your local machine.

  • eksctl installed on your local machine.

Steps to Create an EKS Cluster

Follow these steps to set up your EKS cluster:

  1. Clone the Repository:

    First, clone the repository that contains the necessary configuration files:

     git clone https://github.com/omarsamyi/Eks_eksctl
     cd Eks_eksctl
    

This repository includes a sample eks_deployment.yaml file, which we'll customize in the next step.

  1. Edit eks_deployment.yaml:

    Open the eks_deployment.yaml file and edit the necessary fields such as cluster name, node group name, and other specifications. Here is an example configuration:

     apiVersion: eksctl.io/v1alpha5
     kind: ClusterConfig
    
     metadata:
       name: demo-cluster
       region: us-east-1
    
     nodeGroups:
       - name: demo-nodes
         instanceType: t2.micro
         desiredCapacity: 2
         minSize: 1
         maxSize: 3
    
  2. Create the EKS Cluster:

    With the configuration file updated, create the EKS cluster using the following command:

     eksctl create cluster -f eks_deployment.yaml
    

    This command will initiate the creation of your EKS cluster based on the provided configuration. The process may take several minutes.

  3. Deploy an Application:

    Once the cluster is up and running, you can deploy applications. As an example, let's deploy an NGINX application using Kubernetes manifests provided in the repository.

    First, apply the NGINX deployment:

     kubectl apply -f nginx-deployment.yaml
    

    Next, apply the NGINX service to expose the deployment:

     kubectl apply -f nginx-service.yaml
    
  4. Run as Dry-Run:

    If you want to test your configuration without making any changes, you can use the --dry-run flag. This is useful for validating your setup:

     eksctl create cluster \
     --name demo-cluster \
     --version 1.29 \
     --region us-east-1 \
     --nodegroup-name demo-nodes \
     --node-type t2.micro \
     --nodes 2 \
     --nodes-min 1 \
     --nodes-max 3 \
     --dry-run >> eks_deployment.yaml
    

    This command simulates the creation of the cluster and appends the configuration to eks_deployment.yaml.

Additional Resources:

For more detailed instructions and advanced configurations, refer to the eksctl getting started guide.

Conclusion:

By following these steps, you can easily set up an EKS cluster using eksctl. This setup is scalable and ready to deploy your containerized applications. If you have any questions or need further assistance, feel free to reach out.

Find me on