contents

preface

acknowledgments

about this book

about the author

about the cover illustration

 

  1  Why microservices?

  1.1  This book is practical

  1.2  What will I learn?

  1.3  What do I need to know?

  1.4  Managing complexity

  1.5  What is a microservice?

  1.6  What is a microservices application?

  1.7  What’s wrong with the monolith?

  1.8  Why are microservices popular now?

  1.9  Benefits of microservices

  1.10  Drawbacks of microservices

  1.11  Modern tooling for microservices

  1.12  Designing a microservices application

  1.13  An example application

  2  Creating your first microservice

  2.1  New tools

  2.2  Getting the code

  2.3  Why Node.js?

  2.4  Our philosophy of development

  2.5  Establishing our single-service development environment

Installing Git

Cloning the code repo

Getting Visual Studio (VS) Code

Installing Node.js

  2.6  Building an HTTP server for video streaming

Creating a Node.js project

Installing Express

Creating the Express boilerplate

Running our simple web server

Adding streaming video

Configuring our microservice

Setting up for production

Live reloading for fast iteration

Running the finished code from this chapter

  2.7  Node.js review

  2.8  Continue your learning

  3  Publishing your first microservice

  3.1  New tools

  3.2  Getting the code

  3.3  What is a container?

  3.4  What is an image?

  3.5  Why Docker?

  3.6  What are we doing with Docker?

  3.7  Extending our development environment with Docker

Installing Docker

Checking your Docker installation

  3.8  Packaging our microservice

Creating a Dockerfile

Packaging and checking our Docker image

Booting our microservice in a container

  3.9  Publishing our microservice

Creating a private container registry

Pushing our microservice to the registry

Booting our microservice from the registry

  3.10  Docker review

  3.11  Continue your learning

  4  Data management for microservices

  4.1  New tools

  4.2  Getting the code

  4.3  Developing microservices with Docker Compose

Why Docker Compose?

Installing Docker Compose

Creating our Docker Compose file

Booting our microservices application

Working with the application

Shutting down the application

Can we use Docker Compose for production?

  4.4  Adding file storage to our application

Using Azure Storage

Updating the video-streaming microservice

Adding our new microservice to the Docker Compose file

Testing the updated application

Cloud storage vs. cluster storage

What did we achieve?

  4.5  Adding a database to our application

Why MongoDB?

Adding a database server in development

Adding a database server in production

Database-per-microservice or database-per-application?

What did we achieve?

  4.6  Docker Compose review

  4.7  Continue your learning

  5  Communication between microservices

  5.1  New and familiar tools

  5.2  Getting the code

  5.3  Getting our microservices talking

  5.4  Introducing the history microservice

  5.5  Live reload for fast iterations

Creating a stub for the history microservice

Augmenting the microservice for live reload

Splitting our Dockerfile for development and production

Updating the Docker Compose file for live reload

Trying out live reload

Testing production mode in development

What have we achieved?

  5.6  Methods of communication for microservices

Direct messaging

Indirect messaging

  5.7  Direct messaging with HTTP

Why HTTP?

Directly targeting messages at particular microservices

Sending a message with HTTP POST

Receiving a message with HTTP POST

Testing the updated application

Sequencing direct messages

What have we achieved?

  5.8  Indirect messaging with RabbitMQ

Why RabbitMQ?

Indirectly targeting messages to microservices

Creating a RabbitMQ server

Investigating the RabbitMQ dashboard

Connecting our microservice to the message queue

Single-recipient indirect messaging

Multiple-recipient messages

Sequencing indirect messages

What have we achieved?

  5.9  Microservices communication review

  5.10 Continue your learning

  6  Creating your production environment

  6.1  New tools

  6.2  Getting the code

  6.3  Getting to production

  6.4  Infrastructure as code

  6.5  Hosting microservices on Kubernetes

Why Kubernetes?

How does Kubernetes work?

  6.6  Working with the Azure CLI

Installing the Azure CLI

Authenticating with Azure

Which version of Kubernetes?

What have we achieved?

  6.7  Creating infrastructure with Terraform

Why Terraform?

Installing Terraform

Terraform project setup

  6.8  Creating an Azure resource group for your application

Evolutionary architecture with Terraform

Scripting infrastructure creation

Initializing Terraform

By-products of Terraform initialization

Fixing provider version numbers

Building your infrastructure

Understanding Terraform state

Destroying and recreating your infrastructure

What have we achieved?

  6.9  Creating your container registry

Continuing the evolution of our infrastructure

Creating the container registry

Terraform outputs

What have we achieved?

  6.10  Refactoring to share configuration data

Continuing the evolution of our infrastructure

Introducing Terraform variables

  6.11  Creating our Kubernetes cluster

Scripting creation of your cluster

Cluster authentication with Azure

Building your cluster

What have we achieved?

  6.12  Interacting with Kubernetes

Kubernetes authentication

The Kubernetes CLI

The Kubernetes dashboard

What have we achieved?

  6.13  Terraform review

  6.14  Continue your learning

  7  Getting to continuous delivery

  7.1  New and familiar tools

  7.2  Getting the code

  7.3  Continuing to evolve our infrastructure

  7.4  Continuous delivery (CD)

  7.5  Deploying containers with Terraform

Configuring the Kubernetes provider

Deploying our database

Preparing for continuous delivery

Testing the new database server

Deploying and testing RabbitMQ

Tightening our security

What have we achieved?

  7.6  Deploying our first microservice with Terraform

Using local variables to compute configuration

Building and publishing the Docker image

Authentication with the container registry

Deploying the video-streaming microservice

Testing your microservice

What have we achieved?

  7.7  Continuous delivery with Bitbucket Pipelines

Why Bitbucket Pipelines?

Importing the example code to Bitbucket

Creating a deployment shell script

Managing Terraform state

The Bitbucket Pipelines script

Configuring environment variables

Testing your deployment pipeline

Debugging your deployment pipeline

What have we achieved?

  7.8  Continue your learning

  8  Automated testing for microservices

  8.1  New tools

  8.2  Getting the code

  8.3  Testing for microservices

  8.4  Automated testing

  8.5  Testing with Jest

Why Jest?

Setting up Jest

The math library to test

Your first Jest test

Running your first test

Live reload with Jest

Interpreting test failures

Invoking Jest with npm

Populating your test suite

Mocking with Jest

What have we achieved?

  8.6  Unit testing

The metadata microservice

Creating unit tests with Jest

Running the tests

What have we achieved?

  8.7  Integration testing

The code to test

Running a MongoDB database

Loading database fixtures

Creating an integration test with Jest

Running the test

What have we achieved?

  8.8  End-to-end testing

Why Cypress?

Installing Cypress

Starting the Cypress UI

Setting up database fixtures

Booting your application

Creating an end-to-end test with Cypress

Invoking Cypress with npm

What have we achieved?

  8.9  Automated testing in the CD pipeline

  8.10 Review of testing

  8.11 Continue your learning

  9  Exploring FlixTube

  9.1  No new tools!

  9.2  Getting the code

  9.3  Revisiting essential skills

  9.4  Overview of FlixTube

FlixTube microservices

Microservice project structure

FlixTube project structure

  9.5  Running FlixTube in development

Booting a microservice

Booting the application

  9.6  Testing FlixTube in development

Testing a microservice with Jest

Testing the application with Cypress

  9.7  FlixTube deep dive

Database fixtures

Mocking storage

The gateway

The user interface (UI)

Video streaming

Video upload

  9.8  Manually deploying FlixTube to production with Terraform

The Terraform scripts structure

Prerequisites

Azure authentication

Configuring storage

Deploying the application

Checking that it works

Teardown

Terraform modules

  9.9  Continuous delivery to production

Prerequisites

Setting up your code repository

Preparing the backend

The deployment shell script

FlixTube’s CD configuration

Testing the continuous delivery (CD) pipeline

Adding automated testing

  9.10 Review

  9.11 FlixTube in the future

  9.12 Continue your learning

10  Healthy microservices

10.1  Maintaining healthy microservices

10.2  Monitoring your microservices

Logging in development

Error handling

Logging with Docker Compose

Basic logging with Kubernetes

Roll your own log aggregation for Kubernetes

Enterprise logging, monitoring and alerts

Automatic restarts with Kubernetes health checks

Tracing across microservices

10.3  Debugging microservices

The debugging process

Debugging production microservices

10.4  Reliability and recovery

Practice defensive programming

Practice defensive testing

Protect your data

Replication and redundancy

Fault isolation and graceful degradation

Simple techniques for fault tolerance

Advanced techniques for fault tolerance

10.5  Continue your learning

11  Pathways to scalability

11.1  Our future is scalable

11.2  Scaling the development process

Multiple teams

Independent microservices

Splitting the code repository

Splitting the continuous delivery (CD) pipeline

The meta-repo

Creating multiple environments

Production workflow

11.3  Scaling performance

Vertically scaling the cluster

Horizontally scaling the cluster

Horizontally scaling an individual microservice

Elastic scaling for the cluster

Elastic scaling for an individual microservice

Scaling the database

Managing changes to infrastructure

11.4  Security

Trust models

Sensitive configuration

11.5  Refactoring to microservices

11.6  Microservices on a budget

11.7  From simple beginnings ...

11.8  Continue your learning

 

appendix A. Creating a development environment with Vagrant

appendix B. Bootstrapping Microservices cheat sheet

 

index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.19.251