Cloud Native Microservices With Kubernetes
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes
Available as: Kindle, Paperback, Online course
What You'll Learn
- Package and ship services to Kubernetes with Helm and Rancher
- Wire CI/CD and GitOps so a commit reaches the cluster without you
- Instrument services with Prometheus and read what they report
- Route, secure and observe traffic through an Istio service mesh
- Provision the underlying infrastructure with Terraform
About This Book
A complete guide to building, deploying, and managing scalable microservices in Kubernetes. Learn GitOps, CI/CD, observability, and service mesh using tools like Rancher, Helm, Prometheus, Istio, Terraform, and more. Ideal for developers and architects ready to master Cloud Native systems with practical, hands-on examples.
Table of Contents
-
Preface
- Who This Guide Is For
- What You Will Learn
- About the Author
- Join the Community
- Your Feedback Matters
-
How to Use This Guide
- The Companion Kit
- Conventions Used in This Guide
-
Cloud Native Microservices: How and Why
- Lehman's Laws of Software Evolution
- The Twelve-Factor App
- Unix/Linux Philosophy
- Microservices
- From Microservices to Cloud-Native Microservices
-
Setting Up the Foundation
- Prerequisites
- Creating the Workspace Server
- Creating the Kubernetes Cluster
- Installing the Necessary Tools
-
Kubernetes Architecture Overview
- Introduction
- The Control Plane
- Worker Nodes
- Kubelet
- Container Runtime
- Kube-proxy
- Node pools
- An overview of the architecture and the flow of information
- Key Takeaways
-
Stateless and Stateful Microservices
- Introduction
- Stateless Workloads
- Stateful Workloads
-
Deploying Stateless Microservices: Introduction
- Creating a Simple Stateless Microservice
- Namespaces: Pitfalls and Best Practices
- Creating a Namespace
- Pods, ReplicaSets, and Deployments
- The Building Analogy
- Creating the Deployment
- Post-Deployment Checks: Status, Events, and Logs
- Accessing Pods and Port Forwarding
- Using Services to Expose Applications
- Key Takeaways
-
Deploying Stateful Microservices: Persisting Data in Kubernetes
- ConfigMap: Storing Configuration Data in a Decoupled Manner
- Persisting Data Storage in PostgreSQL
- Consuming ConfigMaps
- Attaching a Kubernetes Volume to a Workload
- Deploying PostgreSQL: Putting It All Together
- Inter-Pod Communication and External Access
- Testing Data Persistence
- Key Takeaways
-
Understanding and Using StatefulSets and Headless Services
- A Common Topology for Relational Databases
- StatefulSet: A Slow but Safe Brain for Databases
- Headless Services: The No-Middleman Approach to Pod Networking
- StatefulSet & Headless Service for PostgreSQL: Putting It All Together
- Having a Minimum Viable PostgreSQL Cluster
- CloudNativePG, Operators, CRDs, and PostgreSQL Clustering in Kubernetes
- Key Takeaways
-
From Settings to Startup: Managing Configuration and Initialization in Kubernetes
- Configuration Challenges in Microservices
- Use Cases and Required Environment
- ConfigMap: Setting Non-Sensitive Configurations
- Kubernetes Secrets: Setting Sensitive Configurations
- Init Container: Initializing the Application
- Key Takeaways
-
Best Practices for Microservices: Health Checks
- Health Checks
- The Fundamentals of Health Checks: Liveness, Readiness, and Startup
- Probing Mechanisms: HTTP, TCP, and Exec
- Fine-Tuning Probes with Configuration Options
- Best Practices for Implementing Health Checks
- Key Takeaways
-
Understanding Resource Management in Kubernetes
- From Containers to Pods: Understanding Resource Management
- Requests and Limits
- CPU Resource Units in Kubernetes
- Memory Resource Units
- Considerations When Setting Resource Requests and Limits
- CPU vs. Memory Is Time vs. Space
- Resource Quotas and Limit Ranges
- Node Reserve vs Allocatable Resources
- Key Takeaways
-
Priority Mechanisms in Kubernetes: QoS and PriorityClass
- Quality of Service (QoS) Classes
- How Requests and Limits Affect Priority and Eviction
- PriorityClass, Pod Priority, Preemption, and Victim Pods
- PriorityClass
- Priority vs. Quality of Service (QoS)
- Key Takeaways
-
Autoscaling Microservices in Kubernetes: Best Practices
- Kubernetes: A Natural Fit for Scalable Microservices
- Key Takeaways
-
Autoscaling Microservices in Kubernetes: Horizontal Autoscaling
- Horizontal Scaling
- Horizontal Pod Autoscaler
- Horizontal Pod Autoscaler in Practice
- Cluster Autoscaler
-
Autoscaling Microservices in Kubernetes: Vertical Scaling
- What is Vertical Scaling?
- The Frontiers of Horizontal Scaling
- The Vertical Pod Autoscaler
- VPA Modes
- The VPA Recommender: A Statistical Analyzer
- When to Use VPA Recommendations
- VPA Limitations
- Key Takeaways
-
Microservices Deployment Strategies: Node-Level Workloads
- When Deployment and StatefulSet are Not Enough
- DaemonSet: A Special Type of Controller
- DaemonSet: How to Use It
- Key Takeaways
-
Microservices Deployment Strategies: Custom Scheduling
- Assigning Your Workloads to Specific Nodes: Why?
- Taints and Tolerations: Theory & Practice
- The nodeSelector: Simple Custom Scheduling with Labels
- Affinity and Anti-Affinity: Advanced Node Scheduling
- Key Takeaways
-
Managing Upgrades and Maintenance in Kubernetes
- Leveling Up Your Infrastructure: Why and When?
- What to Upgrade?
- Draining and Cordoning Nodes
- Cordoning and Uncordoning Nodes
- Upgrading Node Pools
- Key Takeaways
-
Pod Disruption Budgets: Availability Assurance
- Use Case and Motivation
- Creating a Pod Disruption Budget
- Key Takeaways
-
Microservices Deployment Strategies: Blue/Green, Canary, and Rolling Updates
- Cloud Native Practices
- Deployment Strategies
- Rolling Updates: Changing the Tyres While Driving
-
Microservices Observability in a Distributed Environment
- Introduction to Observability
- What is Monitoring?
- What Is Observability and Why Is It Important?
- White-Box Monitoring vs. Black-Box Monitoring
- The 3 Pillars of Observability
- The Four Golden Signals of Monitoring
- Key Takeaways
-
Microservices Observability in a Kubernetes World: Metrics
- From Borgmon to Cloud Native Monitoring: Prometheus's Journey
- Installing Prometheus
- Prometheus Web User Interface
- Metrics Available in Prometheus
- Using Grafana to Visualize Prometheus Metrics
- Key Takeaways
-
Microservices Observability in a Kubernetes World: Logs
- Shipping Container Logs with Promtail
- Setting Up Loki for Log Aggregation
- Using Loki to Query Logs
- Key Takeaways
-
Microservices Observability in a Kubernetes World: Distributed Tracing
- Using Jaeger and OpenTelemetry for Distributed Tracing
- Key Takeaways
-
GitOps: Cloud Native Continuous Delivery
- GitOps: Introduction and Definitions
- GitOps: Benefits and Drawbacks
- GitOps: Tools and Ecosystem
- Key Takeaways
-
GitOps: Example of a GitOps workflow using Argo CD
- Argo CD: Introduction
- Argo CD: Installation and Configuration
- Argo CD: Deploying an Application
- Argo CD: Automated Synchronization and Self-Healing
- Argo CD: Roll Back
- Argo CD: The Declarative Way
- Argo CD: Configuration Management using Helm
- Argo CD: Managing Different Environments
- Argo CD: Deployment Hooks
- Key Takeaways
-
Everything You Need to Know to Start Using Helm
- What is Helm?
- How to Install Helm
- Charts, Releases, and Repositories
- Helm Plugins
- Helm Environment Variables
- Understanding Helm Chart Installation and Management
- Installing from a Specific Repository
- Using a Chart with Custom Configurations
- Using a Chart with a Custom Configuration File
- Install a Chart from a Local Tarball
- Installing a Chart from a Local Directory
- Default Helm Labels
- Understanding What's Installed and How
- Install a Chart in a Specific Namespace
- Understanding Chart Versions and Upgrading Releases
- Viewing Release
- Viewing Release History
- Uninstalling a Release
- Key Takeaways
-
Continuous Integration, Delivery, and Deployment of Microservices: A Hands-on Guide
- The CI/CD Ecosystem: A Survey of Popular Tools
- Defining CI/CD Pipeline Workflows
- Setting Up the Repositories
- CI Workflows for Our Microservice with GitHub Actions
- Continuous Delivery with Helm
- Continuous Deployment with Argo CD
- Key Takeaways
-
Afterword
- Let's Stay Connected
- Feedback
Who This Is For
Developers and architects running services on Kubernetes who want the whole delivery path, not just kubectl apply.
About the Author
Aymen El Amri is a software engineer, author and founder. He runs eralabs, built FAUN.dev, and writes about cloud native systems, AI engineering and developer tooling. More about Aymen.