Hands-On Cloud-Native Applications with Java and Quarkus - Francesco Marchioni - E-Book

Hands-On Cloud-Native Applications with Java and Quarkus E-Book

Francesco Marchioni

0,0
32,36 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Build robust and reliable Java applications that works on modern infrastructure, such as containers and cloud, using the new features in Quarkus 1.0




Key Features



  • Build apps with faster boot time and low RSS memory using the latest Quarkus 1.0 features


  • Seamlessly integrate imperative and reactive programming models to build modern Java applications


  • Discover effective solutions for running Java on serverless apps, microservices, containers, FaaS, and the cloud



Book Description



Quarkus is a new Kubernetes-native framework that allows Java developers to combine the power of containers, microservices, and cloud-native to build reliable applications. The book is a development guide that will teach you how to build Java-native applications using Quarkus and GraalVM.






We start by learning about the basic concepts of a cloud-native application and its advantages over standard enterprise applications. Then we will quickly move on to application development, by installing the tooling required to build our first application on Quarkus. Next, we'll learn how to create a container-native image of our application and execute it in a Platform-as-a-Service environment such as Minishift. Later, we will build a complete real-world application that will use REST and the Contexts and Dependency injection stack with a web frontend. We will also learn how to add database persistence to our application using PostgreSQL. We will learn how to work with various APIs available to Quarkus such as Camel, Eclipse MicroProfile, and Spring DI. Towards the end, we will learn advanced development techniques such as securing applications, application configuration, and working with non-blocking programming models using Vert.x.






By the end of this book, you will be proficient with all the components of Quarkus and develop-blazing fast applications leveraging modern technology infrastructure.




What you will learn



  • Build a native application using Quarkus and GraalVM


  • Secure your applications using Elytron and the MicroProfile JWT extension


  • Manage data persistence with Quarkus using PostgreSQL


  • Use a non-blocking programming model with Quarkus


  • Learn how to get Camel and Infinispan working in native mode


  • Deploy an application in a Kubernetes-native environment using Minishift


  • Discover Reactive Programming with Vert.x



Who this book is for



The book is for Java developers and software architects who are interested in learning a promising microservice architecture for building reliable and robust applications. Knowledge of Java, Spring Framework, and REST APIs is assumed.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 295

Veröffentlichungsjahr: 2019

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Hands-On Cloud-Native Applications with Java and Quarkus

 

Build high performance, Kubernetes-native Java serverless applications

 

 

 

 

 

Francesco Marchioni

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Hands-On Cloud-Native Applications with Java and Quarkus

Copyright © 2019 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

Commissioning Editor: Kunal ChaudhariAcquisition Editor: Alok DhuriContent Development Editor: Pathikrit RoyTechnical Editor: Gaurav GalaCopy Editor: Safis EditingSenior Editor: Rohit SinghProject Coordinator:Francy PuthiryProofreader: Safis EditingIndexer: Priyanka DhadkeProduction Designer: Aparna Bhagat

First published: December 2019

Production reference: 1131219

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-83882-147-0

www.packt.com

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
To my wife Linda, who is happy she married somebody "with no special talent, but who is passionately curious." And I'm so glad to be such.
 

Packt.com

Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Fully searchable for easy access to vital information

Copy and paste, print, and bookmark content

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 

Foreword

I've been involved with Java and enterprise Java since 1995-96 and over the intervening years, I've been impressed by the passion of the developers within communities who find innovative ways to improve their own productivity and that of others. Various significant changes to our industry have occurred and Java has continued to remain relevant. Whether it's service-oriented architecture, RESTful development, Internet of Things, microservices, or hybrid cloud, Java has found a way to ensure that developers can bring much of what they've learned prior to the advent of these waves with them so they don't have to re-invent the wheel.

However, sometimes that wheel does need a bit of shaking up. Not everything that is applicable to one type of deployment environment is necessarily going to be useful to another. And we've seen that with the cloud, Platform-as-a-Service and, specifically, Kubernetes and Linux containers. The Java Virtual Machine (JVM) represents a huge and impressive amount of work by countless developers from several vendors over two decades.

Despite the fact that Java began life aimed at constrained devices, it rapidly evolved into a world where the assumptions are quite different compared to the cloud today, such as, the ability to consume a lot of memory, the requirements to dynamically update the running application/environment, and other runtime optimizations. Concerns about Java (performance, runtime memory footprint, boot time, and so on) have caused some to re-evaluate their investment with Java and consider some of the newer languages, despite the fact that many of those languages don’t yet have the rich ecosystem of tools, utilities, and so on that have been built up over the years by the Java community.

This is where Quarkus comes in! It aims to make Java relevant in the modern Kubernetes world. I've seen frameworks and stacks come and go over the decades, with some of them being massively successful for their time. However, whether it's DCE, CORBA, JBoss, or Spring, I've never seen anything quite like Quarkus in terms of almost instantaneous popularity, the ability to capture the imagination of people, being able to mine a deep-rooted need for Java developers, and to create a new wave: true Kubernetes-native Java middleware.

And I try to say that objectively, given that I've been involved with Quarkus since the very beginning. As you're about to find out when you read this book, it truly feels like "a paradigm shift." It enables developers to bring their Java skills to Kubernetes and feel like they can be as (or more) productive as developers using other languages and even other Java frameworks/stacks.

I'm really pleased to see this book coming out so quickly on the back of the initial Quarkus release and thus filling an important need for existing Quarkus developers and those thinking about trying it out. The fact the author works within Red Hat JBoss Middleware, from where Quarkus originated, and specifically in our QE group, gives a unique view that readers interested in learning about Quarkus and developers interested in using it can both enjoy and benefit from. I hope you find it as interesting to read the book as I did!

 

 

Mark Little

Red Hat's Vice President, Middleware Engineering

Contributors

About the author

Francesco Marchioni is a Red Hat Certified JBoss Administrator (RHCJA) and Sun Certified Enterprise Architect (SCEA) working at Red Hat in Rome, Italy. He started learning Java in 1997, and since then he has followed all the newest application program interfaces released by Sun. In 2000, he joined the JBoss community, when the application server was running the 2.X release.

He has spent years as a software consultant, where he has enabled many successful software migrations from vendor platforms to open source products, such as JBoss AS, fulfilling the tight budget requirements necessitated by the current economy. Over the last 10 years, he has authored many technical articles for O'Reilly Media and has run an IT portal focused on JBoss products. 

I have a long list of people that I'd like to thank for their contribution in writing this book. I'd like to thank, in strict random order, Clement Escoffier, Guillaume Smet, Georgios Andrianakis for their valuable hints that made my journey through Quarkus Land smooth and safe. Many thanks to Mark Little for writing the incipit of this book. Also, last but not least, a huge thanks to the reviewers and proofreaders of this book, Alessio Soldano, Guillame Smet, Max Andersen, and Nicola Ferraro.

 

About the reviewers

Nicola Ferraro is a passionate software developer contributing to many open source projects. He is a committer and a PMC member of Apache Camel as well as a co-creator of the Camel K serverless integration platform, which leverages the power of Quarkus. He works as a collaborator for the Knative project. He is also developing Syndesis, a no-code integration platform, and the Fabric8 development tools for Kubernetes. Nicola currently works as a principal software engineer for Red Hat.

I would have never finished the review of this book without the help of my beloved son, Alessandro, who kept me out of bed for so many nights. Love you!

 

 

Alessio Soldano was born in Varese, Italy, in 1979. He started his career working on distributed systems in the financial/credit field and fell in love with JBoss. After years of J2EE practice, he finally got the chance to deal with web services. He contributed to the JBoss Web Services project by finding and fixing some bugs and eventually was hired by JBoss (a division of Red Hat) to continue doing that. Later on, Alessio took on project leadership, represented Red Hat at JCP (JSR 224) and W3C (Web Services Resource Access Working Group), and contributed to multiple JBoss and Apache projects. More recently, he has shifted his attention to the REST world; he's been leading RESTEasy for a few years and because of that he's also involved in Quarkus.

 

 

 

 

 

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Hands-On Cloud-Native Applications with Java and Quarkus

Dedication

About Packt

Why subscribe?

Foreword

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Code in Action

Conventions used

Get in touch

Reviews

Section 1: Getting Started with Quarkus

Introduction to Quarkus Core Concepts

Technical requirements

From the big data hype to Kubernetes

The Kubernetes architecture in a nutshell

Benefits of using Kubernetes

From Java EE to MicroProfile

The Twelve-Factor App methodology

The MicroProfile initiative

Quarkus – a Kubernetes-native Java framework

Native code execution

Container first

Unifying the imperative and Reactive Programming models

Coding that sparks joy

Best-of-breed Java libraries and standards

Quarkus architecture

Getting started with GraalVM

Installing GraalVM

Running a Java application with GraalVM

Building native images

Installing a development environment

A brief overview of IntelliJ IDEA

Installing IntelliJ Plugin for Quarkus

Summary

Developing Your First Application with Quarkus

Technical requirements

Getting started with the Quarkus Maven plugin

Launching the Quarkus Maven plugin

Running the application

Using the Maven plugin to generate a Gradle project

Kick-starting applications using the Quarkus online application

Testing live reload from your IDE

Debugging applications

Testing Quarkus applications

Choosing a different port for testing

Turning your application into a native executable

Executing integration tests against the native executable

Summary

Creating a Container Image of Your Application

Technical requirements

Setting up Docker

Running Quarkus applications in a container

Running the native executable process in a container

Deploying Quarkus applications on a Kubernetes-native platform

Installing Minishift

Building and deploying a Quarkus application on OKD

Scaling our Quarkus service

Summary

Section 2: Building Applications with Quarkus

Adding Web Interfaces to Quarkus Services

Technical requirements

Adding web content to Quarkus applications

Building a CRUD application

Adding a UI to our customer service

Testing our application

Running the example

Running our application on Minishift

Configuring Cross-Origin Resource Sharing in Quarkus

Adding Enterprise web components

Introducing WebSockets

Building a project that uses Websockets

Creating a WebSocket client project

Adding an AJAX handler

Summary

Managing Data Persistence with Quarkus

Technical requirements

Adding an ORM layer to our applications

Defining the entity layer

Coding the repository classes

Defining REST endpoints

Connecting to the database

Coding a test class

Adding a web interface to our application

Running the application

Caching entity data

Taking an application to the cloud

Making data persistence easier using Panache API

Summary

Building Applications Using the MicroProfile API

Technical requirements

Getting started with the MicroProfile API

Getting started with MicroProfile projects

The Eclipse MicroProfile Health Check

Using liveness and readiness checks

Letting OpenShift manage unhealthy services

The Eclipse MicroProfile Fault Tolerance API

Using Timeout, Fallback, and Retry to create resilient services

Applying a retry policy to your failures

Circuit Breaker

Using asynchronous and bulkhead policies

The Eclipse MicroProfile Metrics API

Configuring OpenAPI and the Swagger UI

Customizing the output of OpenAPI

The Eclipse MicroProfile OpenTracing API

The Eclipse MicroProfile REST Client API

Summary

Securing Applications

Technical requirements

Securing our customer service

Securing Quarkus services with Elytron

Creating a test class that performs basic authentication

Securing Quarkus services with Keycloak

Adding a Keycloak extension to our service

Setting up Keycloak

Defining the security realm

Configuring Quarkus for Keycloak

Coding the test class

Gathering principal and role information at runtime

Securing Quarkus services with MicroProfile JWT

Configuring our service to use JWT

Running our test

Injecting JWT claims and token information

Using HTTPS with Quarkus

Summary

Section 3: Advanced Development Tactics

Advanced Application Development

Technical requirements

Using advanced configuration options

Multiple configuration sources

Configuring custom configuration sources

Using converters in your configuration

Adding custom converters

Testing advanced configuration options

Configuration profiles

Activating profiles

Automatic profile selection

Controlling the application life cycle

Activating a database test resource

Firing events with the Quarkus scheduler

Using the cron scheduler format

Firing one-time events

Summary

Unifying Imperative and Reactive with Vert.x

Technical requirements

Demystifying Reactive Programming and Vert.x

Vert.x API models in Quarkus

Managing the Vert.x core API

Managing Vert.x API for RxJava

Using RxJava with Quarkus

Decoupling events with Vert.x axle libraries

Adding an EventBus layer to Quarkus applications

Rolling up the application

Streaming SSE with Vert.x

Canceling events

Managing the Reactive SQL Client

Configuring your application to use the PostgreSQL reactive client

Running the example

Summary

Reactive Messaging with Quarkus

Technical requirements

Getting started with Reactive Messaging

Streaming messages with Apache Kafka

Composing our stock trading application

Coding bean classes

Streaming messages to Kafka in the cloud

Installing Kafka on OpenShift

Shaping up our project for native cloud execution

Streaming messages with AMQP

Configuring the AMQP broker

Streaming messages to AMQ in the cloud

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

Despite its age, Java still remains one of the most popular choices among developers, having made it through almost 20 years of constant improvements and having developed a full stack of libraries for enterprise systems. As we are living in a fast-paced industry, we cannot deny that many things have changed in the last few years with the introduction of containers, microservices, reactive applications, and cloud platforms. To remain a first-class citizen in this changing world, Java needs a boost. And we, at Red Hat, believe that this boost can be Quarkus!

Quarkus has been designed from the ground up to be a Kubernetes-native Java framework that is a perfect fit for creating microservice applications with a minimal memory footprint and fast execution. At the same time, Quarkus does not dump the rich set of libraries, such as Hibernate, and REST services that most developers are familiar with. On the contrary, they are part of a larger picture that includes the game-changing MicroProfile API, reactive programming models such as Vert.x, and a ton of other features that can be easily plugged into your services.

Quarkus provides an effective solution for running Java in this new world of serverless, microservices, containers, Kubernetes, Function as a Service (FaaS), and the cloud because it has been designed with these in mind. Its container-first approach to cloud-native Java applications unifies imperative and reactive programming paradigms for microservices development and offers an extensible set of standards-based enterprise Java libraries and frameworks combined with extreme developer productivity that promises to revolutionize the way we develop in Java.

Who this book is for

This book is for Java developers and software architects who are interested in learning about a very promising microservice architecture for building reliable and robust applications. Some knowledge of Java, Spring, and REST APIs is assumed.

What this book covers

Chapter 1, Introduction to Quarkus Core Concepts, explains the container-first (minimal-footprint Java applications are optimal for running in containers), cloud-native (Quarkus embraces the 12-factor architecture of environments such as Kubernetes), and microservice-first (Quarkus brings lightning-fast start up times and code turnaround times to Java apps) approaches. We will examine the various tools available for developing Quarkus applications. For this, we will install an IDE and GraalVM, which is required for native applications.

Chapter 2, Developing Your First Application with Quarkus, takes you through building your first application with Quarkus. We will see how to use Maven/Gradle plugins to bootstrap your application. You will learn how to import the application in your IDS, and how to run and test the application. Next, we will discuss creating a native application from your Java project.

Chapter 3, Creating a Container Image of Your Application, looks at how to build a Docker image of your application, how to run an application on Docker, how to install a single-node cluster of OpenShift, and how to run an application on Minishift.

Chapter 4, Web Application Development, looks at the use case of a customer store application that will use REST and the CDI stack and a web frontend. We will see how to deploy the application and see changes without restarting Quarkus.

Chapter 5, Managing Data Persistence with Quarkus,discusses data persistence with Quarkus. We will see how to add persistence to the customer store example as well as setting up a database (PostgreSQL) to run the example. We will then take the application to the cloud. Finally, we will show you how Hibernate Panache can simplify application development.

Chapter 6, Building Applications Using the MicroProfile API, teaches you how to complement the Enterprise API that we have already discussed with the full stack of Eclipse MicroProfile specifications (https://microprofile.io/).

Chapter 7, Securing Applications, will explore how to secure our example application with built-in security APIs such as the Elytron Security stack, the Keycloak extension, and the MicroProfile JWT extension.

Chapter 8, Advanced Application Development, gets into advanced application development techniques such as advanced application configuration management, life cycle events, and firing scheduled tasks.

Chapter 9, Unifying Imperative and Reactive, takes you through the non-blocking programming model with Quarkus and an example application using the Vert.x programming model with Quarkus. We will also explore how to leverage Vert.x's reactive SQL API to build non-blocking database applications.

Chapter 10, Reactive Messaging with Quarkus,explains how to implement reactive data streaming applications using a CDI development model and Kafka and AMQP as a broker. We will also explain how to implement a full streaming architecture in the cloud by deploying our application on OpenShift.

To get the most out of this book

Hands-On Cloud-Native Applications with Java and Quarkus is a complete end-to-end development guide that will give you hands-on experience with building Kubernetes-native applications in serverless environments. To get the most out of this book, we recommend using a development environment that is integrated with Apache Maven (such as IntelliJ IDEA or Eclipse) and import it into our example code files. That will help you to follow our projects step-by-step and, when needed, to debug them.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

Log in or register at

www.packt.com

.

Select the

Support

tab.

Click on

Code Downloads

.

Enter the name of the book in the

Search

box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR/7-Zip for Windows

Zipeg/iZip/UnRarX for Mac

7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Cloud-Native-Applications-with-Java-and-Quarkus. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781838821470_ColorImages.pdf.

Code in Action

Please visit the following link to see the Code in Action videos: http://bit.ly/2LKFbY1

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

Section 1: Getting Started with Quarkus

In this section, we will learn about the foundations of the Quarkus architecture, install the tools we need to develop applications, and develop our first cloud-native application.

This section includes the following chapters:

Chapter 1

Introduction to Quarkus Core Concepts

Chapter 2

Developing Your First Application with Quarkus

Chapter 3

Creating a Container Image of Your Application

Introduction to Quarkus Core Concepts

Java was introduced to the open source community over 20 years ago. Since then, we cannot think of a single large IT company or organization that doesn't use Java. For this reason, Java is often regarded as a corporate language, which is not a bad thing per se: Java is the enterprise standard, and it's an extremely mature language with a huge ecosystem of tools and libraries around it and still the most used language by developers in the world.

20 years in the IT industry is, however, a considerable amount of time. Since the beginning, Java has gone through a long list of optimizations with the burden of keeping backward compatibility with earlier releases. Today, however, the IT landscape has significantly changed with the rise of new standards such as the cloud, containers, microservices, and Reactive Programming. Do we still need to use Java to address the latest application architectures and reach a higher level of productivity and efficiency? Yes! This book promises to do this while teaching you about Quarkus, a Kubernetes-native framework that will take supersonic, subatomic Java to new heights!

In the first part of this book, we will learn how to create Quarkus applications with simple tools while using a development environment to code, execute, and debug them. After completing all the green bars, we will concentrate on advanced topics to show you how to combine multiple Quarkus extensions to produce a serverless infrastructure.

As far as this chapter is concerned, we will have a quick tour of the Quarkus technology by covering these topics:

An overview of the IT landscape, showing the benefits of cloud-native applications and microservices

The basics of the Quarkus architecture

Installing the required software (GraalVM to compile code natively and a development environment)

Technical requirements

You can find the source code for the project in this chapter on GitHub at https://github.com/PacktPublishing/Hands-On-Cloud-Native-Applications-with-Java-and-Quarkus/tree/master/Chapter01.

From the big data hype to Kubernetes

About 10 years ago, the biggest buzz in the IT industry was the term big data. Every major enterprise was racing to harness the mystical powers of massive, yet supposedly manageable, silos of data. Equipped with big data, no problem would prove insurmountable, and all forecasts would be met.

But lately, these forecasts appear to have faded, and the worst-kept secret in the IT industry is that big data is dead – at least as we knew it. This doesn't mean that the volume or growth of data has broken down – or the opposite. It's just the underlying technology that has changed, which means that the architectures of applications that use big data have too.

Take Hadoop as an example, which has been the icon of the big data hype. It was designed based on a set of assumptions that dramatically changed in a short time. One of these assumptions was that, in order to process a large batch of data, network latency was the evil and cloud-native storage simply wasn't an option. At that time, most of the IT industry data was on-premise, so the focus was on avoiding moving around big sets of information. This meant that data was to be co-located in order to compute it efficiently.

Today, this scenario has changed quite a bit: most applications still use large amounts of data, but data is now processed on the fly. That is to say, we now stream data instead of processing the whole dataset multiple times.

Besides this, the network latency barrier has become less of an issue for cloud providers and there are even multiple cloud sources to choose from. Also, companies now have the option to deploy their own private cloud on-premise, leading to new scenarios such as hybrid clouds.

Therefore, the focus is what really changed: today, big data does not merely mean a big quantity of datasets but flexible storage options for a big quantity of data.

This is where containers and, specifically, Kubernetes fits in. In a nutshell, you can think of a container as a packaged application that contains just the libraries that are needed to run it, and Kubernetes is like an orchestrating system that makes sure all the containers have the appropriate resources while managing their life cycle.

Kubernetes runs images and manages containers using Docker. However, Kubernetes can use other engines too (for example, rkt). Since we will be building our applications on top of Kubernetes, we will provide a short overview of its architecture in the next section.

The Kubernetes architecture in a nutshell

The architecture of Kubernetes is focused around the concept of a loosely coupled, flexible mechanism for service discovery. Like most other distributed middleware platforms, a Kubernetes cluster is composed of one or more master nodes and multiple compute nodes. The following diagram depicts a high-level view of a Kubernetes cluster:

Kubernetes Master nodes essentially make up the brain of the cluster. They are responsible for managing the overall cluster, exposing APIs, and scheduling deployments. Kubernetes nodes (right-hand side of the preceding diagram) contain the services that are needed to run applications in components called Pods.

Each master node contains the following components:

API Server

: This synchronizes and validates the information running in Pods and services.

etcd

: This provides consistent and highly available storage for the cluster data.

You can think of

etcd

as the brain's shared memory.

Controller Manager server

: This checks for changes in the

etcd

service and uses its API to enforce the desired state.

HAProxy

: This can be added when we're configuring HA masters to balance loads between several master endpoints.

Kubernetes nodes (simply called nodes) can be considered workhorses of a Kubernetes cluster. Each node exposes a set of resources (such as computing, networking, and storage) to your applications. The node also ships with additional components for service discovery, monitoring, logging, and optional add-ons. In terms of infrastructure, you can run a node as a virtual machine (VM) in your cloud environment or on top of bare-metal servers running in the data center.

Each node contains the following components:

Pod

: This allows us to logically group containers and pieces of our application stacks together. A Pod acts as the logical boundary for such containers with shared resources and contexts. Pods can be scaled at runtime by creating Replica sets. This, in turn, ensures that the required number of Pods is always run by the deployment.

Kubelet

: This is an agent that runs on each node in the Kubernetes cluster. It makes sure that the containers are running in a Pod.

Kube-Proxy

: This maintains network rules on nodes to allow network communication between Pods.

Container Runtime

: This is the software that is responsible for running containers. Kubernetes supports multiple container runtimes (such as Docker,

containerd

,

cri-o

, and 

rktlet

).

Now that we've covered the basics of the Kubernetes architecture, let's look at the top advantages that it can bring to your organization.

Benefits of using Kubernetes

The advantages that Kubernetes can bring to your organization are as follows:

Kubernetes greatly simplifies container management. As you have learned, when using Kubernetes, there's no need to manage containers directly. Instead, you just to have manage Pods. In order to have your applications available in your Pods, Kubernetes introduced an abstraction called a 

service

. It defines a logical set of Pods with their IP address. This level of abstraction enhances fault tolerance and reduces downtime by launching containers on different machines.

Kubernetes speeds up the process of building, testing, and releasing software by supporting a wide range of programming languages (Java, Go, Python, and so on) and offering advanced deployment features (automated rollouts and rollbacks, canary deployments, and more). This makes it a lot easier to configure effective

Continuous Integration/Continuous Delivery

(

CI/CD

) pipelines for your software.

Kubernetes provides the fastest and least costly horizontal scalability for your pods, so when the number of users for your application increases, you can configure the replication service to fire new Pods and balance the load across them to avoid downtime.

It's worth mentioning that Kubernetes is able to manage both stateless and stateful applications, because it allows ephemeral storage and persistent volumes. It also supports a number of storage types, such as NFS, GlusterFS, and cloud storage systems. Furthermore, a

persistent volume

 (

PV

) life cycle doesn't depend on any pod using it, so you can keep the data as long as you need it.

The benefits of using Kubernetes as a service orchestrator in your industry are clearly evident, but the next question is, how do we write our services to get the most out of this architecture? Can we still write our applications using the same standards we have learned about in the last few years? The next section will address this dilemma.

From Java EE to MicroProfile

Java Enterprise Edition (EE) has reached an outstanding level of maturity and has a huge adoption in the IT Enterprise. A Java EE application is typically packaged as a monolithic application and deployed in an application server, which can host multiples of them.

A monolithic application can be thought of as a self-contained application that includes both the user interface and the business components that are required to run the applications.

This approach has been widely used for years. The reason is simple: monolithic applications are conceptually simple to develop and package because everything is contained in a bundle and can be edited with a single IDE. Also, scaling monolithic applications is simple: all you need to do is scale a single component.

As a result, the traditional way of coding enterprise applications produced an extremely large set of applications that were supposed to be available as long-running processes and needed an application server to manage their High Availability (HA). In turn, some other tooling was needed to manage server restarts in the case of failures and to check the overall health of the system.

As server-based monolithic applications continued growing, several disadvantages became evident, as follows:

Difficult to maintain

: This is due to the size of the applications, which makes it complex to create a patch for them.

Limited scalability

: You can scale the whole application, not the single services.

Longer release cycles

: Any changes that are made to the code require that we deploy the whole application, which complicates things when multiple teams are working on the same application.

Less isolation