Amazon EKS Clusters Setup – Step by Step Instructions
Tags: aws, devops, cloud, kubernetes
Published: 2022-12-02 06:44:12


A production-quality Kubernetes cluster requires planning and preparation. If your Kubernetes cluster is to run critical workloads, it must be configured to be resilient.

There are several deployment tools to do the Kubernetes cluster steps:

1.	Bootstrapping clusters with kubeadm
2.	Installing Kubernetes with KOPS
3.	Installing Kubernetes with Kubespray
4.	Turnkey Cloud Solution

We are going to use Turnkey Cloud Solution (Amazon EKS), using EKSCTL utility we are going to manage the production ready cluster.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7x5uxk1tyn0ylpkl3lni.JPG)

There are several cloud providers who support creating of Kubernetes cluster setup, this blog concentrates on creating of cluster on amazon EKS.

First, we are going to launch a Linux instance (t2 micro), this instance is used to manage the k8s cluster and give all the necessary instruction to Kubernetes cluster using EKSCTL and KUBECLT utility.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3wujrvvldc981lkq5cb.JPG)

Allow SSH, HTTP and HTTPs traffic to that instance, rest leave as default and launch instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gy4cdjthk17hpqy6a6yx.JPG)

SSH to machine using public IPv4 address.

Check the AWS CLI version, using “aws –version” command. Better to refer below link to use the current AWS CLI version:

https://docs.aws.amazon.com/eks/latest/userguide/getting-started-console.html

You can easily upgrade it to the latest by using below command:
For Linux, execute the below command, for other OS refer to below link:

```
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

```
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

Above command will download the binaries and install the AWS CLI in your instance or override in case you have the older one. 

In case new version does not appear then exit and re-login to machine as demonstrated below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eyxy8e4m0p4re28y335y.JPG)

Now, we are going to install below item as prerequisites:
1.	kubectl
2.	Eksctl
3.	Required IAM Permissions to Instance

You can refer below link for more details: 

https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html

Kubectl is a command line tool for working with Kubernetes cluster.

For Linux machine, execute the below command, for other OS refer the link below:

```
curl -o kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.24.7/2022-10-31/bin/linux/amd64/kubectl
```

https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html

Now, apply execute permissions to the binary, and copy the binary to a folder in your PATH, you can check the PATH by executing “echo $PATH” as mentioned below:

```
chmod +x ./kubectl
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctr5ozz06ifiayqkpdxw.JPG)

Check kubectl version …

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9dfr2tv495cfk4r6hf2h.JPG)

Now, install eksctl by executing below command for Linux machine, for other OS refer the link below:

```
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
```

https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html

Binaries got download into the tmp folder, go to tmp and copy the binary to a folder in your PATH, same as mentioned below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t94t2cy8dduyw5460yuy.JPG)

Now, its time to create an IAM Role with required permissions and attached it to the Linux EC2 Instance.

Eks_role, get created with below permissions attached, I am giving the full access but you can refine the permission related things at your end accordingly.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i77sxfcyeq03pdl96jcz.JPG)

At backend, EKSCTL utility is using CloudFormation to do all the cluster creation, so EC2 machine must have all the required permission to perform the actions.

Now, assign the role to EC2 Linux instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rgnavnhlenxrsa9dmfz1.JPG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvod0jnoggj039gtoqi0.JPG)

Now, using eksctl utility, we are going to create an EKS Cluster.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bg1hrwg0lr7cb1lbd1p.JPG)

This will create a cluster with name “alok-devops” in Mumbai region with 2 worker node of type t2.small.

Please be aware. this not comes into free-tier.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5j7japqtgpkdbhnb578.JPG)

CloudFormation Stacks get created for Kubernetes cluster using eksctl utility. During creation of stack and work efficiently it creates several roles, this is the reason we provided EC2 machine with permission of IAM full access. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hzz9q4z4dvfxinsbn0cr.JPG)![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eknmhf34zaeeyll0ap2a.JPG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izpez00f98bnqegkhelf.JPG)

Successfully created the EKS cluster with 2 worker node. It take approximately 18 min. 

Now, its time to validate the cluster using few Kubernetes command using kubectl utility.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqayskiwegi7tquqfoqo.JPG)

You can view complete setup on my youtube video:

{% embed https://www.youtube.com/watch?v=1O-I7NtwCeE&list=PL6nVblW4NNATBBMFJNiDbYDvHSholElfz&index=19 %}.