Hands-On Cloud-Native Applications with Java and Quarkus
eBook - ePub

Hands-On Cloud-Native Applications with Java and Quarkus

Build high performance, Kubernetes-native Java serverless applications

Francesco Marchioni

Share book
  1. 314 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Cloud-Native Applications with Java and Quarkus

Build high performance, Kubernetes-native Java serverless applications

Francesco Marchioni

Book details
Book preview
Table of contents
Citations

About This Book

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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Hands-On Cloud-Native Applications with Java and Quarkus an online PDF/ePUB?
Yes, you can access Hands-On Cloud-Native Applications with Java and Quarkus by Francesco Marchioni in PDF and/or ePUB format, as well as other popular books in Informatica & Servizi web e API. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9781838828189
Edition
1

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

Table of contents