Creating an EKS (Elastic Kubernetes Service) cluster using eksctl is a relatively simple process that can be broken down into a few key steps. In this blog post, we will walk through the process of creating an EKS cluster using eksctl, step-by-step.

Overview

  1. Install eksctl
  2. Create an IAM Role and User
  3. Create the EKS Cluster
  4. Configure kubectl
  5. Deploying an application
  6. Clean up

Steps:

Step 1: Install eksctl

The first step in creating an EKS cluster using eksctl is to install eksctl on your local machine. eksctl is a command-line tool that makes it easy to create, update, and manage EKS clusters. To install eksctl, you can use the following command:

curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin

Step 2: Create an IAM Role and User

Before creating an EKS cluster, you will need to create an IAM role and user that eksctl can use to create and manage the cluster. To create an IAM role and user, you can use the AWS Management Console or the AWS CLI.

AWS Doc: Amazon EKS cluster IAM role

Once you have created the IAM role and user, you will need to add the access key and secret access key for the user to your ~/.aws/credentials file.

Step 3: Create the EKS Cluster

Once you have installed eksctl and created an IAM role and user, you can create the EKS cluster using the following command:

eksctl create cluster --name my-cluster --region ap-south-1 --nodes 3

This command creates an EKS cluster named “my-cluster” in the us-west-2 region with 3 worker nodes.

Step 4: Configure kubectl

After the EKS cluster is created, you will need to configure kubectl to communicate with the cluster. You can do this by running the following command:

aws eks --region ap-south-1 update-kubeconfig --name my-cluster

This command configures kubectl to communicate with the “my-cluster” EKS cluster in the ap-south-1 region.

Step 5: Deploying an application

Now that your EKS cluster is set up and configured, you can deploy an application to it. You can use the kubectl command-line tool to deploy your application.

For example, you can deploy a simple NGINX web server by creating a deployment file nginx-deployment.yaml and running the following command:

Sample file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.22.1
        ports:
        - containerPort: 80

This command deploys an NGINX web server to the EKS cluster.

kubectl apply -f nginx-deployment.yaml

Step 6: Clean up

Run the below command to delete the cluster.

eksctl delete cluster my-cluster
Conclusion

In conclusion, creating an EKS cluster using eksctl is a relatively straightforward process that can be broken down into a few key steps. By following these steps, you can quickly and easily create an EKS cluster and deploy applications to it.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments