How to set up Amazon EKS Cluster

How to set up Amazon EKS Cluster
Photo by Luca Bravo / Unsplash

Intro

Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS without needing to install, operate, and maintain your own Kubernetes control plane. Click for more details.

Requirements

In order to set up a new Amazon EKS, we need an AWS account with root privileges. For the k8s interaction, we also need a client machine. I'll use MacOS for this article.

VPC Setup

This is the first and most important step for our cluster setup. When I try to create VPC myself, I have encountered many errors. First of all, you need to decide on your cluster subnets. We have 3 choices. Public/Public&Private/Private. Detailed architecture is explained here.

I choose the Public & Private one. In this architecture, our control plane is accessible from the public internet, and our workers run in a private network.

AWS public-private VPC diagram 

To create VPC with cloudformation;

  1. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation.
  2. From the navigation bar, select a Region that supports Amazon EKS.
  3. Choose Create a stack, With new resources (standard).
  4. For Choose a template, select Specify an Amazon S3 template URL.
  5. Paste the URL that corresponds to the Region that your cluster is in into the text area and choose Next:
https://amazon-eks.s3.us-west-2.amazonaws.com/cloudformation/2020-08-12/amazon-eks-vpc-private-subnets.yaml
AWS cloudformation eks stack

EKS Setup

Now we can continue with the installation. Select EKS from the service list. Give a name to your cluster. Select the K8s version and Service Role and then press next.

Cluster name and version screen

Select previously created VPC, Subnet and Security group from the current screen. Don't forget to select Public & Private from the Cluster endpoint access section.

Specify networking

On the next screen, you can choose your favourite infra options or leave it off-state.

Congratulations! You have created your EKS cluster.

EKS Node Group Creation

You have successfully deployed EKS but you need worker nodes. For this requirement, you need to select Compute tab from your EKS dashboard and click the Add Node Group button.

Node Group configuration

After you select the name and Node IAM Role, click next and select the machine types and scaling configurations.

Compute and scaling options

We need to select the subnet and ssh options from the last screen.

Networking options

After a few seconds, the nodes will have been created and joined the master.

AWS & Eksctl Setup

If you want to control your cluster with kubectl you need aws cli. Ok, but what is eksctl?

Ekscli is a simple CLI tool for creating clusters on EKS - Amazon's new managed Kubernetes service for EC2. It is written in Go, uses CloudFormation, was created by Weaveworks and welcomes contributions from the community.

Why we did previous step? because I did want to explain what is under the hood.

Let's install eksctl;

brew tap weaveworks/tap

To install;

brew tap weaveworks/tap

To update;

brew upgrade eksctl && brew link

Let's install awscli;

brew install awscli

Configuration

(I assume you have already installed kubectl if not click here)

In order to create a kubeconfig file we need to configure awscli

awscli configure

To create kubeconfig;

aws eks --region [your region code] update-kubeconfig --name [your cluster name]

After these steps, you have successfully configured your kubectl.

kubectl output screen

After configuring your awscli you can create an EKS cluster with ekscli :)

eksctl create cluster

eksctl read your awscli configuration and create a cluster for you with default settings.

The End

We completed EKS cluster installation. Feel free to discover your newly created EKS Cluster.