Deploy Spring Boot microservices on Kubernetes

Get the code

Summary

Spring Boot is an opinionated framework for quickly building production-ready Spring applications. This pattern shows you how to create and deploy Spring Boot microservices within a polyglot application and then deploy the app to a Kubernetes cluster.

Description

The Java community is finding innovative ways to use technologies like Java EE within microservices architectures. The Spring framework is an established presence in the Java ecosystem, and now Spring Boot is garnering a lot of attention because it radically simplifies writing a Spring application.

Spring Boot takes an opinionated view of building Spring applications. You can use Spring Boot to create stand-alone Java applications that can be started using the Java -jar command or more traditional WAR deployments. Spring applications can be deployed as WAR files atop existing app servers, or they can be built into a “fat” JAR file with an embedded app server. Either choice works well within a Docker container. You can then rely on native Spring platforms like Spring Cloud to perform tasks such as service discovery, registration, and load balancing.

But what do we do in the context of polyglot applications? For managing a system of polyglot microservices, you need a general-purpose microservices and container orchestration platform, and that’s where Kubernetes shines. In this developer pattern, you’ll build an app called Office Space — and yes, it’s inspired by Michael Bolton’s idea in the movie “Office Space.” When you complete the pattern, you’ll understand how to deploy a polyglot microservices application, including Spring Boot microservices, on a Kubernetes cluster.

Flow

flow

  1. The Transaction Generator service written in Python simulates transactions and pushes them to the Compute Interest microservice.
  2. The Compute Interest microservice computes the interest and then moves the fraction of pennies to the MySQL database to be stored.
  3. The database can be running within a container in the same deployment or on a public cloud such as IBM Cloud.
  4. The Compute Interest microservice then calls the notification service to notify the user if an amount has been deposited in the user’s account.
  5. The Notification service uses OpenWhisk actions to send an email message to the user. You can also invoke an OpenWhisk action to send messages to Slack.
  6. Additionally, an OpenWhisk action to send messages to Slack can also be invoked.
  7. The user retrieves the account balance by visiting the Node.js web interface.

Instructions

Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.