AWS Builder Center
kubernets

kubernets

kubernets

Deploying a Kubernetes Application on Amazon EKS Using eksctl and kubectl

Introduction

Amazon Elastic Kubernetes Service (Amazon EKS) is a managed Kubernetes service provided by AWS. It makes it easier to run Kubernetes applications without managing the Kubernetes control plane manually.
In this project, I created an Amazon EKS cluster using eksctl, configured kubectl, deployed an Nginx application, and exposed it using an AWS LoadBalancer service.
This article explains the complete process step by step in a beginner-friendly way.

Architecture

The workflow used in this project is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
AWS Cloud
│
▼
Amazon EKS
my-k8s-cluster
│
┌─────────┴─────────┐
│ │
Worker Node Worker Node
│ │
└─────────┬─────────┘
│
Kubernetes
Deployment
│
Nginx
│
▼
LoadBalancer
│
▼
Internet

1. Prerequisites

For this project, I used:
  • AWS Account
  • Ubuntu EC2 instance
  • AWS CLI
  • eksctl
  • kubectl
  • Amazon EKS
  • Kubernetes
  • Nginx
The EC2 instance was used as the administration machine from which the EKS cluster was created and managed.

2. Install eksctl

eksctl is a command-line tool used to create and manage Amazon EKS clusters.
I downloaded the Linux version of eksctl:
1
curl -sLO "https://github.com/eksctl-io/eksctl/releases/download/v0.231.0/eksctl_Linux_amd64.tar.gz"
Then I extracted the file:
1
sudo tar -xzvf eksctl_Linux_amd64.tar.gz
I installed it into /usr/local/bin:
1
sudo install -m 0755 eksctl /usr/local/bin
To verify:
1
eksctl version
Output:
1
0.231.0
This confirmed that eksctl was successfully installed.

3. Verify AWS Credentials

Before creating the EKS cluster, I verified that the EC2 instance could communicate with AWS.
1
aws sts get-caller-identity
This command returned the AWS account and identity information.
This step is important because eksctl needs AWS permissions to create EKS resources.

4. Create the EKS Cluster

I created an EKS cluster named:
1
my-k8s-cluster
in the AWS Singapore region:
1
ap-southeast-2
The cluster was created using:
1
eksctl create cluster --name my-k8s-cluster --region ap-southeast-2
During the process, eksctl automatically created the required AWS resources, including:
  • EKS control plane
  • VPC networking
  • Subnets
  • Managed node group
  • Worker nodes
  • Kubernetes add-ons
The cluster creation took several minutes because AWS had to provision multiple resources.

5. Verify the EKS Cluster

After cluster creation completed, I checked the cluster:
1
eksctl get cluster --region ap-southeast-2
The EKS cluster was successfully created.
I also verified the worker nodes:
1
kubectl get nodes
The output showed two worker nodes with the status:
1
Ready
For example:
1
2
3
NAME STATUS ROLES
ip-192-168-31-145... Ready <none>
ip-192-168-93-207... Ready <none>
This confirmed that the worker nodes were successfully connected to the EKS cluster.

6. Install kubectl

kubectl is the Kubernetes command-line tool.
I installed the latest Kubernetes client using:
1
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Then:
1
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
I verified the installation:
1
kubectl version --client
The output showed:
1
Client Version: v1.37.1

7. Configure kubectl with EKS

Next, I connected kubectl to my EKS cluster.
1
aws eks update-kubeconfig --region ap-southeast-2 --name my-k8s-cluster
The command added the EKS cluster context to:
1
/root/.kube/config
Now kubectl could communicate with my EKS cluster.

8. Verify Kubernetes Nodes

I ran:
1
kubectl get nodes
Both worker nodes were shown as:
1
Ready
This confirmed that the Kubernetes cluster was working correctly.

9. Deploy Nginx

For the application, I used the popular Nginx web server.
I created an Nginx deployment:
1
kubectl create deployment nginx --image=nginx
This command tells Kubernetes to:
  1. Create a Deployment named nginx
  2. Use the Nginx container image
  3. Create a Pod
  4. Maintain the desired state of the application

10. Verify the Nginx Pod

I checked the Pod:
1
kubectl get pods
The output showed:
1
2
NAME READY STATUS
nginx-66686b6766-b8nj9 1/1 Running
The important part is:
1
1/1 Running
This means the Nginx container is running successfully inside the Kubernetes cluster.

11. Expose Nginx Using a LoadBalancer

A Pod inside Kubernetes is not automatically accessible from the internet.
To expose Nginx externally, I created a Kubernetes Service:
1
kubectl expose deployment nginx --type=LoadBalancer --port=80
The LoadBalancer service tells AWS to provision an external load balancer.
The traffic flow becomes:
1
2
3
4
5
6
7
Internet
↓
AWS Load Balancer
↓
Kubernetes Service
↓
Nginx Pod

12. Verify the Service

To check the service:
1
kubectl get svc
We can expect something similar to:
1
2
NAME TYPE CLUSTER-IP EXTERNAL-IP
nginx LoadBalancer 10.x.x.x xxx.amazonaws.com
The EXTERNAL-IP or hostname can then be used to access the Nginx application from a web browser.

13. What I Learned

Through this project, I learned how different AWS and Kubernetes components work together.

AWS

  • Amazon EC2
  • Amazon EKS
  • VPC
  • IAM
  • CloudFormation
  • AWS Load Balancer

Kubernetes

  • Cluster
  • Control plane
  • Worker nodes
  • Pods
  • Deployments
  • Services
  • LoadBalancer

Tools

  • AWS CLI
  • eksctl
  • kubectl

14. Important Kubernetes Commands

Here are some of the commands used in this project:
1
eksctl version
Check eksctl version.
1
eksctl get cluster --region ap-southeast-2
List EKS clusters.
1
kubectl get nodes
Check worker nodes.
1
kubectl get pods
Check application Pods.
1
kubectl get pods -A
Check Pods across all namespaces.
1
kubectl create deployment nginx --image=nginx
Create an Nginx deployment.
1
kubectl expose deployment nginx --type=LoadBalancer --port=80
Expose Nginx through a LoadBalancer.
1
kubectl get svc
Check Kubernetes Services.

Conclusion

This project demonstrated a simple way to deploy a containerized web application on Amazon EKS.
Using eksctl, I created the EKS cluster and managed worker nodes. Using kubectl, I configured the cluster, created an Nginx deployment, verified the Pods, and exposed the application through a Kubernetes LoadBalancer.
The overall workflow was:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
AWS EC2
↓
Install eksctl
↓
Create Amazon EKS Cluster
↓
Create Worker Nodes
↓
Install kubectl
↓
Configure kubeconfig
↓
Create Nginx Deployment
↓
Verify Nginx Pod
↓
Create LoadBalancer Service
↓
Access Nginx Application
This hands-on project helped me understand the basic relationship between AWS, EKS, Kubernetes, Pods, Deployments, Services, and Load Balancers, and gave me practical experience with deploying an application on AWS using Kubernetes.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article