Creating Kubernetes Cluster On Amazon EKS

Christopher Quiles
5 min readJan 19, 2021

--

In this lab we’ll run through the process of creating a Kubernetes Cluster using Amazon EKS.

Amazon EKS:

Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS and on-premises. Amazon EKS is certified Kubernetes conformant, so existing applications that run on upstream Kubernetes are compatible with Amazon EKS.

EKS runs the Kubernetes control plane across multiple AWS Availability Zones, automatically detects and replaces unhealthy control plane nodes, and provides on-demand, zero downtime upgrades and patching.

Course files can be found here: https://github.com/quiwest/Course_EKS-Basics.git

Requirements:

  1. AWS Console → https://aws.amazon.com/free/
  2. Patience…

Create an IAM User with Admin Permissions:

Let’s get started. Log into your AWS console.

  1. Navigate to IAM > Users.
  2. Click Add user.
  3. Set the following values to the user:
  • User name: k8-admin
  • Access type: Programmatic access

4. Click Next: Permissions.

5. Select Attach existing policies directly.

6. Select AdministratorAccess.

7. Click Next: Tags > Next: Review.

8. Click Create user.

9. Copy the access key ID and secret access key.

Launch an EC2 Instance

  1. Navigate to EC2 > Instances.
  2. Click Launch Instance.
  3. On the AMI page, select the Amazon Linux 2 AMI.
  4. Leave t2.micro selected, and click Next: Configure Instance Details.
  5. On the Configure Instance Details page:
  • Network: Leave default
  • Subnet: Leave default
  • Auto-assign Public IP: Enable (THIS IS IMPORTANT)

6. Click Next: Add Storage > Next: Add Tags > Next: Configure Security Group.

7. Click Review and Launch, and then Launch.

8. In the key pair dialog, select Create a new key pair.

9. Give it a Key pair name of “mynvkp”.

10. Click Download Key Pair, and then Launch Instances.

11. Click View Instances, and give it a few minutes to enter the running state.

12. Once the instance is fully created, check the checkbox next to it and click Connect at the top of the window.

13. In the Connect to your instance dialog, select SSH CLIENT.

14. Run the following commands in your terminal and connect to instance.

Configure the Command Line

After logging into the EC2 following the following commands

AWS Configure:

Configure your AWS credentials inside the CLI. Grab the access key and password we created earlier for the IAM user.

Kuberenetes:

Download kubectl
The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

Download eksctl:
eksctl
is a simple CLI tool for creating clusters on EKS — Amazon’s new managed Kubernetes service for EC2. It is written in Go, and uses CloudFormation.

Provision an EKS Cluster

  1. Provision an EKS cluster with three worker nodes in us-east-1:

It will take 10–15 minutes since it’s provisioning the control plane and worker nodes, attaching the worker nodes to the control plane, and creating the VPC, security group, and Auto Scaling group.

2. In the AWS Management Console, navigate to CloudFormation.

Under Services, you can find CloudFormation under Management & Governance.
we should see the cluster eskctl-dev-cluster creating in Cloudformation
Click Events, so you can see all the resources that are being created.
Click dev in the breadcrumb navigation link at the top of the screen.
The cluster and worker nodes are now complete.
Navigate to EC2 > Instances, where you should see the instances have been launched.

3. In the CLI, check the cluster:

Create a Deployment on Your EKS Cluster:

Git is a distributed version-control system for tracking changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows

Create service and deployment:

  1. Copy the external IP of the load balancer, and paste it into a text file, as we’ll need it in a minute.

2. Access the application using the load balancer, replacing <LOAD_BALANCER_EXTERNAL_IP> with the IP you copied earlier:

curl "<LOAD_BALANCER_EXTERNAL_IP>"

3. The output should be the HTML for a default Nginx web page.

4. In a new browser tab, navigate to the same IP, where we should then see the same Nginx web page.

Conclusion:

  1. In the AWS console, on the EC2 instances page, select the three t3.micro instances.
  2. Click Actions > Instance State > Stop.
  3. In the dialog, click Yes, Stop.

In the CLI, delete everything:

eksctl delete cluster dev

Hopefully this helped somebody out there, thanks for taking the time!

Connect with me:

linked in → https://www.linkedin.com/in/quiwest/

email → quileswest@gmail.com

--

--