Professional Documents
Culture Documents
Beginning Cloud Native Development With Microprofile Jakarta Ee and Kubernetes 1St Edition Tarun Telang Full Chapter
Beginning Cloud Native Development With Microprofile Jakarta Ee and Kubernetes 1St Edition Tarun Telang Full Chapter
This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
Conventions
Throughout the book, I use a consistent style for presenting Java code,
SQL, command-line text, and results. When pieces of code, SQL,
reserved words, or code fragments are presented in the text, they are
presented in fixed-width Courier font, such as this (working) example:
Note The sources for this book may change over time, in order to
incorporate the most up-to-date features in Jakarta EE, MicroProfile,
and the Kubernetes platform. If you find any issues in the sources,
please submit them via the book’s GitHub repo and the code will be
adjusted accordingly.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub
(https://github.com/Apress). For more detailed information, please
visit http://www.apress.com/source-code.
Acknowledgments
I would like to thank my wife, Nikita, and son, Vihan, for their patience
and love throughout the process of writing this book. I am indebted to
all my mentors and friends who encouraged me to keep on growing
during every phase of my professional career.
I’d like to thank my parents for pushing me in the right direction
with technology and always supporting me every step of the way, even
when I decided to do something completely different than they
expected. It’s also important to note that without them, I probably
wouldn’t have become a developer and had such a great career. Lastly,
thanks again go out to my wife (and soulmate), Nikita. It’s an incredible
feeling to be with someone who keeps you motivated and challenges
you, not only professionally but personally.
Thank you for always being there for me!
I’d like to send a special thanks to Pramit Das and Massimo Nardone
(technical reviewers), for their impeccable work on this book. I also
greatly appreciate Steve Anglin, Mark Powers, and everyone at Apress
Media (apress.com) for their support in getting this book published.
Last, but not least, I would like to thank you, the reader, for taking
the time to read this book. I hope that it will help you in your journey of
becoming a better Jakarta EE developer.
Table of Contents
Chapter 1:Introduction to Cloud Computing
Introduction to Cloud Computing
Examples of Cloud Computing
Benefits of Cloud Computing
Essential Characteristics of Cloud Computing
Types of Cloud Computing Based on Deployment Models
Public Cloud
Community Cloud
Private Cloud
Hybrid Cloud
Service Models of Cloud Computing
Software as a Service (SaaS)
Platform as a Service (PaaS)
Infrastructure as a Service (IaaS)
The Role of Java in Cloud Computing
The Evolution of Cloud Computing
Summary
Chapter 2:Cloud-Native Application Development
What Is Cloud-Native?
Characteristics of Cloud-Native Applications
Examples of Cloud-Native Applications
Benefits of Cloud-Native Applications
Drawbacks of Using Cloud-Native Applications
Cloud-Native Applications vs.Traditional Applications
Cloud-Native Application Development
Managed Services for Java-Based Applications
Examples of Cloud-Native Application Development
Cloud-Native Application Development Is the Future
Phases of Cloud-Native Application Development
Summary
Chapter 3:Setting Up Your Development Environment
Prerequisites
Hardware Requirements
Installing Java Development Kit (JDK)
Using Maven
Installing Maven
Git
Installing Git
Creating a GitHub Account
Creating a GitHub Repository
Pushing Code to a GitHub Repository
Using Docker
Benefits of Using Docker
Installing Docker
Docker Hub
Using Kubernetes
Installing Kubernetes
Configuring Docker for Kubernetes
Creating a Kubernetes Cluster
Using Zipkin
Installing Zipkin
Integrated Development Environments (IDE)
Summary
Chapter 4:Building RESTful Web Services
REST:An Architectural Style for Building Web Services
Introduction to Open Liberty Runtime
Key Features of the Open Liberty Application Server
Downloading and Installing Open Liberty
Starting the Open Liberty Server
Printing a List of Features on the Open Liberty Server
Creating a Server Instance
Stopping the Open Liberty Server
Configuring the Server
Creating a RESTful Web Service in Open Liberty
Creating a RESTful API
Summary
Chapter 5:Microservices Architecture
Vertical Scaling
Horizontal Scaling
Vertical vs.Horizontal Scaling
History of Service-Based Architecture
Types of Service-Based Architectures
Service-Oriented Architecture (SOA)
What Is a Web Service?
What Is SOAP?
What Is REST?
REST vs.SOAP
The Monolithic Architecture
Evolution of the Microservices Architecture
Benefits of Microservices Architectures
Drawbacks of Microservices Architectures
Design Considerations
Using Microservices in Cloud-Native Applications
Cloud-Native Twelve-Factor Applications
What Is a Virtual Machine?
What Are Containers?
What Are Container-Based Applications?
What Are Serverless Applications?
Where Is Serverless Computing Used?
Benefits of Serverless Computing
Drawbacks of Serverless Computing
Popular Serverless Platforms
Main Components of a Serverless Computing Platform
Serverless Applications vs.Containers
Microservice Deployment Patterns
Key Considerations
Microservices Deployment Strategies and Patterns
Microservices Management
Summary
Chapter 6:The Eclipse MicroProfile Framework
What Is the Eclipse MicroProfile Framework?
Layers of Functionality in MicroProfile
Popular Implementations of the Eclipse MicroProfile
Framework
MicroProfile Config
The MicroProfile Health Check Specification
The MicroProfile Fault Tolerance Component
Key Features of the Fault Tolerance Component
Fault Tolerance API
Summary
Chapter 7:MicroProfile Framework – Part 2
The MicroProfile Metrics Specification
Types of Metrics
Metrics Components
Metrics Annotations
Maven Dependency
Tracking Response Time Using @Timed
Tracking the Number of Invocations
Tracking Memory Usage
MetricRegistry
Creating Custom Metrics
Using Open Tracing
Distributed Tracing
How Does It Work?
Using the Jakarta RESTful Web Service
Using the MicroProfile OpenAPI Specification
OpenAPI
Capabilities of the MicroProfile OpenAPI Specification
Generating OpenAPI Documents
Using the MicroProfile OpenAPI in Your Project
MicroProfile OpenAPI Annotations
Summary
Chapter 8:MicroProfile JSON Web Tokens and Jakarta Security
Security Best Practices for Microservices
What Is a JSON Web Token (JWT)?
Use Cases for JSON Web Tokens
Authentication
Authorization
Session Information
Claims-Based Identity
Information Exchange
Federation
Creating and Signing a JWT
Testing the Application
Verifying and Validating a JWT
Using JWT in a Microservice Environment
Securing a RESTful Application
Securing a REST Resource
The @RolesAllowed Annotation
The @Claim Annotation
The @HeaderParam Annotation
Configuring a JWK Set or PEM-Encoded Public Key
Public Key Cryptography Standards #8 in PEM Format
JSON Web Key (JWK)
JSON Web Key Set (JWKS)
The Jakarta EE Security Specification
Securing a Servlet Using Jakarta Security
The MicroProfile REST Client
The @RegisterClient Annotation
Configuring Your REST Client
REST Client Interface
Documenting RESTful APIs Using MicroProfile OpenAPI
What Is the OpenAPI Specification?
What Is MicroProfile OpenAPI?
Summary
Chapter 9:Containerizing Microservices Using Kubernetes
What Are Containers?
Why Use Containers?
What Is Container Orchestration?
The Benefits of Using Container Orchestration
Understanding Kubernetes Terminology
The Key Features of Kubernetes
Using Kubernetes
Using Docker Containers
Running a MicroProfile Application in Docker
Pushing the Docker Image to Docker Hub
Scaling Your Deployment
Summary
Appendix A:Introduction to Maven
Appendix B:Creating an Open Liberty Project Using Maven
Appendix C:Installing Open Liberty Tools
Index
About the Author
Tarun Telang
is a hands-on technologist with extensive
experience in the design and
implementation of multitiered, highly
scalable software applications. He has
been part of several well-known
companies, including Microsoft, Oracle,
Polycom, and SAP. He has over 17 years
of experience in architecting and
developing business applications.
He began his career as an enterprise
Java developer at SAP, where he
developed distributed application
software for big firms. He got his start
with enterprise session beans and
message-driven beans, as well as instrumenting enterprise
applications’ configuration and management using the Java
Management Extensions (JMX) technology.
He quickly mastered various enterprise technologies, including the
Enterprise Beans, Java Management Extensions, Servlets, and Server
Pages technologies, and in his first year as a developer, he became a Sun
Certified Programmer for the Java Platform, Standard Edition 6, and an
SAP Certified Development Consultant for the SAP NetWeaver Java Web
Application Server (which was a Java EE 5-compliant application
server).
He also gained expertise in XML technologies like XSLT and XSD. He
developed several solutions using session beans and message-driven
beans to handle message-oriented communications across numerous
systems. In 2007, Tarun was named an SAP Mentor and Community
Influencer for his articles and blog posts on emerging technologies and
for promoting innovative solutions in the SAP Developer Community.
He frequently writes articles on Java and related technologies. Tarun
has also authored multiple online courses, including a best-selling
course on the YAML data serialization language.
He has presented technical lectures at several developer
conferences, including SAP TechEd and the Great Indian Developer
Summit. He has been presenting at conferences for more than 15 years
and actively publishes technical papers and blogs to assist everyone in
grasping the fundamentals of software technology. Tarun developed
cloud-based video conferencing applications using a microservices
architecture with the Spring framework and has experience working
with Persistence APIs and the Hazelcast framework for building REST-
based services.
He also developed many end-to-end cloud-based solutions using
various architectural patterns, including microservices and service-
oriented architectures. Tarun has gained expertise in web, mobile, and
cloud technologies. He is also knowledgeable in applied agile
methodologies, including user-centric and mobile-first design for
managing projects with cross-functional teams located in multiple
geographies. Tarun is the co-author of Java EE to Jakarta EE 10 Recipes:
A Problem-Solution Approach for Enterprise Java (Apress, 2022).
Having previously worked in Canada and Germany, Tarun currently
resides in Hyderabad, India with his wife and son. You can follow him
on LinkedIn ( www.linkedin.com/in/taruntelang/ ), Facebook
( www.facebook.com/tarun.telang ), and Twitter
(@taruntelang). His blog at https://blogs.taruntelang.me
is an excellent resource for all things related to software technology!
About the Technical Reviewers
Massimo Nardone
has more than 25 years of experience in
security, web/mobile development,
cloud, and IT architecture. His true IT
passions are security and Android. He
has been programming and teaching
others how to program with Android,
Perl, PHP, Java, VB, Python, C/C++, and
MySQL for more than 20 years. He holds
a Master of Science degree in computing
science from the University of Salerno,
Italy.
He has worked as a CISO, CSO,
security executive, IoT executive, project
manager, software engineer, research
engineer, chief security architect,
PCI/SCADA auditor, and senior lead IT security/cloud/SCADA architect
for many years. His technical skills include security, Android, cloud,
Java, MySQL, Drupal, Cobol, Perl, web and mobile development,
MongoDB, D3, Joomla, Couchbase, C/C++, WebGL, Python, Pro Rails,
Django CMS, Jekyll, Scratch, and more.
He was a visiting lecturer and supervisor for exercises at the
Networking Laboratory of the Helsinki University of Technology (Aalto
University). He also holds four international patents (in the PKI, SIP,
SAML, and Proxy areas). He is currently working for Cognizant as head
of cybersecurity and CISO to help clients in areas of information and
cybersecurity, including strategy, planning, processes, policies,
procedures, governance, awareness, and so forth. In June, 2017, he
became a permanent member of the ISACA Finland Board.
Massimo has reviewed more than 45 IT books for different
publishing companies and is the co-author of Pro Spring Security:
Securing Spring Framework 5 and Boot 2-based Java Applications
(Apress, 2019), Beginning EJB in Java EE 8 (Apress, 2018), Pro JPA 2 in
Java EE 8 (Apress, 2018), and Pro Android Games (Apress, 2015)
Pramit Das
has more than 12 years of experience in
software design and development across
multiple platforms using various
technology stacks. He is extremely
passionate about programming and
exploring new and upcoming
technologies. He has extensive hands-on
experience with programming languages
like C/C++, Java, Scala, JavaScript, and
Python, along with their respective tools,
libraries, and frameworks, including
Spring, Django, NodeJs, and Spark. He
also has excellent knowledge of backend
storage solutions from Oracle, MySQL,
MongoDB, and Cassandra, as well as
other cloud-based managed services.
Academically, Pramit received his Bachelor’s of Technology from
NIT, Rourkela in Computer Science & Engineering, graduating in 2009.
He has experience in product- and service-based industries and is
currently working for the cloud giant Salesforce as a full-time engineer.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2023
T. Telang, Beginning Cloud Native Development with MicroProfile, Jakarta EE, and
Kubernetes
https://doi.org/10.1007/978-1-4842-8832-0_1
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.