Three-Tier Application Deployment on Kubernetes (Real-World Project Guide)

By Admin · 2/18/2026

Three-Tier Application Deployment on Kubernetes (Real-World Project Guide) - architecture and deployment guide

In this exhilarating challenge, we're tasked with deploying a Three-Tier Web Application, comprising ReactJS for the frontend, NodeJS for the backend, and MongoDB for the database, all orchestrated on AWS Elastic Kubernetes Service (EKS).

Prerequisites:

  • Basic knowledge of Docker, and AWS services.

  • An AWS account with necessary permissions.

Setup AWS EC2 Instances:

  • Launch two EC2 instances (one for each tier).

  • Choose the appropriate instance type based on your application's requirements.

  • Ensure each instance has the necessary security group settings to allow traffic between them.

Install Docker:

  • Install Docker on each instance. You can use the official Docker installation instructions for your operating system.
sudo apt update
sudo apt install docker.io
sudo chown $USER /var/run/docker.sock

Clone the GitHub Repository:

  • Clone the GitHub repository follow these command:
git clone https://github.com/RahulSinha9/Three-Tier-Appliction.git

Create a Dockerfile for Frontend:

  • To create a docker file follow these command
vim Dockerfile

Inside the Dockerfile:

FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]

Create a docker image from Dockerfile:

  • To create a docker image follow these command:
docker build -t three-tier-fronted .

Then build the Docker Container from Docker image:

  • To create a docker container follow these command:
docker run -d -p 3000:3000 three-tier-fronted:latest

Access your frontend:

  • You can now access the frontend on your web browser:

To push Docker images to Amazon Elastic Container Registry (ECR):

Install AWS CLI:

  • To install aws cli follow these command:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt install unzip
unzip awscliv2.zip
sudo ./aws/install -i /usr/local/aws-cli -b /usr/local/bin --update

Configure AWS CLI:

  • Run aws configure and provide your AWS Access Key ID, Secret Access Key, default region, and output format when prompted.
aws configure

Create an ECR Repository:

  • Navigate to the Amazon ECR console and create a new repository for your Docker images if one does not already exist.

Push commands for three-tier-frontend:

Use the following steps to authenticate and push an image to your repository. For additional registry authentication methods, including the Amazon ECR credential helper.

  1. Retrieve an authentication token and authenticate your Docker client to your registry.

    Use the AWS CLI:

aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/h5f2y8q2
  1. Build your Docker image using the following command. For information on building a Docker file from scratch, see the instructions here .You can skip this step if your image has already been built:
docker build -t three-tier-frontend .
  1. After the build is completed, tag your image so you can push the image to this repository:
docker tag three-tier-frontend:latest public.ecr.aws/h5f2y8q2/three-tier-frontend:latest
  1. Run the following command to push this image to your newly created AWS repository:
docker push public.ecr.aws/h5f2y8q2/three-tier-frontend:latest
  1. Verify Image Push:

    • Check the Amazon ECR console to ensure that your Docker image has been successfully pushed to the repository.

Create a Dockerfile for backend:

  • To create a docker file follow these command:
vim Dockerfile

Inside the Dockerfile:

FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "index.js"]

Then push Docker images to Amazon Elastic Container Registry (ECR):

  • Do the same steps as before to push image on ECR.

Now, Install kubectl:

  • To install kubectl follow these command:
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin
kubectl version --short --client

Install eksctl:

  • To install eksctl follow these command:
curl --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/local/bin
eksctl version

Setup EKS Cluster:

eksctl create cluster --name three-tier-cluster --region us-west-2 --node-type t2.medium --nodes-min 2 --nodes-max 2
aws eks update-kubeconfig --region us-west-2 --name three-tier-cluster
kubectl get nodes

Run Manifests:

Running Kubernetes manifest files typically involves applying them to a Kubernetes cluster using the kubectl command-line tool.

kubectl create namespace three-tier
kubectl apply -f .
kubectl delete -f .

After apply the kubctl:

Install AWS Load Balancer:

  • Installing an AWS Load Balancer involves several steps to configure and deploy it effectively.
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document file://iam_policy.json
eksctl utils associate-iam-oidc-provider --region=us-west-2 --cluster=three-tier-cluster --approve
eksctl create iamserviceaccount --cluster=three-tier-cluster --namespace=kube-system --name=aws-load-balancer-controller --role-name AmazonEKSLoadBalancerControllerRole --attach-policy-arn=arn:aws:iam::626072240565:policy/AWSLoadBalancerControllerIAMPolicy --approve --region=us-west-2

Deploy AWS Load Balancer Controller:

  • To deploy the AWS Load Balancer Controller on your Kubernetes cluster, you can follow these commands:
sudo snap install helm --classic
helm repo add eks https://aws.github.io/eks-charts
helm repo update eks
helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=my-cluster --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
kubectl get deployment -n kube-system aws-load-balancer-controller
kubectl apply -f full_stack_lb.yaml

Cleanup

  • To delete the EKS cluster:
eksctl delete cluster --name three-tier-cluster --region us-west-2

By successfully deploying a Three-Tier Web Application on AWS EKS, we're harnessing the power of cloud-native architectures and DevOps practices to build scalable, resilient, and efficient applications. Here's to conquering this challenge and mastering the art of container orchestration! 🌟🚀 #ThreeTierApplication #AWS #EKS #ContainerOrchestration #DevOpsChallenge 🌐📦

Topic cluster

More kubernetes Articles

Latest related posts connected by shared tags.

Continue learning

Related internal resources

Jump deeper with documentation, cheat sheets, and the full roadmap.