Deploying a Spring Boot application on the cloud
See how one developer deployed his application
Most Java developers already know about the ease of use in building applications by using the Spring Boot framework. But how easy is it to deploy Spring Boot applications on the cloud?
One of my friends asked me recently, “Can we deploy different application components on the cloud?” I told him that it is possible! He asked me how a developer could bind these components once they are deployed on a cloud (via a Kubernetes cluster). The answer: the public cluster IP address can be used in configurations, just like a server IP address (application/database server IP address), in traditional deployments.
In my friend’s case, he was building a war file for a back end and then deployed it on a server. The services deployed in back-end services were invoked by front-end Node.js applications. The database and applications (front end and back end) were deployed on servers on a network, and URLs were shared to end users. He wanted to break this traditional way of working and wanted to shift to the cloud to modernize – and as a result, he also wanted to take advantage of Kubernetes for ease of deployment. (It is much easier to deploy applications with Kubernetes.) You just need a few additional steps, like creating a Docker image and creating cluster and YAML files for deploying applications onto the cloud. That’s all!
For this blog, I can illustrate just how easy and simple this process is by using IBM Cloud™ as an example.
Then, create a Docker image from the Dockerfile.
docker build -t spring-boot-demo
Note: You can view my Dockerfile at https://github.com/ragudiko/spring-boot-demo/blob/master/Dockerfile).
Tag the image (this step requires a Docker account):
docker tag spring-boot-demo ragudiko/spring-boot-demo
Push the image to the Docker registry:
docker push ragudiko/spring-boot-demo
Once you have Docker images for your application components, you can deploy them by using YAML files that are scripted for kubernetes.
kubectl create -f deployment.yaml
All of the applications that are deployed on our cluster can then be accessed by using a public IP address of the cluster. The public IP address of a cluster created on IBM Cloud can be obtained by using the following command:
ibmcloud ks workers <your-cluster-name>
See how easy that was? You can find complete instructions in my instructions.md file.
Once you master the instructions here, try out our code pattern, Deploy Spring Boot microservices on Kubernetes or read up on how IBM Cloud is creating starter kits to enable developers to quickly create Spring applications to the cloud.