Kubernetes_Native_Microservices-RedHat_Final v4 cover

Kubernetes Native Microservices with Quarkus and MicroProfile

John Clingan, Ken Finnigan
English

Overview

Kubernetes Native Microservices with Quarkus and MicroProfile provides an essential understanding of what it takes to develop cloud-native applications using modern tools such as microservices that utilize and integrate with Kubernetes features naturally and efficiently. The result is a productive developer experience that is consistent with the expectations of Kubernetes platform administrators.

This book will show you how to combine Quarkus, microservices, MicroProfile, Spring, and Kubernetes into an effective and integrated development and deployment stack. By reading this book, you will:

  • Understand what microservices are and how they have evolved over the last decade as a popular enterprise software architecture. 
  • Dive into the history and overview of MicroProfile and its growth into a significant collection of microservices-related specifications and introduce Quarkus as a Java runtime that supports these technologies. 
  • Get an introduction to core Kubernetes concepts and why they make Kubernetes an ideal microservices deployment platform.
  • Learn how to unite Java, MicroProfile, Quarkus, and Kubernetes to build fast, efficient applications.
  • Get step-by-step instructions on how to make code changes in Quarkus Live Coding.
  • Learn how to develop Java microservices  that target Kubernetes as a deployment environment using Quarkus and MicroProfile.

Download the e-book at no cost.

Excerpt

What is a microservice?

An internet search will result in hundreds of microservice definitions. There is no industry consensus on a single definition, but some common and well-understood principles exist. We are using a definition that aligns with those principles but with a particular emphasis on one principle—isolation. As defined in Enterprise Java Microservices, a microservice consists of a single deployment executing within a single process, isolated from other deployments and processes, that supports the fulfillment of a specific piece of business functionality. 

We are going to put a bit more emphasis on the runtime aspect of isolation than most other writings. With Kubernetes as the target deployment platform, we have an opportunity for optimizing code and the Java runtime itself. Although a microservice is isolated business functionality, it nearly always interacts with other microservices. That is the basis of many code examples for this book. There are a couple of useful points to make when breaking down the selected definition.

First, a microservice implements a specific piece of business functionality, known as a bounded context (as explained by Eric Evans), which is a logical separation of multiple business problem domains within an enterprise. By logically breaking down a business domain into multiple bounded contexts, each bounded context more accurately represents its specific view of the business domain and becomes easier to model.

As represented in figure 1.1, the set of bounded contexts for a small business accounting application may include accounts receivable, accounts payable, and invoic ing. A traditional monolithic application would implement all three bounded contexts. Multiple bounded contexts within in a single monolith can result in “spaghetti code” as a result of unnecessary interdependencies and unplanned intermixing of contexts. In a microservices architecture, each of these capabilities is modeled individually as a bounded context and implemented as a microservice that addresses each specific bounded context.

Next, a microservice executes within a single isolated process. Although this is not a concrete requirement, it has become a preferred architectural approach. There are some practical reasons behind this, based on more than a decade of experience of deploying applications to Java EE application servers and servlet containers like Apache Tomcat. We refer to these synonymously as “application servers.”

From a technical perspective, application servers can host multiple microservices. However, this deployment model has fallen out of favor for the following reasons:

  • Resource management—One microservice can starve other microservices of resources. The Java Virtual Machine (JVM) does not have built-in resource management to limit resource consumption by different applications within the same JVM instance.
  • Patching/upgrading—Patching or upgrading an application server negatively impacts the availability of all hosted microservices simultaneously.
  • Versioning—Each microservice development team may want to evolve at a different pace, causing an application server versioning-requirements mismatch. Some may want to leverage new features of the latest version, whereas others may prefer to avoid introducing risk because the current version is stable in
    production.
  • Stability—One poorly written microservice can cause stability issues for the entire application server, impacting the availability of the remaining stable applications.
  • Control—Developers rightfully cede control of shared infrastructure, like application servers, to a separate DevOps team. This limits developer options like JDK version, tuning for a specific microservice’s optimal performance, application server version, and more.

Related E-books