Leanpub Header

Skip to main content

Playing with Java Microservices on Kubernetes and OpenShift

Playing with Java Microservices on Kubernetes and OpenShift will teach you how to build and design microservices using Java and the Spring platform. You'll learn how to build a microservices architecture with Spring Boot/Cloud, by evolving an application from a sample monolith to an architecture composed of several services.

Free With Membership

With Membership

Free!

$7.99

You pay

$0.00

Author earns

$0.00

Packages

Details
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
289
Pages
53,707Words
About

About

About the Book

Playing with Java Microservices on Kubernetes and OpenShift will teach you how to build and design microservices using Java and the Spring platform.

This book covers topics related to creating Java microservices and deploy them to Kubernetes and OpenShift.

Traditionally, Java developers have been used to developing large, complex monolithic applications. The experience of developing and deploying monoliths has been always slow and painful. This book will help Java developers to quickly get started with the features and the concerns of the microservices architecture. It will introduce Docker, Kubernetes and OpenShift to help them deploying their microservices.

The book is written for Java developers who wants to build microservices using the Spring Boot/Cloud stack and who wants to deploy them to Kubernetes and OpenShift.

You will be guided on how to install the appropriate tools to work properly. For those who are new to Enterprise Development using Spring Boot, you will be introduced to its core principles and main features thru a deep step-by-step tutorial on many components. For experts, this book offers some recipes that illustrate how to split monoliths and implement microservices and deploy them as containers to Kubernetes and OpenShift.

The following are some of the key challenges that we will address in this book:

  • Introducing Spring Boot/Cloud for beginners
  • Splitting a monolith using the Domain Driven Design approach
  • Implementing the cloud & microservices patterns
  • Rethinking the deployment process
  • Introducing containerization, Docker, Kubernetes and OpenShift

By the end of reading this book, you will have practical hands-on experience of building microservices using Spring Boot/Cloud and you will master deploying them as containers to Kubernetes and OpenShift.

Packages

Pick Your Package

All packages include the ebook in the following formats: PDF, EPUB, and Web

The Book

Minimum price

Suggested price$0.00

Free!

    The Book + 1 Hour Training

    Minimum price

    Suggested price$299.99

    This package contains the book with a one hour of live assistance & training using Skype or Zoom or any video chat solution you choose.

    $289.99

      Author

      About the Author

      Nebrass Lamouchi

      Nebrass Lamouchi is a senior software engineer at Microsoft who is addicted to Java and cloud technologies. He is also a former NetBeans Dream Team member. Nebrass was one of the four happy winners of the Oracle Groundbreaker Awards in May, 2019. ?

      He has also been a project leader on the Barbarus Project for the OWASP Foundation since March, 2013.

      He is the author of the books

      Nebrass graduated with an M.Sc Degree in Information Systems Security and a Bachelor’s Degree in Computing Sciences and Management from the Higher Institute of Management of Tunis, Tunisia.

      Over the past night years, he has worked on Java SE/EE projects in many sectors, including business management, petroleum, finance and banking, medical and healthcare, and defense and space. He has developed applications using many frameworks and Java-related technologies, such as native Java EE APIs and third-party frameworks and tools (Spring, Quarkus, Hibernate, Primefaces, JBoss Forge). He has managed and used infrastructure and programming tools such as DBMS, Java EE servers (Glassfish and JBoss), quality and continuous integration/deployment tools (Sonar, Jenkins, and Azure DevOps), and Docker, Kubernetes, and OpenShift.

      Contents

      Table of Contents

      Acknowledgements

      Preface

      1. What this book covers
      2. Part One: The Monolithics Era

      Chapter 1: Introduction to the Monolithic architecture

      1. Introduction to an actual situation
      2. Presenting the context
      3. How to solve these issues ?

      Chapter 2: Coding the Monolithic application

      1. Presenting our domain
      2. Use Case Diagram
      3. Class Diagram
      4. Sequence Diagram
      5. Coding the application
      6. Presenting the technology stack
      7. Java 8
      8. Maven
      9. Spring Boot
      10. NetBeans IDE
      11. Implementing the Boutique
      12. Generating the project skull
      13. Creating the Persistence Layer
      14. Cart
      15. What is a JpaRepository ?
      16. What is Spring Data Query Builder Mecanism?
      17. CartStatus
      18. Address
      19. Category
      20. Customer
      21. Order
      22. OrderItem
      23. Payment
      24. Product
      25. ProductStatus
      26. Review
      27. Creating the Service Layer
      28. Typical Service: CartService
      29. Why I like Constructor Dependency Injection ?
      30. AddressService
      31. CategoryService
      32. CustomerService
      33. OrderItemService
      34. OrderService
      35. PaymentService
      36. Product Service
      37. ReviewService
      38. Creating the Web Layer
      39. Typical RestController: CartResource
      40. CategoryResource
      41. CustomerResource
      42. OrderItemResource
      43. OrderResource
      44. PaymentResource
      45. ProductResource
      46. ReviewResource
      47. Automated API documentation
      48. Maven Dependencies
      49. Java Configuration
      50. Hello World Swagger !

      Chapter 3 : Upgrading the Monolithic application

      1. Refactoring the database

      Chapter 4: Building & Deploying the Monolithic application

      1. Building the monolith
      2. Which package type: WAR vs JAR
      3. Build a JAR
      4. Build WAR if you
      5. Step 1: Adding the Servlet Initializer Class
      6. Step 2: Exclude the embedded container from the WAR
      7. Step 3: Change the package type to war in pom.xml
      8. Step 4: Package your application
      9. Deploying the monolith
      10. Deploying the JAR
      11. Deploying the WAR
      12. Part Two: The Microservices Era

      Chapter 5: Microservices Architecture Pattern

      1. The Monolithic Architecture
      2. What is a Monolithic Architecture ?
      3. Microservices Architecture
      4. What is a Microservices Architecture ?
      5. What is really a Microservice?
      6. Making the Switch

      Chapter 6: Splitting the Monolith: Bombarding the domain

      1. What is Domain-Driven Design ?
      2. Context
      3. Domain
      4. Model
      5. Ubiquitous Language
      6. Strategic Design
      7. Bounded context
      8. Bombarding La Boutique
      9. Codebase
      10. Dependencies and Commons
      11. Entities
      12. Example: Breaking Foreign Key Relationships
      13. Refactoring Databases
      14. Staging the Break
      15. Transactional Boundaries
      16. Try Again Later
      17. Abort the Entire Operation
      18. Distributed Transactions
      19. So What to Do?
      20. Summary

      Chapter 7: Applying DDD to the code

      1. Introduction
      2. Applying Bounded Contexts to Java Packages
      3. The birth of the commons package
      4. The birth of the configuration package
      5. Locating & breaking the BC Relationships
      6. Locating the BC Relationships
      7. Breaking the BC Relationships

      Chapter 8: Meeting the microservices concerns and patterns

      1. Introduction
      2. Cloud Patterns
      3. Service discovery and registration
      4. Externalized configuration
      5. Circuit Breaker
      6. Database per service
      7. API gateway
      8. CQRS
      9. Event sourcing
      10. Log aggregation
      11. Distributed tracing
      12. Audit logging
      13. Application metrics
      14. Health check API
      15. Security between services: Access Token
      16. What’s next?

      Chapter 9: Implementing the patterns

      1. Introduction
      2. Externalized configuration
      3. Step 1: Generating the Config Server project skull
      4. Step 2: Defining the properties of the Config Server
      5. Step 3: Creating a centralized configuration
      6. Step 4: Enabling the Config Server engine
      7. Step 5: Run it !
      8. Step 6: Spring Cloud Config Client
      9. Service Discovery and Registration
      10. Step 1: Generating the Eureka Server project skull
      11. Step 2: Defining the properties of the Eureka Server
      12. Step 3: Creating the main configuration of the Eureka Server
      13. Step 4: Enabling the Eureka Server engine
      14. Step 5: Update the global application.yml of the Config Server
      15. Step 6: Run it !
      16. Step 7: Client Side Load Balancer with Ribbon
      17. Distributed tracing
      18. Step 1: Getting the Zipkin Server
      19. Step 2: Listing the dependencies to add to our microservices
      20. Sleuth
      21. Zipkin Client
      22. Health check API
      23. Circuit Breaker
      24. Step 1: Add the Maven dependency to your project
      25. Step 2: Enable the circuit beaker
      26. Step 3: Apply timeout and fallback method
      27. Step 4: Enable the Hystrix Stream in the Actuator Endpoint
      28. Step 5: Monitoring Circuit Breakers using Hystrix Dashboard
      29. API Gateway
      30. Step 1: Generating the API Gateway project skull
      31. Step 2: Enable the Zuul Capabilities
      32. Step 3: Defining the route rules
      33. Step 4: Enabling API specification on gateway using Swagger2
      34. Step 5: Run it!
      35. Log aggregation and analysis
      36. Step 1: Installing Elasticsearch
      37. Step 2: Installing Kibana
      38. Step 3: Installing & Configuring Logstash
      39. Installing Logstash
      40. Configuring Logstash
      41. Run it !
      42. Step 4: Enabling the Logback features
      43. Adding Logback libraries to our microservices
      44. Adding Logback configuration file to our microservices
      45. Step 5: Adding the Logstash properties to the Config Server
      46. Step 6: Attending the Kibana party
      47. Conclusion

      Chapter 10: Building the standalone microservices

      1. Introduction
      2. Global Architecture Big Picture
      3. Implementing the µServices
      4. Before starting
      5. Step 1: Generating the Commons project skull
      6. Step 2: Moving Code from our monolith
      7. Step 3: Moving Code from our monolith
      8. Step 4: Building the project
      9. The Product Service
      10. Step 1: Generating the Product Service project skull
      11. Step 2: Swagger 2
      12. Step 3: Application Configuration
      13. Step 4: Logback
      14. Step 5: Activating the Circuit Beaker capability
      15. Step 6: Moving Code from our monolith
      16. The Order Service
      17. Step 1: Generating the Order Service project skull
      18. Step 2: Swagger 2
      19. Step 3: Application Configuration
      20. Step 4: Logback
      21. Step 5: Activating the Circuit Beaker capability
      22. Step 6: Moving Code from our monolith
      23. The Customer Service
      24. Step 1: Generating the Customer Service project skull
      25. Step 2: Swagger 2
      26. Step 3: Application Configuration
      27. Step 4: Logback
      28. Step 5: Activating the Circuit Beaker capability
      29. Step 6: Moving Code from our monolith
      30. Conclusion
      31. Part Three: Containers & Cloud Era

      Chapter 11. Getting started with Docker

      1. Introduction to containerization
      2. Introducing Docker
      3. What is Docker ?
      4. Images and containers
      5. Installation and first hands-on
      6. Installation
      7. Run your first container
      8. Docker Architecture
      9. The Docker daemon
      10. The Docker client
      11. Docker registries
      12. Docker objects
      13. Images
      14. Containers
      15. Docker Machine
      16. Why should I use it?
      17. Using Docker on older machines
      18. Provision remote Docker instances
      19. Diving into Docker Containers
      20. Introduction
      21. Your new development environment
      22. Define a container with Dockerfile
      23. Create sample application
      24. Run the app
      25. Share your image
      26. Log in with your Docker ID
      27. Automating the Docker image build
      28. Meeting the Docker Services
      29. Your first docker-compose.yml file
      30. Run your new load-balanced app
      31. Scale the app
      32. Remove the app and the swarm
      33. Containerizing our microservices

      Chapter 12. Getting started with Kubernetes

      1. What is Kubernetes ?
      2. Kubernetes Architecture
      3. Kubernetes Core Concepts
      4. Kubectl
      5. Cluster
      6. Namespace
      7. Label
      8. Annotation
      9. Selector
      10. Pod
      11. ReplicationController
      12. ReplicaSet
      13. Deployment
      14. StatefulSet
      15. DaemonSet
      16. Service
      17. Ingress
      18. Volume
      19. PersistentVolume
      20. PersistentVolumeClaim
      21. StorageClass
      22. Job
      23. CronJob
      24. ConfigMap
      25. Secret
      26. Run Kubernetes locally

      Chapter 13: The Kubernetes style

      1. Discovering the Kubernetes style
      2. Create the ConfigMap
      3. Create the Secret
      4. Deploy PostgreSQL to Kubernetes
      5. What is Spring Cloud Kubernetes
      6. Deploy it to Kubernetes
      7. It works ! Hakuna Matata !
      8. Revisiting our Cloud Patterns after meeting Kubernetes
      9. Service Discovery and Registration
      10. Engaging the Kubernetes-enabled Discovery library
      11. Step 1: Remove the Eureka Client dependency
      12. Step 2: Add the Kubernetes-enabled Discovery library
      13. Step 3: Defining the Kubernetes Service name:
      14. Load Balancing
      15. Server Side Load Balancing
      16. Client Side Load Balancing
      17. Externalized Configuration
      18. Replacing the Config Server by ConfigMaps
      19. Step 1: Removing the Spring Cloud Config footprints
      20. Step 2: Adding the Maven Dependencies
      21. Step 3: Creating ConfigMaps based on the Application properties files
      22. Step 4: Authorizing the ServiceAccount access to ConfigMaps
      23. Step 5: Boosting Spring Cloud Kubernetes Config
      24. Log aggregation
      25. Step 1: Prepare the Minikube
      26. Step 2: Install EFK using Helm
      27. Step 2.1: Prepare Helm
      28. Step 2.2: Add the Chart repository
      29. Step 3: Installing the Elasticsearch Operator
      30. Step 4: Installing the EFK Stack using Helm
      31. Step 5: Remove the broadcasting appenders
      32. Health check API
      33. API Gateway
      34. Step 1: Delete the old ApiGateway microservice
      35. Step 2: Create the ApiGateway Ingress
      36. Distributed Tracing
      37. Step 1: Deploy Zipkin to Kubernetes
      38. Step 2: Forward Sleth traces to Zipkin

      Chapter 14: Getting started with OpenShift

      1. Introduction
      2. What is really OpenShift ?
      3. Run OpenShift locally
      4. Free OpenShift cluster
      5. What is the difference between OpenShift & Kubernetes
      6. The OpenShift Web Console
      7. Integrated Container Registry & ImageStreams
      8. Native CI/CD factory
      9. Logging and monitoring
      10. Version Control Integration
      11. Security
      12. What is changing in OpenShift?
      13. Common Kubernetes and OpenShift resources
      14. OpenShift specific resources

      Chapter 15: The Openshift style

      1. Introduction
      2. What is the OpenShift style?
      3. Route instead of Ingress
      4. Building applications
      5. Continuous Integration & Deployment
      6. OpenShift Pipelines
      7. OpenShift Jenkins Client Plug-in
      8. OpenShift DSL
      9. Jenkins Pipeline Strategy
      10. Jenkinsfile
      11. Jenkins
      12. Using the Jenkins Kubernetes Plug-in to Run Jobs
      13. OpenShift Container Platform Pipeline Plug-in
      14. OpenShift Container Platform Client Plug-in
      15. OpenShift Container Platform Sync Plug-in
      16. Conclusion
      17. Does it worth to move from OpenShift ?
      18. When do I need OpenShift ?
      19. Is OpenShift really matters ?
      20. Can I do the job using Kubernetes ?
      21. Part four: Conclusion

      Chapter 16: Conclusion

      1. Development
      2. Fabric8 Maven Plugin
      3. Deployment
      4. End of the End
      5. Part five: Bonus Chapters

      Service Mesh

      1. Introduction
      2. What is a Service Mesh ?
      3. Why do we need Service Mesh ?
      4. Conclusion

      Bonus 1: Service Mesh: Istio

      1. What is Istio?
      2. Istio Architecture
      3. Istio Components
      4. Envoy
      5. Mixer
      6. Pilot
      7. Citadel
      8. Galley
      9. Getting started with Istio
      10. Requirements
      11. Get & Install Istio
      12. Envoy Sidecar Injection
      13. Automatic Sidecar Injection
      14. Manual Sidecar Injection
      15. Traffic Management
      16. Istio Gateway & VirtualService
      17. Destination Rules
      18. Observability
      19. Distributed Tracing
      20. Hello Jaeger
      21. Trace sampling
      22. Grafana
      23. Prometheus
      24. Service Graph
      25. Conclusion

      Bonus 2: Service Mesh: Linkerd

      Get the free sample chapters

      Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

      The Leanpub 60 Day 100% Happiness Guarantee

      Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

      Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

      You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

      So, there's no reason not to click the Add to Cart button, is there?

      See full terms...

      Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

      We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

      (Yes, some authors have already earned much more than that on Leanpub.)

      In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

      Learn more about writing on Leanpub

      Free Updates. DRM Free.

      If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

      Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

      Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

      Learn more about Leanpub's ebook formats and where to read them

      Write and Publish on Leanpub

      You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

      Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

      Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

      Learn more about writing on Leanpub