Three Tier application deploy with AWS EKS and k8s
In this Project I am Using Docker,AWS ECR Kubernetes, Ingress, AWS ALB
Firstly i want to clone any three-tier application from github and make it containerise with Docker
git clone https://github.com/SarthakTyagiji/TWSThreeTierAppChallenge.git
Now go to Application>frontend>here make a Dockerfile
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "start" ]
Build it and run it
docker build -t sarthak_front .
docker run -d -p 3000:3000 sarthak_front
#React application by default run on Port 3000
now check it's run or not go to browser
localhost:3000
#if it's running perfectly then kill that container and rm it
docker kill container id
docker rm container id
cd ..
cd backend and make a docker file in it
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "index.js"]
same build it run it
docker build -t sarthak_back .
docker run -d -p 3500:3500 sarthak_front
Now it's time to push it to aws ecr so for that you need
AWS cli in your pc then install it first go to home dir cd ..
Install AWS CLI 2
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
aws configure
Now make a iam user and give secure key and access key paste it here
Now in AWS ECR make a repo and push it here
front end and backend
Install kubectl
Go to home and install kubernetes controller
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
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
It take 15-20 min for making a cluster by Cloud Formation