Cloud Native Development with Google Cloud

Book description

Cloud native development gives you the power to rapidly build, secure, and scale software. But you still need to navigate many potential pitfalls along the way. Through practical examples, this book demonstrates how to use Google Cloud as a laboratory to enable rapid innovation, a factory to automate toil, a resilient, scalable, and secure citadel for running applications, and an observatory to observe them.

Author Daniel Vaughan shows you how to take applications from prototype to production by combining Google Cloud services, a cloud native programming model, and best practices. By following an example project from start to finish, developers, architects, and engineering managers working with the Google Cloud Platform will learn how to build and run cloud native applications on Google Cloud with confidence.

  • Understand cloud native development concepts from microservices and containerization to architecture best practices and cost optimization
  • Learn Google Cloud services that specifically support this development style: compute, persistence, messaging, DevOps, security and networking, and observability
  • Confidently build cloud native applications on Google Cloud
  • Learn how to address nonfunctional requirements such as security, observability, and testing
  • Successfully make the transition from initial proofs of concept and prototypes to production systems

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Who This Book Is For
    2. Conventions Used in This Book
    3. How This Book Is Organized
    4. Using Code Examples
    5. O’Reilly Online Learning
    6. How to Contact Us
    7. Acknowledgments
  2. I. Cloud Native Google Cloud
  3. 1. Why Cloud Native and Not Just Cloud?
    1. Emergence of the Cloud Era
    2. Navigating the Cloud Migration
    3. The Pitfalls of an Unplanned Journey
    4. More Than Just an Online Data Center
    5. Embracing the Cloud as a Distributed System
    6. Distinguishing Cloud Hosted from Cloud Native
    7. Unraveling the Concept of Cloud Native
    8. Embracing Cloud Native Architecture
    9. Building a Cloud Native Platform
      1. Laboratory, Factory, Citadel, and Observatory
      2. The Need for More Than Just a Factory
    10. Summary
  4. 2. Why Google Cloud Platform?
    1. Strong Foundations
    2. Powerful Abstractions
      1. Borg
      2. Colossus
      3. Spanner
      4. Andromeda
      5. Combining Abstractions
    3. Why Not DIY?
    4. Summary
  5. 3. Cloud Native Applications
    1. Autonomous Components Communicating with Messages
    2. Harnessing Cloud Potential with the 12-Factor App Principles
      1. I. Codebase: One Codebase Tracked in Version Control, Many Deploys
      2. II. Dependencies: Explicitly Declare and Isolate Dependencies
      3. III. Config: Store Config in the Environment
      4. IV. Backing Services: Treat Backing Services as Attached Resources
      5. V. Build, Release, Run: Strictly Separate Build and Run Stages
      6. VI. Processes: Execute the App as One or More Stateless Processes
      7. VII. Port Binding: Export Services via Port Binding
      8. VIII. Concurrency: Scale Out via the Process Model
      9. IX. Disposability: Maximize Robustness with Fast Startup and Graceful Shutdown
      10. X. Dev/Prod Parity: Keep Development, Staging, and Production as Similar as Possible
      11. XI. Logs: Treat Logs as Event Streams
      12. XII. Admin Processes: Run Admin/Management Tasks as One-Off Processes
    3. Beyond the 12 Factors
      1. API First
      2. Telemetry
      3. Security
    4. Defining Components with Microservices
    5. Determining Component Granularity
    6. Leveraging Domain-Driven Design for Defining Microservice Boundaries
    7. Intercommunication Between Microservices: APIs and Events
      1. Event-Driven Architecture
      2. API-First Approach
    8. Harmonizing APIs and Events for Effective Microservice Communication
    9. Event Storming: A Collaborative Approach to System Design
    10. Achieving Portability with Containers
    11. Flexible Running with Container Runtimes
    12. Avoiding Lock-In with Abstractions
    13. Responding to Change with Extreme Programming (XP)
    14. Building Confidence with Testing
    15. Eliminating Toil with Automation
    16. Summary
  6. II. Hands-On Projects
  7. 4. Preparing Google Cloud
    1. Create a Google Account
      1. Install the gcloud CLI
      2. Update Your gcloud Client
      3. Log In to gcloud
      4. Set Your Default Region and Zone
    2. Create a Project
      1. Enable Billing
      2. Checking Billing Is Enabled
      3. Doing More with the gcloud CLI
    3. Key Google Cloud Concepts
      1. Environment Files
      2. Enabling Services
      3. Identity and Access Management
      4. Service Accounts
    4. Recommended Tools
      1. Google Cloud Architecture Diagramming Tool
      2. Command-Line Utilities
    5. Introducing the Example Application
      1. Introducing Skills Mapper
      2. Skills Mapper Architecture
    6. Services Used
    7. Summary
  8. 5. Project 1: Tag Updater with Cloud Functions
    1. Requirements
      1. User Story
      2. Elaborated Requirements
    2. Solution
      1. Architecture Diagram
      2. Summary of Services
    3. Command Line Implementation
      1. BigQuery
      2. Cloud Storage
    4. Cloud Native Implementation
      1. Cloud Functions
      2. Configuration
      3. Testing with cURL
      4. Cloud Scheduler
    5. Terraform Implementation
    6. Evaluation
      1. How Will This Solution Scale?
      2. How Much Will This Solution Cost?
    7. Summary
  9. 6. Project 2: Skill Service with Cloud Run
    1. Requirements
      1. User Story
      2. Elaborated Requirements
    2. Solution
    3. Summary of Services
      1. Cloud Storage
      2. Cloud Run
    4. Implementation
      1. Getting Ready for Deployment
      2. Deploy with Cloud Run
    5. Smoke Testing
    6. Running the Service Locally
    7. Securing
    8. Create a Service Account
    9. Performance Testing
    10. Logging
    11. Improving Performance
    12. How Much Will This Solution Cost?
    13. Summary
  10. 7. Project 3: Fact Service with Spring Boot, Cloud Run, and Cloud SQL
    1. Requirements
      1. User Story
      2. Elaborated Requirements
    2. Solution
    3. Summary of Services
      1. Spring Boot with Spring Cloud GCP
      2. Identity Platform
      3. Cloud SQL
      4. Cloud Run
      5. Spring Cloud GCP
    4. Implementation
      1. Creating a New Spring Boot Project
      2. Configuring Identity Platform
      3. Building the Container
      4. Creating a Cloud SQL Instance
      5. Creating a Database and User
      6. Test Deploying to Cloud Run
      7. Creating a Secret in Secret Manager
      8. Creating a Service Account
      9. Deploying to Cloud Run Connecting to Cloud SQL
      10. Authentication with Identity Platform
      11. Improving the Startup Time
    5. Evaluation
      1. How Will This Solution Scale?
      2. How Much Will This Solution Cost?
    6. Summary
  11. 8. Project 4: Profile Service with Pub/Sub and Firestore
    1. Requirements
      1. User Story
      2. Elaborated Requirements
    2. Solution
    3. Summary of Services
      1. Google Firestore
      2. Google Pub/Sub
      3. Cloud Run
    4. Implementation
      1. Storing Data in Firestore
      2. Sending Events to Pub/Sub
      3. Configuring Pub/Sub
      4. Configuring Service Accounts
      5. Receiving Pub/Sub Events
      6. Creating a Subscription
    5. Testing the Profile Service
    6. Evaluation
      1. Firestore
      2. Cloud Run
      3. Cloud Pub/Sub
    7. Summary
  12. 9. Project 5: API and User Interface with API Gateway and Cloud Storage
    1. Requirements
    2. Solution
      1. User Interface
      2. OpenAPI
      3. API Gateway
      4. Global HTTP Load Balancer
    3. Implementation
      1. Hosting the UI on Cloud Run
      2. Deploying the UI Container to Cloud Run
      3. Hosting the UI in a Cloud Storage Bucket
      4. Configuring the API
      5. Testing the API Gateway
      6. Disabling Unauthenticated Access to Cloud Run Services
    4. Summary
    5. Coming Next
  13. III. The Facilities
  14. 10. Laboratory
    1. The Inner Loop
    2. Containers in the Inner Loop
    3. Inside the Laboratory
    4. Choosing an IDE
    5. Cloud Code
      1. Desktop IDE with Cloud Code
      2. Cloud Shell Editor
      3. Cloud Workstations
      4. Comparison of Cloud Code–Enabled IDEs
    6. Skaffold
    7. Efficiently Building Containers
      1. Using a Dockerfile
      2. Jib
      3. Ko
      4. Buildpacks
      5. Comparison of Container Build Tools
    8. Deploy to a Development Container Runtime
      1. Local Kubernetes
      2. Shared GKE
      3. GKE Autopilot
      4. Cloud Run
      5. Comparison of Development Container Runtimes
    9. Choosing a Container Repository
      1. Artifact Registry or Container Registry?
      2. External Registry
    10. Choosing an Integration Testing Method
      1. Actual Service Instance
      2. Local Emulator
      3. Local Container
    11. Comparison of Service Integration Testing
    12. Building an Example Laboratory
      1. Start the Cloud Shell Editor
      2. Clone the Code
      3. Enable Jib
      4. Init Skaffold
      5. Repeat for the Skill and Profile Services
      6. Start Minikube
      7. Create a Secret for Service Account Keys
      8. Build a Container with Skaffold
      9. Run Skaffold
    13. Summary
  15. 11. Citadel
    1. Securing from Attackers
      1. Adding a Custom Domain
      2. Reserving a Static IP Address
      3. Creating an A Record to the Static IP Address
      4. Creating an SSL Certificate
      5. Create a Load Balancer
      6. Testing the UI
      7. Testing the API
      8. Authenticating Real Users with Identity Platform
    2. Testing the UI Authentication
    3. Evaluation
    4. How Will This Solution Scale?
    5. Enhancing Defenses with Cloud Armor
      1. Blocking Specific Addresses
      2. Rate-Limiting Calls to the API
      3. Extending Cloud Armor Further
      4. How Much Will This Solution Cost?
    6. Summary
  16. 12. Factory
    1. Automating Build, Deployment, and Provisioning
      1. Requirements
      2. The Outer Loop
      3. DORA Metrics
      4. Canary Releases
      5. Summary of Services
      6. Implementation
      7. Deploying Infrastructure
      8. How Much Will This Cost?
    2. Summary
  17. 13. Observatory
    1. Monitoring the System
    2. Site Reliability Engineering
    3. Golden Signals
    4. Implementing Observability
      1. Monitoring Workspaces
      2. Configuring Cloud Monitoring
      3. Metrics
      4. Dashboards
      5. Creating a Custom Dashboard
      6. Logging
      7. Log-Based Metrics
      8. Alerts
      9. User-Defined Metrics and Tracing
      10. Tracing
      11. Adding Trace and Span IDs to Logs
    5. How Much Does It Cost?
    6. Summary
  18. IV. Going Further
  19. 14. Scaling Up
    1. Skill Service with Memorystore
    2. Fact Service with GKE Autopilot and Spanner
    3. Requirements
      1. User Story
      2. Elaborated Requirements
    4. Solution
      1. GKE Autopilot
      2. Cloud SQL
      3. Cloud Spanner
      4. Kubernetes Service Accounts
      5. Workload Identity
      6. Skaffold
    5. Preparation
      1. Getting Ready for Kubernetes
      2. Getting Ready for Spanner
      3. Kubernetes Configuration
    6. Implementation
      1. Create a GKE Autopilot Cluster
      2. Service Account Binding with Workload Identity
      3. Deploying the Pod
      4. Scaling with a Horizontal Pod Autoscaler
      5. Exposing with a Load Balancer
    7. Switching to Spanner
      1. Create a Spanner Instance
      2. Create a Spanner Database
      3. Authenticate the Service Account
      4. Redeploy the Fact Service
    8. Evaluation
      1. How Will This Solution Scale?
      2. How Much Will This Solution Cost?
    9. Summary
  20. 15. Going Further
    1. Professional Certification
    2. Online Learning Resources and Communities
      1. YouTube
      2. Podcasts
      3. Qwiklabs
      4. Non-Google Communities
    3. Community Support
      1. Google Staff
      2. Partners
      3. Customer Groups
      4. Developer Community
    4. Conferences and Events
    5. Summary
  21. Appendix. Deploying Skills Mapper
    1. Reintroducing Terraform
    2. Installing Terraform
    3. Terraform Workflow
    4. Terraform Configuration
    5. Preparing for Terraform
    6. Creating Projects
    7. Terraform Backend
      1. Configure Identity Platform
      2. Setting Terraform Variables
    8. Deploying with Terraform
    9. Reapplying Terraform
    10. Deleting Everything
  22. Index
  23. About the Author

Product information

  • Title: Cloud Native Development with Google Cloud
  • Author(s): Daniel Vaughan
  • Release date: November 2023
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098145088