Cloud Native Microservices With Kubernetes
Cloud Native Microservices With Kubernetes
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes
About the Book
TL;DR:
In this comprehensive guide, we will dive deep into the intricacies of microservices, high-availability strategies, CI/CD, GitOps, and observability in a Cloud Native world.
We will employ a wide array of tools, including:
- Docker,
- Kubernetes,
- minikube,
- Rancher,
- Terraform,
- Operators,
- Helm,
- Prometheus,
- Istio,
- Grafana,
- OpenTelemetry,
- Jaeger,
- Loki,
- Argo CD
- Ansible
- and more.
These are the top 10 things you will learn in this guide:
- Understand the Cloud Native approach to building software and microservices.
- Understand Kubernetes architecture and its core components.
- Run Kubernetes locally and in the cloud.
- Use Rancher to manage containers and Kubernetes.
- Manage data persistence in Kubernetes.
- Understand the different types of services in Kubernetes and when to use each one.
- Use Operators, Helm, Terraform, and other tools to provision and manage Kubernetes clusters.
- Implement deployment strategies such as Blue/Green, Canary, and Rolling updates.
- Use Istio to implement a service mesh in Kubernetes.
- Implement Observability and GitOps in Kubernetes using Prometheus, Grafana, Jaeger, Loki, OpenTelemetry, Argo CD, and Ansible.
About This Book:
This guide will embark you on an exhilarating journey, unraveling the subtleties and possibilities of Kubernetes - the most popular container orchestration platform in the world. You will discover how to use Kubernetes to build a robust, scalable, and resilient microservices architecture.
"Cloud Native Microservices With Kubernetes" is an insightful guide taking you into the nitty-gritty of Kubernetes and providing help to leverage all its possibilities.
It is designed for a broad range of audiences, from newcomers willing to plunge into Kubernetes, to masters keen on pushing forward the bar of proficiency on this platform while staying tuned with its latest developments.
The chapters are sequentially outlined to ensure easy, progressive learning. The process starts with a review of the available options to run Kubernetes locally and in the cloud.
We will explore how to provision a Kubernetes cluster in the cloud using Minikube, Rancher, and Terraform. Finally, we will provision a cluster with any managed Kubernetes service of a cloud provider.
We will also discuss the Cloud Native app development methodology and some of the basic building blocks of Kubernetes before moving on to more advanced topics such as resource management, autoscaling, and deploying different types of microservices.
This exhaustive guide will deeply dive into all these - microservices intricacies, high-availability strategies, CI/CD, and all things observability in this world of everything cloud native.
We will be using Docker, Kubernetes, minikube, Rancher, Terraform, Operators, Helm, Prometheus, Istio, Grafana, OpenTelemetry, Jaeger, Loki, Ansible, and many other tools.
Our findings will be based on GitOps where we get to learn how establishing a good workflow of GitOps is done using Argo CD. We will easily handle CI/CD (continuous delivery and deployment) strategies such as Blue/Green, Canary deployments, and Rolling updates.
We will also overview different ways data can be managed in Kubernetes starting from persistent volumes to stateful sets. We will guide you through steps for creating different types of services in Kubernetes as well as approaches that may be used to expose those services outside the cluster with the help of Ingress and Service Mesh.
This guide will help you achieve high availability, scalability, efficient deployment, monitoring, CI/CD, and everything else a person needs to build your next microservices architecture. All of this is using the power of Kubernetes and its ecosystem.
Each chapter of the guide has an example and practical exercises to make you feel the atmosphere of using Kubernetes and the like. By doing these examples, you will comprehend the very stem of Kubernetes notions and their real-life implementations.
This guide will provide you with the knowledge and skills necessary for designing, creating, managing, scaling, deploying, and monitoring your microservices on Kubernetes.
Toward the end of this guide, I hope that Kubernetes ceases to be a horrifying maze. Instead, it becomes something you're good at and can use as your tool to write your own success story.
Enjoy the process!
Team Discounts
Get a team discount on this book!
Table of Contents
- Cloud Native Microservices: How and Why
- Common Approaches
- The Twelve-Factor App
- Codebase
- Dependencies
- Config
- Backing Services
- Build, Release, Run
- Processes
- Port Binding
- Concurrency
- Disposability
- Dev/Prod Parity
- Logs
- Admin Processes
- Microservices
- Database per Service
- API Composition
- Service Instance per Container
- Externalized Configuration
- Server-Side Service Discovery
- Circuit Breaker
- Cloud Native
- From Monolith to Cloud Native Microservices
- Requirements
- A Development Server
- Install Kubectl
- Kubernetes: Creating a Cluster
- Creating a Development Kubernetes Cluster Using Minikube
- Minikube: Installation
- Minikube: Creating a Cluster
- Minikube: Profiles
- Minikube: User Interface
- Creating a Deployment
- Kubernetes Events
- Exposing a Deployment
- Deleting K8s Resources
- Minikube: Addons
- Using Kubectl with Minikube
- Deleting clusters
- Creating a Development Kubernetes Cluster Using Rancher
- Requirements
- Using Terraform to Launch the Cluster
- Creating Kubernetes Resources Using Rancher UI
- Creating an On-Premises Kubernetes Cluster Using Rancher
- Requirements Before Starting
- Creating a Cluster Using Rancher Server
- Notes about High Availability
- Creating an On-Premises Kubernetes Cluster: Other Options
- Managed Clusters
- Creating a Managed DOK Cluster Using Terraform
- Creating a Development Kubernetes Cluster Using Minikube
- Kubernetes Architecture Overview
- Introduction
- The Control Plane
- Etcd
- API Server (kube-apiserver)
- Controller Manager (kube-controller-manager)
- Cloud Controller Manager (cloud-controller-manager)
- Scheduler (kube-scheduler)
- Worker Nodes
- Kubelet
- Container Runtime
- Kube-proxy
- Nodepools
- An overview of the architecture
- Stateless and Stateful Microservices
- Introduction
- Stateless Workloads
- Stateful Workloads
- Deploying Stateless Microservices: Introduction
- Requirements
- Creating a Namespace
- Creating the Deployment
- Examining Pods and Deployments
- Accessing Pods
- Exposing a Deployment
- ClusterIP Service
- NodePort Service
- LoadBalancer Service
- Headless Service
- Ingress Service
- Deploying Stateful Microservices: Persisting Data in Kubernetes
- Requirements
- Creating a Namespace
- Creating a ConfigMap for the PostgreSQL Database
- What is a ConfigMap?
- ConfigMap for PostgreSQL
- Persisting Data Storage on PostgreSQL
- Kubernetes Volumes
- VolumeClaims
- StorageClass
- Adding Storage to PostgreSQL
- Creating a Deployment for PostgreSQL
- Creating a Service for PostgreSQL
- Creating a Deployment for our application
- Creating a Service for Our Application
- Creating an External Service for Our Application
- Creating an Ingress for Our Application
- Checking Logs and Making Sure Everything is Working
- Summary
- Deploying Stateful Microservices: StatefulSets
- What is a StatefulSet?
- StatefulSet vs Deployment
- Creating a StatefulSet
- Creating a Service for the StatefulSet
- Post Deployment Tasks
- StatefulSet vs Deployment: Persistent Storage
- StatefulSet vs Deployment: Associated Service
- Microservices Patterns: Externalized Configurations
- Storing Configurations in the Environment
- Kubernetes Secrets and Environment Variables: Why?
- Kubernetes Secrets and Environment variables: How?
- Best Practices for Microservices: Health Checks
- Health Checks
- Liveness and Readiness Probes
- Types of Probes
- Implementing Probes
- Microservices Resource Management Strategies
- Resource Management and Risks: From Docker to Kubernetes
- Requests and limits
- CPU Resource Units
- Memory Resource Units
- Considerations When Setting Resource Requests and Limits
- Node Reserve Resources vs Allocatable Resources
- Quality of Service (QoS) Classes
- Guaranteed
- Burstable
- BestEffort
- QoS Class of a Pod
- Eviction Order
- PriorityClass: A Custom Class
- Autoscaling Microservices in Kubernetes: Introduction
- Best Practices for Microservices Scalability
- Use a Service Registry for Service Discovery
- Implement health checks
- Designing for scalability and other best practices
- Best Practices for Microservices Scalability
- Autoscaling Microservices in Kubernetes: Horizontal Autoscaling
- Horizontal Scaling
- Horizontal Pod Autoscaler
- Autoscaling Based on Custom Kubernetes Metrics
- Autoscaling Based on More Specific Custom Kubernetes Metrics
- Using Multiple Metrics
- Autoscaling Based on Custom Non-Kubernetes Metrics
- Cluster Autoscaler
- Autoscaling Microservices in Kubernetes: Vertical Scaling
- Vertical Scaling
- The Vertical Pod Autoscaler
- VPA Modes
- Auto
- Initial
- Recreate
- Off
- VPA Recommendations
- VPA Limitations
- Scaling Stateful Microservices: PostgreSQL as an Example
- StatefulSets and scaling
- Introduction to Stolon: PostgreSQL cloud native High Availability and more
- Stolon: Installation
- Stolon: Usage
- Microservices Deployment Strategies: One Service Per Node
- DaemonSet: Role and Use Cases
- DaemonSet: Creating and Managing
- Microservices Deployment Strategies: Assigning Workloads to Specific Nodes
- Assigning Your Workloads to Specific Nodes: Why?
- Taints and Tolerations
- Taints and Tolerations: The Definition
- Taints and Tolerations: An Example
- The nodeSelector: A Simple Method to Constrain Pods to Specific Nodes
- The Simplest Form of Node Affinity
- nodeSelector: An Example
- Node Affinity and Anti-Affinity
- Node Affinity: Like nodeSelector but with More Options
- Node Affinity: Example
- An Example of Node Anti-Affinity
- Affinity Weight
- Affinity and Anti-Affinity Types
- Kubernetes: Managing Infrastructure Upgrades and Maintenance Mode
- Why Do We Need to Upgrade Our Infrastructure?
- What to Upgrade?
- Upgrading Worker Nodes: Draining
- Upgrading Worker Nodes: Cordoning
- Upgrading Node Pools
- Zero-Downtime Upgrades: Pod Disruption Budgets
- Microservices Deployment Strategies: Managing Application Updates and Deployment
- Cloud Native Practices
- Deployment Strategies
- Blue/Green Deployment: Introduction
- Canary Deployment: Introduction
- Canary Deployment: An Example Using Istio
- Canary Deployment: Testing in Production
- Rolling Updates: Definition
- Rolling Updates: Example
- Microservices Observability in a Kubernetes World: Part I
- Introduction to Observability
- What is Monitoring?
- What is Observability and Why is it Important?
- White-Box Monitoring vs Black-Box Monitoring
- The Three Pillars of Observability
- Logs
- Metrics
- Tracing
- Observability Pillars in Action
- The Four Golden Signals of Monitoring
- Latency
- Traffic
- Errors
- Saturation
- Monitoring vs Observability: What’s the Difference?
- Microservices Observability in a Kubernetes World: Part II
- Introduction to Prometheus
- How Prometheus Works?
- Installing Prometheus
- Accessing Prometheus Web User Interface
- Metrics Available in Prometheus
- Using Grafana to Visualize Prometheus Metrics
- Promtail: Gathering Logs from Kubernetes Logs
- Loki Logging Stack
- Using Loki to Query Logs
- Using Jaeger and OpenTelemetry for Distributed Tracing
- GitOps: Cloud Native Continuous Delivery
- GitOps: Introduction and Definitions
- GitOps: Benefits and Drawbacks
- GitOps: Tools and Ecosystem
- GitOps: Example of a GitOps workflow using Argo CD
- Argo CD: Introduction
- Argo CD: Installation and Configuration
- Argo CD: Creating an Application
- Argo CD: Automated Synchronization and Self-Healing
- Argo CD: Roll Back
- Argo CD: The Declarative Way
- Argo CD: Configuration Management
- Argo CD: Managing Different Environments
- Argo CD: Deployment Hooks
- Introduction to Helm
- What is Helm?
- How to Install Helm
- What is a Chart?
- What is a Repository and How Dependencies Work?
- Installing a Chart
- Installing From a Specific Repository
- Using a Chart with a Custom Configuration
- Using a Chart with Custom Configurations
- Using a Chart with a Custom Configuration File (values.yaml)
- Installing a Chart from a Local Directory
- Installing a Chart from a Local Repository with a Custom Configuration File (values.yaml)
- Install a Chart from a Local Tarball
- Install a Chart in a Specific Namespace
- Dry Run
- Debug Mode
- The values.yaml File
- Upgrading a Chart
- Listing Releases
- Uninstalling a Chart
- Creating a Chart
- Creating GitOps Pipelines for Microservices - Part I
- Continuous Integration, Delivery, and Deployment of Microservices
- CI/CD Tools
- GitHub Actions
- Jenkins and Jenkins X
- Spinnaker
- Argo CD
- GitLab CI/CD
- Creating a CI/CD Pipeline for a Microservice
- Installing and Configuring Argo CD
- Creating the Microservice
- Creating a GitHub Repository for our Microservice
- Creating a Docker Hub account
- Setting up GitHub Actions
- Understanding and Using Helm charts
- Deploying Helm Charts Using Argo CD
- Upgrading and Deploying a New Version of the Application
- Creating GitOps Pipelines for Microservices - Part II
- Introduction
- What is Ansible?
- Prerequisites
- Automating Helm Values Creation for Multiple Environments Using Ansible
- Updating the Helm Chart Using Ansible
- Automating the Argo CD Application YAML File Generation Using Ansible
- Summary
- Afterword
- What’s next?
- Thank you
- About the author
- Join the community
- Feedback
- Cloud Native Microservices: How and Why
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them