Deploying a Spring Boot application on the cloud

March 6, 2019 devadvin

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.

  1. First, create a cluster in the cloud.
    (If you’re using IBM Cloud, just follow these directions.)

  2. 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).

  3. Tag the image (this step requires a Docker account):

    docker tag spring-boot-demo ragudiko/spring-boot-demo
    

  4. Push the image to the Docker registry:

    docker push ragudiko/spring-boot-demo
    

  5. 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
    

  6. You can find examples of YAML files for back-end and databases and for Node.js, in my GitHub repo for reference.

  7. 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.

Previous Article
Join the OpenJS Foundation, JavaScript’s new home
Join the OpenJS Foundation, JavaScript’s new home

The Node.js Foundation and JavaScript Foundation are merging to form the OpenJS Foundation. The OpenJS Foun...

Next Article
Not your grandpa’s mainframers: Who are today’s Z developers?
Not your grandpa’s mainframers: Who are today’s Z developers?

Today's mainframe developers are a widely diverse group of people who use their skills to solve a broad ran...

×

Want our latest news? Subscribe to our blog!

Last Name
First Name
Thank you!
Error - something went wrong!