Table of Contents
Preface xi
1 Introduction: Why Cloud Native? 1
The Journey to the Cloud 1
Challenges in the Cloud 2
Cloud Native Computing Foundation 4
Adopting a Cloud Native Infrastructure with Azure 4
Summary 5
2 Infrastructure as Code: Setting Up the Gateway 7
Infrastructure as Code and Its Importance in the Cloud Native World 8
Getting Started with Azure and Setting Up the Environment 11
Azure Fundamentals and Preparing Your Azure Environment 11
Creating an Azure Account 12
Installing the Azure CLI 13
Prominent IaC Tools 13
Terraform 14
Packer 29
Ansible 31
Azure DevOps and Infrastructure as Code 33
Summary 33
3 Containerizing Your Application: More Than Boxes 35
Why Containers? 35
Isolation 36
Security 36
Packaging and Deployment 37
Basic Container Primitives 37
Cgroups 38
Namespaces 39
Copy on Write 40
Capabilities 40
Seccomp-BPF 40
Components of Running a Container 40
Container Orchestrators 41
Container Software 41
Container Runtimes 42
Containers 43
Operating System 43
Open Container Initiative (OCI) Specification 43
OCI Image Specification 44
OCI Runtime Specification 45
Docker 46
Building Your First Docker Image 46
Best Practices While Using Docker 48
Other Container Platforms 49
Kata Containers 49
LXC and LXD 50
Container Registries 50
Securely Storing Images with Harbor 51
Securely Storing Images with Azure Container Registry 55
Storing Docker Images in a Registry 59
Running Docker on Azure 60
Azure Container Instances 60
Deploying an Azure Container Instance 61
Running a Docker Container Engine 65
Summary 66
4 Kubernetes: The Grand Orchestrator 67
Kubernetes Components 69
Control Plane 70
Worker Nodes 71
Kubernetes API Server Objects 72
Pods 72
ReplicaSets 73
Deployments 73
Services 73
Namespaces 74
Labels and Selectors 74
Annotations 74
Ingress Controller 74
StatefulSets 75
DaemonSets 75
Jobs 75
Observe, Operate, and Manage Kubernetes Clusters with kubectl 76
General Cluster Information and Commands 76
Managing Pods 78
Kubernetes in Production 85
Summary 98
5 Creating a Kubernetes Cluster in Azure 99
Creating a Kubernetes Cluster from Scratch 99
Creating the Resource Group 100
Creating the Machine Images for the Worker and Controller Machines 100
Creating a Storage Account Backend 101
Creating an Azure Virtual Network 102
Creating Public IPs for the Load Balancer 102
Creating Worker and Controller Instances 104
Using Ansible to Deploy and Configure the Kubernetes Controller Nodes 106
Using Ansible to Deploy and Configure the Kubernetes Worker Nodes 109
Setting Up Pod Networking and Routing 109
Generating the kubeconfig File for Remote Access and Cluster Validation 110
Azure Kubernetes Service 111
Deploying Applications and Services Using Helm: A Package Manager for Kubernetes 113
Helm Basics 114
Installing and Managing Helm 114
Managing Helm Releases 117
Creating Charts for Your Applications 118
Summary 120
6 Observability: Following the Breadcrumbs 121
Introduction to Observability 121
Observability: More Than Three Pillars 122
Observability: A Superset of Monitoring 123
Observability-Driven Development 124
Monitoring Metrics with Prometheus in a Cloud Native World 125
Prometheus Components and Architecture 125
Installing and Configuring Prometheus 127
Node_exporter 129
Instrumentation of Applications 130
Finding Hosts 134
Prometheus on Kubernetes 135
Logging in the Cloud Native World 138
Logging with Fluentd 138
Fluentd on Kubernetes 146
Distributed Tracing in the Cloud Native World 150
Tracing: Key Concepts 151
General Tracing System Architecture and Trace Assembly 153
Tracing Standards, Tools, and Code Instrumentation 154
Azure Monitor 159
Summary 161
7 Service Discovery and Service Mesh: Finding New Territories and Crossing Borders 163
Service Discovery 164
Introduction to CoreDNS 165
Installing and Configuring CoreDNS 167
Kubernetes Service Discovery with CoreDNS 169
Azure DNS 171
The Service Mesh 172
Introduction to Istio 174
Installing Istio on Azure Kubernetes Service 175
Automatically Injecting the Sidecar Proxy (Envoy Proxy) 177
Managing Istio Service Meshes Using Kiali 179
Summary 187
8 Networking and Policy Management: Behold the Gatekeepers 189
The Container Network Interface (CNI) 190
Why Would You Use a CNI? 191
How Does CNI Work with Azure? 191
Various CNI Projects 192
Calico 193
Why Would You Use Calico? 193
Basic Architecture 194
Deploying Calico 195
A Calico Deep Dive 197
Implementing Calico Security Policy 198
Cilium 200
Deploying Cilium 201
Integrating Cilium with Your Cloud 204
Flannel 207
Deploying Flannel 207
A Flannel Deep Dive 208
Azure Policy 210
Azure Policy Quickstart 210
Creating Your Own Azure Policy 212
Azure Policy for Kubernetes 213
Open Policy Agent 214
Deploying OPA on Kubernetes 215
Deploying Policy with OPA 216
Summary 218
9 Distributed Databases and Storage: The Central Bank 219
The Need for Distributed Databases in Cloud Native Architecture 219
Azure Storage and Database Options 220
Introduction to Vitess: Distributed and Sharded MySQL 221
Why Run Vitess? 221
The Vitess Architecture 222
Deploying Vitess on Kubernetes 223
Introduction to Rook: Storage Orchestrator for Kubernetes 224
The Rook Architecture 224
Deploying Rook on Kubernetes 225
Introduction to TiKV 226
Why Use TiKV? 226
The TiKV Architecture 226
Deploying TiKV on Kubernetes 228
More on etcd 229
Hardware Platform 230
Autoscaling and Auto-remediation 230
Availability and Security 231
Summary 231
10 Getting the Message 233
The Need for Messaging 233
A Sample Messaging Use Case: Log Ingestion and Analytics 235
Generation 1: Without Queues 235
Generation 2: With Cloud Queues and Object Storage 236
Generation 3: With Memory-Based Pub/Sub Queuing 237
The Basics of Messaging Platforms 238
Messaging Versus Streaming 238
Messaging Fundamentals 238
Producers and Consumers 239
Brokers and Clustering 240
Durability and Persistence 241
Message Delivery 241
Security 242
Common Messaging Patterns 242
Simple Queue 242
Publish and Subscribe 242
Durable Queue 242
An Overview of Popular Cloud Native Messaging Platforms 243
RabbitMQ 243
Apache Kafka 243
CNCF CloudEvents 244
Cloud Messaging Deep Dive with NATS 244
NATS Protocol Architecture 244
NATS Persistence with JetStream 249
NATS Security 249
Deploying NATS on Kubernetes 251
Azure Messaging Services 253
Azure Service Bus 253
Azure Event Hubs 258
Azure Event Grid 261
Summary 263
11 Serverless 265
Introduction to Serverless Computing 265
What Is Serverless? 265
What Is a Serverless Function? 266
The Serverless Landscape 266
Benefits of Serverless 267
Potential Downsides of Serverless 268
Azure Function Apps 268
Function App Architecture 269
Creating a Function App 270
Knative 272
Knative Architecture 272
Installing and Running Knative Serving on Kubernetes 272
Installing and Running Knative Eventing on Kubernetes 274
KEDA 276
KEDA Architecture 276
Installing KEDA on Kubernetes 277
OpenFaaS 281
OpenFaaS Architecture 281
Installing OpenFaaS 281
Writing Your First OpenFaaS Function 282
Summary 283
12 Conclusion 285
What's Next? 287
Index 289