O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Microservices Deployment Cookbook

Book Description

Master over 60 recipes to help you deliver complete, scalable, microservice-based solutions and see the improved business results immediately

About This Book

  • Adopt microservices-based architecture and deploy it at scale
  • Build your complete microservice architecture using different recipes for different solutions
  • Identify specific tools for specific scenarios and deliver immediate business results, correlate use cases, and adopt them in your team and organization

Who This Book Is For

This book is for developers, ops, and DevOps professionals who would like to put microservices to work and improve products, services, and operations. Those looking to build and deploy microservices will find this book useful, as well as managers and people at CXO level looking to adopt microservices in their organization. Prior knowledge of Java is expected. No prior knowledge of microservices is assumed.

What You Will Learn

  • Build microservices using Spring Boot, Wildfly Swarm, Dropwizard, and SparkJava
  • Containerize your microservice using Docker
  • Deploy microservices using Mesos/Marathon and Kubernetes
  • Implement service discovery and load balancing using Zookeeper, Consul, and Nginx
  • Monitor microservices using Graphite and Grafana
  • Write stream programs with Kafka Streams and Spark
  • Aggregate and manage logs using Kafka
  • Get introduced to DC/OS, Docker Swarm, and YARN

In Detail

This book will help any team or organization understand, deploy, and manage microservices at scale. It is driven by a sample application, helping you gradually build a complete microservice-based ecosystem. Rather than just focusing on writing a microservice, this book addresses various other microservice-related solutions: deployments, clustering, load balancing, logging, streaming, and monitoring.

The initial chapters offer insights into how web and enterprise apps can be migrated to scalable microservices. Moving on, you'll see how to Dockerize your application so that it is ready to be shipped and deployed. We will look at how to deploy microservices on Mesos and Marathon and will also deploy microservices on Kubernetes. Next, you will implement service discovery and load balancing for your microservices. We'll also show you how to build asynchronous streaming systems using Kafka Streams and Apache Spark.

Finally, we wind up by aggregating your logs in Kafka, creating your own metrics, and monitoring the metrics for the microservice.

Style and approach

This book follows a recipe-driven approach and shows you how to plug and play with all the various pieces, putting them together to build a complete scalable microservice ecosystem. You do not need to study the chapters in order, as you can directly refer to the content you need for your situation.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Microservices Deployment Cookbook
    1. Microservices Deployment Cookbook
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Customer Feedback
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Building Microservices with Java
      1. Introduction
      2. Creating a project template using STS and Maven
        1. Getting ready
        2. How to do it...
        3. There's more...
      3. Writing microservices with Spring Boot
        1. Getting ready
        2. How to do it...
      4. Writing REST APIs with Spring MVC
        1. Getting ready
        2. How to do it...
      5. Writing microservices with WildFly Swarm
        1. Getting ready
        2. How to do it...
      6. Writing microservices with Dropwizard
        1. Getting ready
        2. How to do it...
      7. Writing REST APIs with SparkJava
        1. Getting ready
        2. How to do it...
      8. Conclusion
    9. 2. Containerizing Microservices with Docker
      1. Building an executable JAR using Maven Shade plugin
        1. Getting ready
        2. How to do it...
      2. Building an executable JAR using the Spring Boot Maven plugin
        1. Getting ready
        2. How to do it...
      3. Installing and setting up Docker
        1. Getting ready
        2. How to do it...
      4. Writing your Dockerfile
        1. Getting ready
        2. How to do it...
      5. Building your Docker image
        1. Getting ready
        2. How to do it...
      6. Running your microservice inside a Docker container
        1. Getting ready
        2. How to do it...
      7. Pushing your image to Docker Hub
        1. Getting ready
        2. How to do it...
    10. 3. Deploying Microservices on Mesos
      1. Introduction
      2. Setting up a Mesos cluster using Docker
        1. Getting ready
          1. Zookeeper
          2. Mesos masters and Mesos slaves
          3. Mesos frameworks
        2. How to do it...
      3. Understanding the Mesos and Marathon interface
        1. Getting ready
        2. How to do it...
          1. The Mesos interface
            1. The Mesos home page
            2. Frameworks
          2. The Marathon web UI
      4. Deploying your microservice to Mesos using Marathon
        1. Getting ready
        2. How to do it...
      5. Configuring ports in Marathon
        1. Getting ready
        2. How to do it...
      6. Configuring volumes in Marathon
        1. Getting ready
        2. How to do it...
      7. Configuring environment variables in Marathon
        1. Getting ready
        2. How to do it...
      8. Scaling your microservice in Marathon
        1. Getting ready
        2. How to do it...
      9. Destroying your microservice in Marathon
        1. Getting ready
        2. How to do it...
      10. Monitoring your microservice logs in Marathon
        1. Getting ready
        2. How to do it...
      11. Monitoring your microservice logs in Mesos
        1. Getting ready
        2. How to do it...
      12. Managing your microservice using Marathon's REST API
        1. Getting ready
        2. How to do it...
    11. 4. Deploying Microservices on Kubernetes
      1. Introduction
        1. Kubernetes master
          1. API server
          2. etcd
          3. Scheduler
          4. Controller manager
          5. Kubernetes node
      2. Setting up Kubernetes cluster using Docker
        1. Getting ready
        2. How to do it...
      3. Understanding the Kubernetes dashboard
        1. Getting ready
        2. How to do it...
      4. Deploying your microservice on Kubernetes
        1. Getting ready
        2. How to do it...
      5. Configuring ports in Kubernetes
        1. Getting ready
        2. How to do it...
      6. Configuring volumes in Kubernetes
        1. Getting ready
        2. How to do it...
      7. Configuring environment variables in Kubernetes
        1. Getting ready
        2. How to do it...
      8. Scaling your microservice in Kubernetes
        1. Getting ready
        2. How to do it...
      9. Destroying your microservice in Kubernetes
        1. Getting ready
        2. How to do it...
      10. Monitoring your microservice logs in Kubernetes
        1. Getting ready
        2. How to do it...
    12. 5. Service Discovery and Load Balancing Microservices
      1. Introduction
      2. Setting up Zookeeper using Docker
        1. Getting ready
        2. How to do it...
      3. Load balancing microservices using Zookeeper
        1. Getting ready
        2. How to do it...
      4. Setting up Consul using Docker
        1. Getting ready
        2. How to do it...
          1. Understanding the concepts of Consul
      5. Implementing service discovery using Spring Cloud Consul
        1. Getting ready
        2. How to do it...
      6. Load balancing your microservice using Spring Cloud Consul
        1. Getting ready
        2. How to do it...
      7. Load balancing your microservice using Nginx and Consul
        1. Getting ready
        2. How to do it...
      8. Load balancing your microservice using Marathon LB
        1. How it works...
    13. 6. Monitoring Microservices
      1. Introduction
      2. Configuring Spring Boot Actuator metrics
        1. Getting ready
        2. How to do it...
      3. Understanding Spring Boot Actuator metrics
        1. Getting ready
        2. How to do it...
      4. Creating custom metrics using Dropwizard
        1. Getting ready
        2. How to do it...
      5. Setting up Graphite using Docker
        1. Getting ready
        2. How to do it...
      6. Using the Graphite interface
        1. Getting ready
        2. How to do it...
          1. Tree view
          2. Search
          3. Auto-Completer
          4. Graphite
      7. Exporting Dropwizard metrics over to Graphite
        1. Getting ready
        2. How to do it...
      8. Exporting Spring Boot Actuator metrics over to Graphite
        1. Getting ready
        2. How to do it...
      9. Setting up Grafana using Docker
        1. Getting ready
        2. How to do it...
      10. Configuring Grafana to use Graphite
        1. Getting ready
        2. How to do it...
      11. Configuring Grafana dashboards to view metrics
        1. Getting ready
        2. How to do it...
    14. 7. Building Asynchronous Streaming Systems with Kafka and Spark
      1. Introduction
      2. Setting up Kafka using Docker
        1. Kafka
          1. Point-to-point mechanism
          2. Pub-sub mechanism
        2. Kafka terminology
          1. Brokers
          2. Topics
          3. Partitions
          4. Producers and consumers
      3. Getting ready
      4. How to do it...
      5. Creating Kafka topics to stream data
        1. Getting ready
        2. How to do it...
      6. Writing a streaming program using Kafka Streams
        1. Getting ready
        2. How to do it...
      7. Improving the performance of the Kafka Streams program
        1. Getting ready
        2. How to do it...
      8. Writing a streaming program using Apache Spark
        1. Getting ready
        2. How to do it...
      9. Improving the performance of the Spark job
        1. How to do it...
      10. Aggregating logs into Kafka using Log4J
        1. Getting ready
        2. How to do it...
      11. Integrating Kafka with log management systems
        1. How it works...
    15. 8. More Clustering Frameworks - DC/OS, Docker Swarm, and YARN
      1. Introduction
      2. Deploying infrastructure with DC/OS
        1. Getting ready
        2. How to do it...
      3. Deploying containers with Docker Swarm
        1. Getting ready
        2. How to do it...
      4. Deploying containers on YARN
        1. Getting ready
        2. How it works...