> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a cluster in Amazon EKS and install kubectl

> Hands-on lab · 45m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/create-a-cluster-in-amazon-eks-and-install-kubectl" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. This lab walks you through the steps to create an EKS Cluster and understand each of its components.
2. You will practice using the AWS Elastic Kubernetes Service cluster and install kubectl to get the cluster IP.
3. Duration: **60 minutes**
4. AWS Region: **US East (N. Virginia) us-east-1**

### Introduction

#### What is Amazon EKS?

* It is a managed container service for running and scaling Kubernetes applications.
* Amazon EKS i.e. Elastic Kubernetes Service can be used in three ways:

  * Deploy applications with Amazon EKS in the cloud: Using AWS Fargate or Amazon EC2
  * Deploy applications with Amazon EKS anywhere: For your on-premise infrastructure
  * Deploy applications with your own tools: Using Bare metal, virtual machines, and Amazon EC2 instances
* Since EKS is a managed service, it allows you to run Kubernetes on AWS without having to install Kubernetes.
* It provisions and scales control plane, API Servers, and backend persistence layers across multiple AZs for high availability and fault tolerance. Also, it automatically detects and replaces the unhealthy control plane nodes for patching.
* Amazon EKS is integrated with many AWS Services like ELB for load distribution, IAM for authentication, Amazon VPC for isolation and CloudTrail for logging.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/001.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=2e7cc3d678624a2607ae4f3a5d33b6b8" alt="" width="700" height="580" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/001.png" />

### Task details

1. Sign into AWS Management Console.
2. Create an EKS Cluster
3. Create an Environment in CloudShell.
4. Install kubectl on AWS CloudShell.
5. Configure your AWS CloudShell to communicate with your cluster.
6. Validation of the lab
7. Deleting AWS Resources

### Launching the lab environment

1. To launch the lab environment, Click on the **Launch lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with **IAM user name**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

**Note** : You can only start one lab at any given time

## Lab guide

### Lab steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

   * Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
   * Now copy your **User Name** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign in** button.
3. Once Signed In to the AWS Management Console, Make the default AWS Region as **US East (N. Virginia) us-east-1.**

<Note>
  If you face any issues, please go through [**FAQs and Troubleshooting**](/aws-cp/support/faqs-and-troubleshooting).
</Note>

#### #### Task 2: Create an EKS Cluster

1. Make sure you are in the **N.Virginia** Region.

2. Navigate to **Elastic Kubernetes Service** by clicking on the **Services** menu available under the **Containers** section.

3. Click on **Create cluster** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/002.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=956bd7a113351b7f575c47750aea9b5c" alt="" width="1222" height="287" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/002.png" />

4. Enter the cluster name as a ***whiz***

5. Keep the Kubernetes version as default

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/003.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=f7cf96bee28e543a6ee9df3b90361a90" alt="" width="1222" height="384" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/003.png" />

   * Cluster IAM role: Choose the existing IAM role
   * **Note** : Ignore below notification messages, and follow further steps.

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/004.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=ca90e635307172e4cb7e633ddd695c83" alt="" width="1222" height="309" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/004.png" />
   * Node IAM role: Choose the existing IAM role

6. VPC: Select the **Default VPC**.

7. Subnets: Select the subnets for us-east-1a, us-east-1b, us-east-1c and us-east-1 and **remove** the subnets **us-east-1e** and **us-east-1f**.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/005.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=0c192bb250f7ae03b723439b1636b7b7" alt="" width="1222" height="287" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/005.png" />

8. Click on the **Create** button.
   **Note: Cluster creation will take about 10-15 minutes.**

9. Cluster is created now.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/006.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=375b223dc6ae2f224bd8b80ca6ad7c44" alt="" width="1222" height="195" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/006.png" />

#### Task 3 : Create an Environment in CloudShell

1. Make sure you are in the **N.Virginia** Region.
2. Click on **Arrow** icon (Cloud Shell) on the top AWS menu bar.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/007.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=8ebeb28a2f8bd5bd33b012fb2143803c" alt="" width="778" height="98" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/007.png" />
3. Once the environment is created, you are ready to use the terminal.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/008.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=a1e0a52958c22cb5d3ec0268a2bf334c" alt="" width="862" height="618" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/008.png" />

#### Task 4 : Install kubectl on AWS CloudShell

1. Once the environment is ready **run all these commands the terminal**, Download the Amazon EKS vended kubectl binary for your cluster's Kubernetes version from Amazon S3. To do so, un the following command:

   ```
   curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl
   ```
2. Apply execute permissions to the binary.

   ```
   chmod +x ./kubectl
   ```
3. Copy the binary to a folder in your PATH. If you have already installed a version of kubectl, then we recommend creating a $HOME/bin/kubectl and ensuring that $HOME/bin comes first in your \$PATH.

   ```
   mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
   ```
4. After you install kubectl, you can verify its version with the following command:

   ```
   kubectl version --short --client
   ```

#### Task 5 : Configure your AWS CloudShell to communicate with your cluster

1. Once the environment is ready on CloudShell, you create a kubeconfig file for your cluster. The settings in this file enable the **kubectl** CLI to communicate with your cluster.
2. To create a kubeconfig file, run the following command:

   ```
   aws eks update-kubeconfig --region us-east-1 --name whiz
   ```

   * **Note: If your cluster name is not whiz, Update your cluster name in the above command.**
3. Test your configuration, with the following command:

   ```
   kubectl get svc
   ```

<img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/009.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=cd51b82975679e4ec62c419103486e41" alt="" width="1042" height="144" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/009.png" />

<Tip>
  **Do you know?**

  You can create an Amazon EKS cluster without specifying a VPC. This is because Amazon EKS can automatically create a VPC for your cluster. However, if you do specify a VPC, you will have more control over the networking configuration of your cluster.
</Tip>

#### Task 6: Validation Test

1. Once the lab steps are completed, please click on the **Check my work** button on the right side panel.
2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
3. Sample output :

<img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/010.gif?s=cc9f6ceab7ca1674c4630017b8212ac2" alt="" width="1002" height="479" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/010.gif" />

#### Task 7: Delete AWS Resources

##### Deleting EKS cluster

1. Navigate to **Elastic Kubernetes Service** by clicking on the **Services** menu available under the **Containers** section..
2. On the left sidebar, click on the **Clusters** option in the left panel.
3. whiz EKS cluster will be listed here.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/011.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=c743742d29231912f0156cb945d25c83" alt="" width="1222" height="195" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/011.png" />
4. To delete the cluster, perform the following task:

   * Select the present cluster,
   * Click on the Delete button.

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/012.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=fc98368710fea65a290716c8de26e809" alt="" width="1222" height="206" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/012.png" />
5. Confirm the deletion by typing the cluster name **whiz** in the required field, and click on the **Delete** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/2u36x6URmH9hJ3QL/images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/013.png?fit=max&auto=format&n=2u36x6URmH9hJ3QL&q=85&s=2b0ab4f7430829cc2669895a79f25fba" alt="" width="1172" height="792" data-path="images/labs/create-a-cluster-in-amazon-eks-and-install-kubectl/013.png" />
6. The cluster will be deleted within 10-15 minutes.

### Completion and conclusion

1. You have successfully created and launched Amazon EKS Cluster.
2. You have successfully installed Kubectl in AWS Cloudshell.
3. You have successfully configured AWS Cloudshell to communicate with AWS EKS Cluster.

### End lab

1. Sign out of AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End lab** in the IP Lab Portal.

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Check EKS Cluster Exists** — Check whether an EKS cluster is created
* **Check EKS Cluster Status Active** — Check EKS cluster is in ACTIVE state

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
