Create an EKS Cluster with Nginx Application on AWS

A Cloud Enthusiast
Search for a command to run...

A Cloud Enthusiast
No comments yet. Be the first to comment.
DNS changes are powerful and risky. A single incorrect Route 53 record can cause outages, security exposure, or compliance issues. A simple but effective governance control is to get alerted whenever

Description Terraform is an infrastructure-as-code tool that makes handling infrastructure more straightforward and manageable. A Terraform module is a collection of configuration files that encapsula
In this article, I will briefly define what is DevOps, then we will discuss the suggested strategy to manage and automate DevOps teamwork in the context of AWS Team. What is DevOps? DevOps is the combination of cultural philosophies, practices, and t...
Introduction In this blog, we will demonstrate how to proactively monitor a web server EC2 security group for any traffic rule changes using Lambda along with a few other services. If we detect any unauthorized changes, we will then undo them using L...

Amazon Elastic Kubernetes Service (Amazon EKS) is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS and on-premises. Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications. Amazon EKS is certified Kubernetes-conformant, so existing applications that run on upstream Kubernetes are compatible with Amazon EKS.
Amazon EKS automatically manages the availability and scalability of the Kubernetes control plane nodes responsible for scheduling containers, managing application availability, storing cluster data, and other key tasks.
In this blog, I will step you through the process of deploying an nginx web server on EKS cluster.
Go to IAM > Users and click on "Add users"
Specify the username for example k8s-admin, enable Programmatic access, and hit Next.
Click on Attach existing policies directly and select the AdministratorAccess policy.
Proceed till the end and click on Create user
Copy both Access key ID and Secret access key and save them for later use.
In this step, we will start by creating an EC2 instance, updating the AWS CLI version, and configuring the AWS CLI using the credentials of the user created in the previous step. We will then install both eksctl and kubectl on that EC2 instance. This instance will act as an admin workstation to run all administrative commands from.
Go to EC2 service and click on Launch instance.
Follow below instructions:
Set Name: k8s-admin
Select AMI: Amazon Linux 2 AMI
Keep the default Instance Type t2.micro
Create new key pair with you preferred name and download it (Note: Select .ppk format if you are using Putty)
Edit Network Settings and enable Auto-assign public IP
Keep other settings as is and click Launch instance
Wait till the Status check turns into 2/2 checks passed and then click on Connect. Choose EC2 Instance Connect and press on Connect button to access the EC2 instance terminal.
Follow the instructions from the AWS documentation here or follow the below steps to update the AWS CLI version:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --bin-dir /usr/bin --install-dir /usr/local/aws-cli --update
aws --version

Run aws configure and set below values:
AWS Acsess Key ID and AWS Secret Access Key from previous step
Default Region name: us-east-1
Default output format: json
Install kubectl with following commands:
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.16.8/2020-04-16/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
kubectl is installedkubectl version --short --client
eksctlcurl --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/bin
eksctl is installedeksctl version
us-east-1eksctl create cluster --name dev --region us-east-1 --nodegroup-name standard-workers --node-type t3.medium --nodes 3 --nodes-min 1 --nodes-max 4 --managed
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.
eksctl get cluster

aws eks update-kubeconfig --name dev --region us-east-1
sudo yum install -y git
git clone https://github.com/noweder/EKS-with-Nginx.git
cd EKS-with-Nginx
kubectl apply -f ./nginx-svc.yaml
kubectl get service

kubectl apply -f ./nginx-deployment.yaml
kubectl get deployment

kubectl get pod

kubectl get rs

kubectl get node

<LOAD_BALANCER_DNS_HOSTNAME> with your specific Load Balancer DNS addresscurl <LOAD_BALANCER_DNS_HOSTNAME>


If you get above results, it means that you have successfully accessed the Nginx application running in container which is deployed in the EKS cluster and exposed to the internet via the load balancer service.
Thank you for reading!