DEPLOY 3 PODS IN k8 AND CHECK THE ENDPOINTS / VISUALISE k8s DASHBOARD
STEP 1 –MINIKUBE AND DOCKER INSTALLATION ON
AMAZON LINUX
1. Launch an instance from an Amazon Linux 2 or Amazon
Linux AMI
2. Connect to your instance.
3. Update the packages and package caches.
ssh -i Kubernetes-setup.pem ec2-user@13.201.41.28
yum update -y
4. Install the latest Docker Engine packages.yum install docker -y
5. Start the Docker service.systemctl start docker
systemctl enable docker
6. Install Conntrack and Minikube:yum install conntrack -y
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64sudo
install minikube-linux-amd64 /usr/local/bin/minikube
7. Start your MINIKUBE/usr/local/bin/minikube start --force --driver=docker
STEP 2 - INSTALL MAVEN/GIT/JAVA
MAVEN
yum install maven -y
cd /opt/
GITyum install git -y
JAVAyum install java -y
STEP 3 – INSTALL KUBECTL
curl -o kubectl
https://amazon-eks.s3.us-west-2.amazonaws.com/1.20.4/2021-04-12/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin
cp ./kubectl $HOME/bin/kubectl
export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
source $HOME/.bashrc
kubectl version --short –client
STEP 4 – https://github.com/DharmendraChourasiya/kubernetes_java_deployment.git
STEP 5 – IMPORTANT STEP
[ 3 SERVICES IN PROJECT ]
SERVICE1 [ Give your dockerhub ID in place of dharm1996 ]
cd shopfront/mvn clean install -DskipTests
docker build -t dharm1996/shopfront:latest .
docker push dharm1996/shopfront:latest
SERVICE2 [ Give your dockerhub ID in place of dharm1996 ]
cd productcatalogue/mvn clean install -DskipTests
docker build -t dharm1996/productcatalogue:latest . docker push dharm1996/productcatalogue:latest
SERVICE3 [ Give your dockerhub ID in place of dharm1996 ]
cd stockmanager/mvn clean install -DskipTests (to convert your application into jar) docker build -t dharm1996/stockmanager:latest . docker push dharm1996/stockmanager:latest
First Login into dockerhub using command docker login then enter username and password
docker login
Docker hub Public Repository
STEP 6 - GO TO KUBERNETES FOLDER IN SAME
PROJECT
cd kuberneteskubectl apply -f shopfront-service.yaml kubectl apply -f productcatalogue-service.yaml kubectl apply -f stockmanager-service.yaml
you can check the pods and services
STEP 7 – Hit the below command to start the kubernetes dashboard in EC2/usr/local/bin/minikube dashboard
STEP 8 [ IN NEW EC2 WINDOW ] - Open the EC2 in new window and set the PROXYkubectl proxy --address='0.0.0.0' --accept-hosts='^*$'
STEP 9 - Hit in browser to view the dashboard
http://<EC2-IP>:8001/api/v1/namespaces/kubernetes-da
shboard/services/http:kubernetes-dashboard:/proxy/#/po
d?namespace=defaultKub
Kubernetes Dashboard
STEP 10 – Hit the below command for each service in
different console of EC2
[ EC2 LOGIN FIRST ]
kubectl port-forward --address 0.0.0.0 svc/shopfront
8080:8010
[EC2 LOGIN FIRST]
kubectl port-forward --address 0.0.0.0 svc/productcatalogue
8090:8020
[ EC2 LOGIN FIRST ]
kubectl port-forward --address 0.0.0.0 svc/stockmanager
9008:8030
STEP 11 – http://<EC2IP>:8090/products
Subscribe to my newsletter
Read articles from Dharmendra Chourasiya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by