Deploying Java Applications with Docker and Kubernetes.

Deploying Java Applications with Docker and Kubernetes.

Pre-requisite:-

  1. Sample Java application.

  2. Install Git, Maven, Docker & K8s Cluster.

Step 1 - Clone the Git Project Repo

  1. git clone github.com/sumit0012/docker-Java-kubernetes..

  2. cd docker-java-kubernetes-project.git

Step 2 - Create a Target folder for each service using mvn & Create a Docker image.

  1. First, go inside each service and give the mvn clean install command which will create a jar file for our Java application.

  2. Then give the command docker build -t <image-name> .

  3. To check docker image >> docker images

  4. Then store the Docker Images in the Docker hub as a Backup by using the docker push command.

  5. After pushing it to the docker hub it will look like the below image.

Step 3 - Deploy our Application using K8s.

  1. Go inside the Kubernetes folder >> cd Kubernetes

  2. Give the command to create pods, services, and deployment >> kubectl apply -f example.yaml/yml

  3. Check whether our pods are running or not >> kubectl get pods

  4. Check our Services >> kubectl get svc

  5. Check our Deployments >> kubectl get deployment

Step 4 - Check whether our Application is running on a live server or not.

  1. First, give the port number of each service to your master and node Security Groups manually.

  2. Then copy our public IP and add the port number where our particular service is running such as 3.109.60.213:32640.

    Home Page of our Java Application

    Stock Page of our Application

    Product Catalogue Page of our Application

Step 5 - Clean Up our Instances.

  1. Remember if you want to avoid billing in your Cloud Account always clean up your Instances after your use.

  2. First delete k8s cluster >> kops delete cluster --name=<cluster-name> --yes

  3. Delete all your k8s work >> kubectl delete all --all

  4. Lastly, terminate your Instances.

\>>>>>>>>>>>>>>>>>>>>> Thank You <<<<<<<<<<<<<<<<<<<<<<<<

Did you find this article valuable?

Support Sumit's Tech by becoming a sponsor. Any amount is appreciated!