From Zero to Creating an Amazon EKS Kubernetes Cluster with Eksctl
Tags: aws, kubernetes, eks, eksctl
Published: 2021-03-04 20:51:28

AWS and Kubernetes can be intimidating at times, and setting up K8s clusters manually can lead to headaches if not properly configured. Luckily, [eksctl](https://eksctl.io/) allows you to create your own EKS cluster in a matter of minutes without headache or hassle. In this guide, we will install the necessary command line tools and create a Kubernetes cluster on AWS

## What is Kubernetes?

Kubernetes is open-source software that allows you to manage and deploy any number of containers. For a simple explanation of containers and Kubernetes clusters, see the [Illustrated Children's Guide to Kubernetes](https://www.youtube.com/watch?v=3I9PkvZ80BQ).


## Installing AWS CLI

First, we need to install Amazon's command-line tool that allows us to set up and configure AWS services from the command line. These install directions come from [AWS Documentation](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html). 

### Installing on Linux

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

### Installing on Windows

Download and run the .msi installer for AWS CLI [here](https://awscli.amazonaws.com/AWSCLIV2.msi)

### Installing on Mac

Download and run the .pkg installer for AWS CLI [here](https://awscli.amazonaws.com/AWSCLIV2.pkg)

### Configuring AWS CLI

Once you have `aws` installed, you will need to configure it to communicate with your aws account. In order to do that, you will need to log into your aws management console, and under IAM settings you will need to get an [access key and secret key](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds). 

Once you have that, run the command
```
aws configure
```
and respond to each of the the prompts appropriately.

## Installing `kubectl`

`kubectl` is Kubernetes' command-line tool that allows you to manage your Kubernetes clusters. Kubernetes documentation has a pretty good overview of the things that you can do using kubectl [here](https://kubernetes.io/docs/reference/kubectl/cheatsheet/). For more options for installing kubectl, refer to the documentation [here](https://kubernetes.io/docs/tasks/tools/install-kubectl/)

### Installing on Debian-based linux

```bash
sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2 curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
```

### Installing with Centos/Redhat/Fedora

```bash
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl
```

### Installing with choco on Windows
To install kubectl using the [chocolatey package manager](https://chocolatey.org/install):

```
choco install kubernetes-cli
```

### Installing using homebrew on Mac
To install kubectl using the [homebrew package manager](https://brew.sh/)
```
brew install kubectl
```

## Installing `eksctl`
`eksctl` is a CLI for creating and managing Amazon EKS clusters. 

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

### Installing with choco on Windows
To install eksctl using the [chocolatey package manager](https://chocolatey.org/install):

```
choco install eksctl
```

### Installing using homebrew on Mac
To install eksctl using the [homebrew package manager](https://brew.sh/)
```
brew tap weaveworks/tap
brew install weaveworks/tap/eksctl
```

At this point, we are ready to spin up our AWS Cluster
```
eksctl create cluster
```

Will create a brand new cluster with a random name and two m5.large worker nodes. 

Congratulations! You have created your first EKS cluster. From here, you might want to read more on the [eksctl documentation](eksctl.io) or look into AWS's recommended [next steps](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html#gs-eksctl-next-steps)