Cloud Native Microservices With Kubernetes: A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

"Cloud Native Microservices With Kubernetes" is a hands-on, example-rich guide focused on real-world examples and practical learning that covers everything needed from the basics to the most advanced concepts. 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 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, and Argo CD. About This Book This book will guide you on a thrilling journey, revealing the nuances and potential of Kubernetes, the most popular container orchestration platform in the world. You'll discover how Kubernetes can be leveraged to build a robust, scalable, and resilient microservices architecture. "Cloud Native Microservices With Kubernetes" is a comprehensive guide that will navigate you through the intricacies of Kubernetes and help you leverage its full potential. It is designed to cater to a wide audience, from beginners who are making their first foray into Kubernetes to experienced professionals who wish to deepen their understanding of the platform and stay updated with its most recent advances. The chapters are structured sequentially to facilitate progressive learning. We start by exploring the different options to run Kubernetes locally and in the cloud. We will see how to use minikube, Rancher, and Terraform to provision a Kubernetes cluster in the cloud, and then we will use a cloud provider's managed Kubernetes service to provision a cluster. We will also explore the Cloud Native approach to software development and the basic components of Kubernetes before moving on to more complex topics such as resource management, autoscaling, and deploying various types of microservices. In this comprehensive guide, we will dive deep into the intricacies of microservices, high-availability strategies, CI/CD, 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, and more. Our exploration will include GitOps, with a focus on creating an efficient GitOps workflow using Argo CD. We will adeptly handle CI/CD (continuous delivery and deployment) strategies such as Blue/Green, Canary deployments, and Rolling updates. In addition, we will cover how to expertly manage data in Kubernetes using persistent volumes and stateful sets. We will navigate the creation of various types of services in Kubernetes and how to expose them to the outside world using Ingress and Service Mesh. The book focuses on achieving high availability, scalability, and efficient deployment, monitoring, CI/CD, and everything else you need to build your next microservices architecture. All of this can be done by leveraging the power of Kubernetes and its ecosystem. Each chapter of this guide includes examples and practical exercises designed to offer a hands-on experience. By working through these examples, you'll gain a practical understanding of Kubernetes concepts and their application in real-world scenarios. This book is designed to equip you with the knowledge and skills needed to build, manage, scale, deploy, and monitor your microservices on Kubernetes. By the end of this book, my goal is for Kubernetes to no longer seem like a daunting labyrinth. Instead, it will be a tool you are proficient in and can use to write your own success story. Enjoy the journey!

Author(s): Aymen El Amri
Publisher: Leanpub
Year: 2023

Language: English
Pages: 369

Cloud Native Microservices With Kubernetes
1 Cloud Native Microservices: How and Why
1.1 Common approaches
1.2 The twelve-factor app
1.2.1 I. Codebase
1.2.2 II. Dependencies
1.2.3 III. Config
1.2.4 IV. Backing services
1.2.5 V. Build, release, run
1.2.6 VI. Processes
1.2.7 VII. Port binding
1.2.8 VIII. Concurrency
1.2.9 IX. Disposability
1.2.10 X. Dev/prod parity
1.2.11 XI. Logs
1.2.12 XII. Admin processes
1.3 Microservices
1.3.1 Database per service
1.3.2 API Composition
1.3.3 Service instance per container
1.3.4 Externalized configuration
1.3.5 Server-side service discovery
1.3.6 Circuit breaker
1.3.7 Cloud native
1.4 From monolith to cloud native microservices
2 Requirements
2.1 A Development server
2.2 Install kubectl
3 Kubernetes: creating a cluster
3.1 Creating a development Kubernetes cluster using minikube
3.1.1 minikube installation
3.1.2 minikube creating a cluster
3.1.3 minikube profiles
3.1.4 K8s dashboard on minikube
3.1.5 Creating a Deployment
3.1.6 Kubernetes events
3.1.7 Exposing a deployment
3.1.8 Deleting K8s resources
3.1.9 minikube addons
3.1.10 Using Kubectl with minikube
3.1.11 Deleting clusters
3.2 Creating a development Kubernetes cluster using Rancher
3.2.1 Requirements
3.2.2 Using Terraform to launch the cluster
3.2.3 Creating Kubernetes resources using Rancher UI
3.3 Creating an on-premises Kubernetes cluster using Rancher
3.3.1 Requirements before starting
3.3.2 Creating a cluster using Rancher server
3.3.3 Notes about high availability
3.4 Creating an on-premises Kubernetes cluster: other options
3.5 Managed clusters
3.6 Creating a managed DOK cluster using Terraform
4 Kubernetes architecture overview
4.1 Introduction
4.2 The Control Plane
4.2.1 etcd
4.2.2 API Server (kube-apiserver)
4.2.3 Controller Manager (kube-controller-manager)
4.2.4 Cloud Controller Manager (cloud-controller-manager)
4.2.5 Scheduler (kube-scheduler)
4.3 Worker nodes
4.3.1 Kubelet
4.3.2 Container Runtime
4.3.3 Kube-proxy
4.4 Node pools
4.5 An overview of the architecture
5 Stateless and stateful microservices
5.1 Introduction
5.2 Stateless workloads
5.3 Stateful workloads
6 Deploying Stateless Microservices: Introduction
6.1 Requirements
6.2 Creating a Namespace
6.3 Creating the Deployment
6.4 Examining Pods and Deployments
6.5 Accessing Pods
6.6 Exposing a Deployment
6.6.1 ClusterIP Service
6.6.2 NodePort Service
6.6.3 LoadBalancer Service
6.6.4 Headless Service
6.6.5 Ingress Service
7 Deploying Stateful Microservices: Persisting Data in Kubernetes
7.1 Requirements
7.2 Creating a Namespace
7.3 Creating a ConfigMap for the PostgreSQL database
7.3.1 What is a ConfigMap?
7.3.2 ConfigMap for PostgreSQL
7.4 Persisting data storage on PostgreSQL
7.4.1 Kubernetes Volumes
7.4.2 VolumeClaims
7.4.3 StorageClass
7.4.4 Adding storage to PostgreSQL
7.4.5 Creating a Deployment for PostgreSQL
7.4.6 Creating a Service for PostgreSQL
7.4.7 Creating a Deployment for our application
7.4.8 Creating a Service for our application
7.4.9 Creating an external Service for our application
7.4.10 Creating an Ingress for our application
7.5 Checking logs and making sure everything is working
7.6 Summary
8 Deploying Stateful Microservices: StatefulSets
8.1 What is a StatefulSet?
8.2 StatefulSet vs Deployment
8.3 Creating a StatefulSet
8.4 Creating a Service for the StatefulSet
8.5 Post deployment tasks
8.6 StatefulSet vs Deployment: persistent storage
8.7 StatefulSet vs Deployment: associated service
9 Microservices Patterns: Externalized Configurations
9.1 Storing configurations in the environment
9.2 Kubernetes Secrets and environment variables: why?
9.3 Kubernetes Secrets and environment variables: how?
10 Best Practices for Microservices: Health Checks
10.1 Health Checks
10.2 Liveness and Readiness probes
10.3 Types of probes
10.4 Implementing probes
11 Microservices Resource Management Strategies
11.1 Resource management and risks: from Docker to Kubernetes
11.2 Requests and limits
11.3 CPU resource units
11.4 Memory resource units
11.5 Considerations when setting resource requests and limits
11.6 Node reserve resources vs allocatable resources
11.7 Quality of Service (QoS) classes
11.7.1 Guaranteed
11.7.2 Burstable
11.7.3 BestEffort
11.7.4 QoS class of a Pod
11.7.5 Eviction order
11.7.6 PriorityClass: a custom class
12 Autoscaling Microservices in Kubernetes: Introduction
12.1 Best practices for microservices scalability
12.1.1 Use a service registry for service discovery
12.1.2 Implement health checks
12.1.3 Designing for scalability and other best practices
13 Autoscaling Microservices in Kubernetes: Horizontal Autoscaling
13.1 Horizontal scaling
13.2 Horizontal Pod Autoscaler
13.3 Autoscaling based on custom Kubernetes metrics
13.4 Autoscaling based on more specific custom Kubernetes metrics
13.5 Using multiple metrics
13.6 Autoscaling based on custom non-Kubernetes metrics
13.7 Cluster autoscaler
14 Autoscaling Microservices in Kubernetes: Vertical Scaling
14.1 Vertical Scaling
14.2 Vertical Pod Autoscaler
14.3 VPA modes
14.3.1 Auto
14.3.2 Initial
14.3.3 Recreate
14.3.4 Off
14.4 VPA recommendations
14.4.1 VPA Limitations
15 Scaling Stateful Microservices: PostgreSQL as an Example
15.1 StatefulSets and scaling
15.2 Stolon: introduction
15.3 Stolon: installation
15.4 Stolon: usage
16 Microservices Deployment Strategies: One Service Per Node
16.1 DaemonSet: role and use cases
16.2 DaemonSet: creating and managing
17 Microservices Deployment Strategies: Assigning Workloads to Specific Nodes
17.1 Assigning your workloads to specific nodes: why?
17.2 Taints and Tolerations
17.2.1 Taints and Tolerations: definition
17.2.2 Taints and Tolerations: example
17.3 nodeSelector
17.3.1 The simplest form of node affinity
17.3.2 nodeSelector: example
17.4 Node affinity and anti-affinity
17.4.1 Node affinity: like nodeSelector but with more options
17.4.2 Node affinity: example
17.4.3 Node anti-affinity: example
17.4.4 Affinity weight
17.4.5 Affinity and anti-affinity types
18 Kubernetes: Managing Infrastructure Upgrades and Maintenance Mode
18.1 Why do we need to upgrade our infrastructure?
18.2 What to upgrade?
18.3 Upgrading worker nodes: draining
18.4 Upgrading worker nodes: cordoning
18.5 Upgrading Node Pools
18.6 Zero downtime upgrades: Pod Disruption Budgets
19 Microservices Deployment Strategies: Managing Application Updates and Deployment
19.1 Cloud Native practices
19.2 Deployment strategies
19.2.1 Blue/Green deployment: introduction
19.2.2 Canary deployment: introduction
19.2.3 Canary deployment: an example using Istio
19.2.4 Canary Deployment: testing in production
19.3 Rolling updates: definition
19.3.1 Rolling updates: example
20 Microservices Observability in a Kubernetes World: Introduction
20.1 Introduction to observability
20.2 What is monitoring?
20.3 What is observability?
20.4 White-box monitoring vs black-box monitoring
20.5 Pillars of observability
20.5.1 Logs
20.5.2 Metrics
20.5.3 Tracing
20.5.4 Observability pillars in action
20.6 Four golden signals of monitoring
20.6.1 Latency
20.6.2 Traffic
20.6.3 Errors
20.6.4 Saturation
20.7 Monitoring vs Observability: what’s the difference?
21 Microservices Observability in a Kubernetes World: Prometheus, Grafana, Loki, Promtail, OpenTelemetry, and Jaeger
21.1 Introduction to Prometheus
21.2 How Prometheus works
21.3 Installing Prometheus
21.4 Accessing Prometheus web UI
21.5 Metrics available in Prometheus
21.6 Using Grafana to visualize Prometheus metrics
21.7 Promtail: Gathering logs from Kubernetes logs
21.8 Loki logging stack
21.9 Using Loki to query logs
21.10 Using Jaeger and OpenTelemetry for distributed tracing
22 GitOps: Cloud Native Continuous Delivery
22.1 GitOps: introduction and definitions
22.2 GitOps: benefits and drawbacks
22.3 GitOps: tools
23 GitOps: Example of a GitOps workflow using Argo CD
23.1 Argo CD: introduction
23.2 Argo CD: installation and configuration
23.3 Argo CD: creating an application
23.4 Argo CD: automatic synchronization and self-healing
23.5 Argo CD: rollback
23.6 Argo CD the declarative way
23.7 Argo CD: configuration management
23.8 Argo CD: managing different environments
23.9 Argo CD: deployment hooks
24 Creating CI/CD Pipelines for Microservices
24.1 Continuous integration, delivery, and deployment of microservices
24.2 CI/CD tools
24.2.1 Jenkins
24.2.2 Spinnaker
24.2.3 Argo CD
24.2.4 GitHub Actions
24.2.5 GitLab CI/CD
24.3 Creating a CI/CD pipeline for a microservice
24.3.1 Install and configure Argo CD
24.3.2 Create a GitHub repository for our microservice
24.3.3 Create a Docker Hub account
24.3.4 Setting up GitHub Actions
24.3.5 Create a Helm chart
24.3.6 Create an Argo CD Application
24.3.7 Automating the deployment of new versions
25 Afterword
25.1 What’s next?
25.2 Thank you
25.3 About the author
25.4 Join the community
25.5 Feedback