📄 Page
1
(This page has no text content)
📄 Page
2
1. Preface a. Who Should Read This Book b. What You’ll Need c. Conventions Used in This Book d. Using Code Examples e. O’Reilly Online Learning f. How to Contact Us g. Acknowledgments 2. 1. Toward a Microservices Architecture a. What Are Microservices? b. Reducing Coordination Costs i. The Coordination Cost Problem ii. The Hard Parts c. Learning by Doing i. The “Up and Running” Microservices Model d. Decisions, Decisions…
📄 Page
3
i. Writing a Lightweight Architectural Decision Record e. Summary 3. 2. Designing a Microservices Operating Model a. Why Teams and People Matter i. Team Size ii. Team Skills iii. Interteam Coordination b. Introducing Team Topologies i. Team Types ii. Interaction Modes c. Designing a Microservices Team Topology i. Establish a System Design Team ii. Building a Microservices Team Template iii. Platform Teams iv. Enabling and Complicated-Subsystem Teams v. Consumer Teams vi. Summary
📄 Page
4
4. 3. Designing Microservices: The SEED(S) Process a. Introducing the Seven Essential Evolutions of Design for Services: The SEED(S) Method b. Identifying Actors i. Example Actors in Our Sample Project c. Identifying Jobs That Actors Have to Do i. Using Job Story Format to Capture JTBDs ii. Example JTBDs in Our Sample Project d. Discovering Interaction Patterns with Sequence Diagrams e. Deriving Actions and Queries from JTBDs i. Example Queries and Actions for Our Sample Project f. Describing Each Query and Action as a Specification with an Open Standard i. Example OAS for an Action in Our Sample Project g. Getting Feedback on the API Specification h. Implementing Microservices
📄 Page
5
i. Microservices Versus APIs j. Summary 5. 4. Rightsizing Your Microservices: Finding Service Boundaries a. Why Boundaries Matter, When They Matter, and How to Find Them b. Domain-Driven Design and Microservice Boundaries i. Context Mapping ii. Synchronous Versus Asynchronous Integrations iii. A DDD Aggregate c. Introduction to Event Storming i. The Event-Storming Process d. Introducing the Universal Sizing Formula i. The Universal Sizing Formula e. Summary 6. 5. Dealing with the Data a. Independent Deployability and Data Sharing
📄 Page
6
b. Microservices Embed Their Data i. Embedding Data Should Not Lead to an Explosion in the Number of Database Clusters ii. Data Embedding and the Data Delegate Pattern iii. Using Data Duplication to Solve for Independence iv. Distributed Transactions and Surviving Failures c. Event Sourcing and CQRS i. Event Sourcing ii. Improving Performance with Rolling Snapshots iii. Event Store iv. Command Query Responsibility Segregation d. Event Sourcing and CQRS Beyond Microservices e. Summary 7. 6. Building an Infrastructure Pipeline a. DevOps Principles and Practices i. Immutable Infrastructure
📄 Page
7
ii. Infrastructure as Code iii. Continuous Integration and Continuous Delivery b. Setting Up the IaC Environment i. Set Up GitHub ii. Install Terraform c. Configuring Amazon Web Services i. Setting Up an AWS Operations Account ii. Configure the AWS CLI iii. Setting Up AWS Permissions iv. Creating an S3 Backend for Terraform d. Building an IaC Pipeline i. Creating the Sandbox Repository ii. Understanding Terraform iii. Writing the Code for the Sandbox Environment iv. Building the Pipeline v. Testing the Pipeline e. Summary
📄 Page
8
8. 7. Building a Microservices Infrastructure a. Infrastructure Components i. The Network ii. The Kubernetes Service iii. The GitOps Deployment Server b. Implementing the Infrastructure i. Installing kubectl ii. Setting Up the Module Repositories iii. The Network Module iv. The Kubernetes Module v. Setting Up Argo CD vi. Testing the Environment vii. Cleaning Up the Infrastructure c. Summary 9. 8. Developer Workspace a. Coding Standards and the Developer’s Setup i. 10 Workspace Guidelines for a Superior Developer Experience
📄 Page
9
b. Setting Up a Containerized Environment Locally i. Installing Multipass ii. Entering the Container and Mapping Folders c. Installing Docker i. Testing Docker d. Advanced Local Docker Usage: Installing Cassandra e. Installing Kubernetes f. Summary 10. 9. Developing Microservices a. Designing Microservice Endpoints i. Flights Microservice ii. Reservations Microservice iii. Designing an OpenAPI Specification b. Implementing the Data for a Microservice i. Redis for the Reservations Data Model ii. MySQL Data Model for the Flights Microservice
📄 Page
10
c. Implementing Code for a Microservice i. The Code Behind the Flights Microservice ii. Health Checks d. Introducing a Second Microservice to the Project e. Hooking Services Up with an Umbrella Project f. Summary 11. 10. Releasing Microservices a. Setting Up the Staging Environment i. The Ingress Module ii. The Database Module iii. Forking the Staging Infrastructure Project iv. Configuring the Staging Workflow v. Editing the Staging Infrastructure Code b. Shipping the Flight Information Container i. Introducing Docker Hub ii. Configuring Docker Hub iii. Configuring the Pipeline c. Deploying the Flights Service Container
📄 Page
11
i. Understanding Kubernetes Deployments ii. Creating a Helm Chart iii. Creating the Microservices Deployment Repository iv. Argo CD for GitOps Deployment d. Clean Up e. Summary 12. 11. Managing Change a. Changes in a Microservices System i. Be Data-Oriented ii. The Impact of Changes iii. Three Deployment Patterns b. Considerations for Our Architecture i. Infrastructure Changes ii. Microservices Changes iii. Data Changes c. Summary 13. 12. A Journey’s End (and a New Beginning)
📄 Page
12
a. On Complexity and Simplification Using Microservices i. Microservices Quadrant b. Measuring the Progress of a Microservices Transformation c. Summary 14. Index
📄 Page
13
Microservices: Up and Running A Step-by-Step Guide to Building a Microservices Architecture Ronnie Mitra and Irakli Nadareishvili
📄 Page
14
Microservices: Up and Running by Ronnie Mitra and Irakli Nadareishvili Copyright © 2021 Mitra Pandey Consulting, Ltd. and Irakli Nadareishvili. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: Melissa Duffield Development Editor: Melissa Potter Production Editor: Deborah Baker Copyeditor: Charles Roumeliotis Proofreader: Piper Editorial, LLC
📄 Page
15
Indexer: nSight, Inc. Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Kate Dullea December 2020: First Edition Revision History for the First Edition 2020-11-25: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781492075455 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Microservices: Up and Running, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the authors, and do not represent the publisher’s views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including
📄 Page
16
without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-492-07545-5 [LSI]
📄 Page
17
Dedication To every person who took the time to chronicle and share their experiences. And to Kairav, who didn’t help me write this dedication. —Ronnie Mitra To Lucas, who was born shortly after we started working on this book and whose smiles gave me the strength to complete this book in the middle of a global pandemic; to my wife Ana, for her support; and to my amazing students at Temple University, in Philadelphia, who kindly “test drove” early versions of a lot of the content in this book. —Irakli
📄 Page
18
Preface Ten years ago a group of software architects gathered together and coined the term microservices to define a style of software architecture that had evolved. Since that time, there’s been an explosion of classes, videos, and written works for the microservices style. In fact, in 2016 we coauthored Microservice Architecture, a book that offered an introductory guide to the principles of a microservices system. Since the publication of that book, we and many others have had a chance to live with the microservices systems we’ve built. Our own experiences, as well as conversations with other practitioners, have led to a better understanding of the practical problems that implementers face. A lot of that understanding comes from success, but some of the most useful insights have come from mistakes. We’ve endeavored to package up the experiences of practitioners into a highly opinionated guide. We live in an age with an abundance of practitioner advice available. But, it can be difficult to navigate this sea of information and put it together in a way that works. This book offers a practical, prescriptive model that spans team design, domain design, infrastructure, engineering, and release. Our goal is to give you a unified view of a microservices implementation and a strong first step in your journey to adoption.
📄 Page
19
Who Should Read This Book We’ve written this book for microservices implementers. While we touch on some of the principles and patterns of a microservices system, the focus of the book is on practical design and engineering. If you are an architect or engineer tasked with building microservices or a microservices architecture, this is the book for you. But this book is also a useful guide for readers who simply want to get “up close and personal” with a microservices implementation. No matter what your role is, if you’re interested in understanding the work that goes into building a microservices system, you’ll find this book enlightening. What You’ll Need Since the scope of microservices is quite large, we use a number of different tools and methods. If you want to follow along with all of the examples, you’ll need to install or subscribe to use the folllowing tools and platforms: Docker Redis MySQL GitHub
📄 Page
20
GitHub Actions Terraform Amazon Web Services kubectl Helm Argo CD We provide instructions on where and how to access these tools in their relevant sections. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.