Skip to main content

Create AWS EKS Cluster — eksctl

· 4 min read

banner

Create AWS EKS Cluster — eksctl​

Creating Kubenetes cluster in AWS have multiple options like using AWS SDK, Terraform, Cloudformation and easy and quick for new learner using AWS Console. In this blog we going see another well know method of creating AWS EKS cluster using “eksctl” command by using as YAML configuration in default VPC. ( Same can be create by CLI command).

Let’s get start​

Prerequisites:​

Let install these binary one by one

  1. AWS CLI
  2. eksctl CLI
  3. kubectl

Step 1. Install AWS CLI (Mac OS)​

Download AWS CLI binary​

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"

image

Install AWS CLI​

sudo installer -pkg ./AWSCLIV2.pkg -target /

image

Verify the installation​

which aws  
aws --version

image

Step 2. Configure AWS CLI​

Step 2.1. Login to AWS console as root user​

Step 2.2. Create IAM user​

username: kubedeveloper

No AWS console access, Only programmatic access

image

Provide Username

image

Permission as per User Type

image

Create Access and SecretAccessKey​

Step 2.3 Select the IAM user “kubedeveloper”​

Step 2.4 Navigate to Security Credentials​

image

Step 2.5. Click Create access key​

image

Step 2.6 Select Use case :​

Command Line Interface (CLI) & check the Confirmation

image

Step 2.7. Set description tag — optional and Click create​

image

Now we got AccessKey and SecretAccessKey,

Next, Let configure AWS CLI on Mac OS command line​

Note: if multiple aws account configured, use — profile

$ aws configure

image

Validate AWS CLI Access​

Run any aws command to list resources

Here eg: To list s3 buckets on my AWS account

bala@kubelancer Downloads % aws s3 ls

Getting output, which denoted AWS access has been configured correctly​

bala@kubelancer Downloads % aws s3 ls  
2022-12-13 21:36:02 firehose-backup-05bf6840

Install eksctl on Mac OS​

To download the latest release, run on Mac OS (arm64 architecture):​

curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl\_Darwin\_arm64.tar.gz"  
tar -xzvf eksctl\_Darwin\_arm64.tar.gz
sudo mv ./eksctl /usr/local/bin

Ref: https://www.weave.works/oss/eksctl/

Step 3: Creating an AWS EKS Kubernetes Cluster using eksctl tool​

3.1. Create Cluster configuration yaml file​

$ vi cluster-config.yaml
apiVersion: eksctl.io/v1alpha5  
kind: ClusterConfig

metadata:
name: kubelancer-cluster-1
region: us-east-1

nodeGroups:
- name: ng-1
instanceType: t4g.medium
desiredCapacity: 2
volumeSize: 20
ssh:
allow: false

3.2 Let’s create eks cluster on aws using eksctl command​

$ eksctl create cluster -f cluster-config.yaml

image

Cluster created successfully

Note: if multiple aws account configured, use — profile

Get the cluster name by using eksctl command​

eksctl interact with AWS API and get the required details from AWS cloud

$ eksctl get cluster --profile kubedev

image

Use the following command to get update kube-config.​

$ aws eks update-kubeconfig --name=kubelancer-cluster-1 --region=us-east-1

Verify the Cluster​

kubectl get nodes

image

Cluster Node Status

Delete Cluster​

$ kubectl get poddisruptionbudget -A  
$ kubectl delete poddisruptionbudget coredns -n kube-system
$ eksctl delete cluster -f cluster-config.yaml --profile kubedev

image

Happy Computing :)​

image


👉 Originally published on Medium: Read more