Deploying Java Applications with Docker and Kubernetes | DevOps Project
In this project, you will get know to know how one application is deployed on the Kubernetes cluster.

As shown in the above picture, you will get an idea about the project.
Building Java Application using Maven.
Containerize images and Deploy them to Docker Hub.
Deploying onto Kubernetes.
Project Overview:-
As a developer, you will commit your code to Git repository. Now you have your whole project on Git Hub (central repository) and if it is public so anyone can access that code on his local machine with the help of git clone operation.
The code present in the git hub is only the base code, you don't have .jar or .war file. So you need to build your code with the help of Maven so that your code converts into a target file like .jar or .war
Then you have to write Dockerfile to convert it into a Docker image.
Once you build the Docker images push it into the Docker Hub registry.
Deploy the application onto the Kubernetes cluster (Minikube).
Pre-requisite:-
Java Application
Docker Installed
Kubernetes Cluster
Basic knowledge of Docker, Maven and Kubernetes.
All the required tools are installed in the system.

Minikube Installation:-
If you don't know about how to set up the Minikube cluster, then follow below video link where you will step-by-step process of Minikube installation.
https://www.youtube.com/watch?v=qG7FGVWijeM
Now install Maven to build your application.


Now you need to set the environment variable for Maven.

Now it's time to clone your code which is present in GitHub using the below command.
"git clone https://github.com/nileshgan/docker-Java-kubernetes-project.git"


Now we will write our Dockerfile to build the images. Right now we don't have docker images.

Now try to build the image.

As you see the docker build is failed.
Now you will get a question that why the build failed - Build failed because there is no target folder in your current path.

to get that target folder you need to build your application first using the below command.
"mvn clean install"

Now try to log in to the docker hub.

Now you will be ready to build the image.

we were successfully able to build our image.

In the same way, you can build images for the other two services.
The build is done for all the services.

Now try to push the image into the docker registry.

We are successfully able to push images into the docker hub.

Now we have to write the deployment YAML files for all three services.
shopfront-service.yaml

stockmanager-service.yaml

productcatalogue-service.yaml

Now you have to apply these YAML files using kubectl so that the container will create and you will able to run the application into that container.


This is how you can deploy any kind of Java application onto Kubernetes. You can create a .jar file with the help of a building tool like Maven. For the deployment process steps are very much similar.
Thank you everyone to read this. Hopefully, this is helpful for you to understand how exactly you can deploy your java based application on Kubernetes.
