
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
│
▼
Internet1. Prerequisites
For this project, I used:
- AWS Account
- Ubuntu EC2 instance
- AWS CLI
eksctlkubectl- 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.gzI installed it into
/usr/local/bin:1
sudo install -m 0755 eksctl /usr/local/binTo verify:
1
eksctl versionOutput:
1
0.231.0This 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-identityThis 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-clusterin the AWS Singapore region:
1
ap-southeast-2The cluster was created using:
1
eksctl create cluster --name my-k8s-cluster --region ap-southeast-2During 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-2The EKS cluster was successfully created.
I also verified the worker nodes:
1
kubectl get nodesThe output showed two worker nodes with the status:
1
ReadyFor 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/kubectlI verified the installation:
1
kubectl version --clientThe output showed:
1
Client Version: v1.37.17. Configure kubectl with EKS
Next, I connected
kubectl to my EKS cluster.1
aws eks update-kubeconfig --region ap-southeast-2 --name my-k8s-clusterThe command added the EKS cluster context to:
1
/root/.kube/configNow
kubectl could communicate with my EKS cluster.8. Verify Kubernetes Nodes
I ran:
1
kubectl get nodesBoth worker nodes were shown as:
1
ReadyThis 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=nginxThis command tells Kubernetes to:
- Create a Deployment named
nginx - Use the Nginx container image
- Create a Pod
- Maintain the desired state of the application
10. Verify the Nginx Pod
I checked the Pod:
1
kubectl get podsThe output showed:
1
2
NAME READY STATUS
nginx-66686b6766-b8nj9 1/1 RunningThe important part is:
1
1/1 RunningThis 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=80The
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 Pod12. Verify the Service
To check the service:
1
kubectl get svcWe can expect something similar to:
1
2
NAME TYPE CLUSTER-IP EXTERNAL-IP
nginx LoadBalancer 10.x.x.x xxx.amazonaws.comThe
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 versionCheck eksctl version.
1
eksctl get cluster --region ap-southeast-2List EKS clusters.
1
kubectl get nodesCheck worker nodes.
1
kubectl get podsCheck application Pods.
1
kubectl get pods -ACheck Pods across all namespaces.
1
kubectl create deployment nginx --image=nginxCreate an Nginx deployment.
1
kubectl expose deployment nginx --type=LoadBalancer --port=80Expose Nginx through a LoadBalancer.
1
kubectl get svcCheck 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 ApplicationThis 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.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article