Foreword to the Second Edition |
|
xvii | |
Foreword to the First Edition |
|
xix | |
Preface |
|
xxi | |
1 Revolution in the Cloud |
|
1 | (20) |
|
The Creation of the Cloud |
|
|
2 | (1) |
|
|
3 | (1) |
|
Infrastructure as a Service |
|
|
3 | (1) |
|
|
3 | (4) |
|
|
4 | (1) |
|
|
4 | (2) |
|
|
6 | (1) |
|
|
6 | (1) |
|
|
7 | (3) |
|
|
7 | (1) |
|
|
7 | (1) |
|
Putting Software in Containers |
|
|
8 | (1) |
|
Plug and Play Applications |
|
|
9 | (1) |
|
Conducting the Container Orchestra |
|
|
10 | (1) |
|
|
11 | (4) |
|
|
11 | (1) |
|
|
11 | (2) |
|
Will Kubernetes Disappear? |
|
|
13 | (1) |
|
Kubernetes Is Not a Panacea |
|
|
14 | (1) |
|
|
15 | (2) |
|
|
17 | (2) |
|
|
18 | (1) |
|
Some Things Will Remain Centralized |
|
|
18 | (1) |
|
Developer Productivity Engineering |
|
|
18 | (1) |
|
|
19 | (1) |
|
|
19 | (2) |
2 First Steps with Kubernetes |
|
21 | (12) |
|
Running Your First Container |
|
|
21 | (2) |
|
Installing Docker Desktop |
|
|
22 | (1) |
|
|
22 | (1) |
|
Running a Container Image |
|
|
23 | (1) |
|
|
23 | (2) |
|
Looking at the Source Code |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
25 | (3) |
|
Understanding Dockerfiles |
|
|
26 | (1) |
|
|
26 | (1) |
|
Running Docker Image Build |
|
|
27 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
|
28 | (1) |
|
Authenticating to the Registry |
|
|
29 | (1) |
|
Naming and Pushing Your Image |
|
|
29 | (1) |
|
|
29 | (1) |
|
|
29 | (2) |
|
|
30 | (1) |
|
If the Container Doesn't Start |
|
|
31 | (1) |
|
|
31 | (1) |
|
|
31 | (2) |
3 Getting Kubernetes |
|
33 | (20) |
|
|
33 | (4) |
|
|
34 | (1) |
|
|
35 | (1) |
|
|
35 | (2) |
|
The Costs of Self-Hosting Kubernetes |
|
|
37 | (4) |
|
It's More Work Than You Think |
|
|
37 | (1) |
|
It's Not Just About the Initial Setup |
|
|
38 | (1) |
|
Tools Don't Do All the Work for You |
|
|
39 | (1) |
|
|
39 | (1) |
|
|
39 | (1) |
|
|
39 | (1) |
|
Start with Managed Services |
|
|
40 | (1) |
|
Managed Kubernetes Services |
|
|
41 | (2) |
|
Google Kubernetes Engine (GKE) |
|
|
41 | (1) |
|
|
41 | (1) |
|
|
41 | (1) |
|
Amazon Elastic Kubernetes Service (EKS) |
|
|
42 | (1) |
|
Azure Kubernetes Service (AKS) |
|
|
42 | (1) |
|
IBM Cloud Kubernetes Service |
|
|
43 | (1) |
|
|
43 | (1) |
|
|
43 | (2) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
44 | (1) |
|
Rancher Kubernetes Engine (RKE) |
|
|
44 | (1) |
|
|
44 | (1) |
|
Buy or Build: Our Recommendations |
|
|
45 | (4) |
|
|
45 | (1) |
|
Use Managed Kubernetes if You Can |
|
|
45 | (1) |
|
But What About Vendor Lock-in? |
|
|
46 | (1) |
|
|
46 | (1) |
|
Multicloud Kubernetes Clusters |
|
|
47 | (1) |
|
|
48 | (1) |
|
|
48 | (1) |
|
Use Standard Kubernetes Self-Hosting Tools if You Must |
|
|
48 | (1) |
|
Clusterless Container Services |
|
|
49 | (1) |
|
|
49 | (1) |
|
Azure Container Instances (ACI) |
|
|
49 | (1) |
|
|
50 | (1) |
|
|
50 | (3) |
4 Working with Kubernetes Objects |
|
53 | (16) |
|
|
53 | (2) |
|
Supervising and Scheduling |
|
|
54 | (1) |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
55 | (1) |
|
|
56 | (1) |
|
Maintaining Desired State |
|
|
57 | (1) |
|
|
58 | (1) |
|
Resource Manifests in YAML Format |
|
|
59 | (5) |
|
|
59 | (1) |
|
|
59 | (1) |
|
|
60 | (1) |
|
|
61 | (2) |
|
Querying the Cluster with kubectl |
|
|
63 | (1) |
|
Taking Resources to the Next Level |
|
|
64 | (1) |
|
Helm: A Kubernetes Package Manager |
|
|
64 | (3) |
|
|
65 | (1) |
|
|
65 | (1) |
|
Charts, Repositories, and Releases |
|
|
66 | (1) |
|
|
67 | (1) |
|
|
67 | (2) |
5 Managing Resources |
|
69 | (28) |
|
|
69 | (3) |
|
|
70 | (1) |
|
|
70 | (1) |
|
|
71 | (1) |
|
|
71 | (1) |
|
Managing the Container Life Cycle |
|
|
72 | (6) |
|
|
72 | (1) |
|
Probe Delay and Frequency |
|
|
73 | (1) |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
75 | (1) |
|
File-Based Readiness Probes |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
77 | (1) |
|
|
78 | (5) |
|
|
79 | (1) |
|
What Namespaces Should I Use? |
|
|
79 | (1) |
|
|
80 | (1) |
|
|
80 | (2) |
|
Default Resource Requests and Limits |
|
|
82 | (1) |
|
|
83 | (11) |
|
|
83 | (1) |
|
|
83 | (1) |
|
|
84 | (1) |
|
|
85 | (1) |
|
|
85 | (2) |
|
|
87 | (1) |
|
Cleaning Up Unused Resources |
|
|
87 | (3) |
|
|
90 | (1) |
|
|
90 | (1) |
|
Using Preemptible (Spot) Instances |
|
|
91 | (2) |
|
Keeping Your Workloads Balanced |
|
|
93 | (1) |
|
|
94 | (3) |
6 Operating Clusters |
|
97 | (16) |
|
Cluster Sizing and Scaling |
|
|
97 | (7) |
|
|
98 | (3) |
|
|
101 | (2) |
|
|
103 | (1) |
|
|
104 | (4) |
|
|
105 | (1) |
|
Conformance Testing with Sonobuoy |
|
|
106 | (2) |
|
|
108 | (1) |
|
|
108 | (3) |
|
Only Production Is Production |
|
|
109 | (1) |
|
|
109 | (1) |
|
|
110 | (1) |
|
|
110 | (1) |
|
|
111 | (2) |
7 Kubernetes Power Tools |
|
113 | (22) |
|
|
113 | (5) |
|
|
113 | (1) |
|
|
114 | (1) |
|
Abbreviating Resource Types |
|
|
114 | (1) |
|
Auto-Completing kubectl Commands |
|
|
115 | (1) |
|
|
115 | (1) |
|
Getting Help on Kubernetes Resources |
|
|
116 | (1) |
|
Showing More Detailed Output |
|
|
116 | (1) |
|
Working with JSON Data and jq |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
118 | (3) |
|
Imperative kubectl Commands |
|
|
118 | (1) |
|
When Not to Use Imperative Commands |
|
|
119 | (1) |
|
Generating Resource Manifests |
|
|
120 | (1) |
|
|
120 | (1) |
|
|
120 | (1) |
|
|
121 | (6) |
|
Viewing a Container's Logs |
|
|
121 | (1) |
|
|
122 | (1) |
|
Watching Kubernetes Resources with kubespy |
|
|
123 | (1) |
|
Forwarding a Container Port |
|
|
123 | (1) |
|
Executing Commands on Containers |
|
|
123 | (1) |
|
Running Containers for Troubleshooting |
|
|
124 | (1) |
|
|
125 | (1) |
|
Adding BusyBox to Your Containers |
|
|
126 | (1) |
|
Installing Programs on a Container |
|
|
127 | (1) |
|
|
127 | (3) |
|
|
128 | (1) |
|
|
129 | (1) |
|
|
130 | (1) |
|
Kubernetes Shells and Tools |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
131 | (1) |
|
|
131 | (1) |
|
|
131 | (1) |
|
|
132 | (1) |
|
VS Code Kubernetes Extension |
|
|
132 | (1) |
|
Building Your Own Kubernetes Tools |
|
|
132 | (1) |
|
|
133 | (2) |
8 Running Containers |
|
135 | (20) |
|
|
135 | (4) |
|
|
136 | (1) |
|
Container Runtimes in Kubernetes |
|
|
137 | (1) |
|
What Belongs in a Container? |
|
|
137 | (1) |
|
|
138 | (1) |
|
|
139 | (5) |
|
|
139 | (1) |
|
|
140 | (1) |
|
|
141 | (1) |
|
|
141 | (1) |
|
|
142 | (1) |
|
Resource Requests and Limits |
|
|
142 | (1) |
|
|
143 | (1) |
|
|
143 | (1) |
|
|
144 | (4) |
|
Running Containers as a Non-Root User |
|
|
144 | (1) |
|
|
145 | (1) |
|
Setting a Read-Only Filesystem |
|
|
146 | (1) |
|
Disabling Privilege Escalation |
|
|
146 | (1) |
|
|
146 | (2) |
|
|
148 | (1) |
|
|
148 | (1) |
|
|
148 | (3) |
|
|
149 | (1) |
|
|
150 | (1) |
|
|
151 | (1) |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
152 | (3) |
9 Managing Pods |
|
155 | (26) |
|
|
155 | (4) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
157 | (1) |
|
|
158 | (1) |
|
|
159 | (1) |
|
|
159 | (2) |
|
|
160 | (1) |
|
|
160 | (1) |
|
Pod Affinities and Anti-Affinities |
|
|
161 | (3) |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
163 | (1) |
|
When to Use Pod Affinities |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
165 | (8) |
|
|
166 | (1) |
|
|
167 | (1) |
|
|
168 | (1) |
|
|
169 | (1) |
|
Horizontal Pod Autoscalers |
|
|
170 | (2) |
|
Operators and Custom Resource Definitions (CRDs) |
|
|
172 | (1) |
|
|
173 | (3) |
|
|
174 | (1) |
|
|
175 | (1) |
|
Terminating TLS with Ingress |
|
|
176 | (1) |
|
|
176 | (2) |
|
|
177 | (1) |
|
|
177 | (1) |
|
|
177 | (1) |
|
|
177 | (1) |
|
|
178 | (3) |
10 Configuration and Secrets |
|
181 | (18) |
|
|
181 | (8) |
|
|
182 | (1) |
|
Setting Environment Variables from ConfigMaps |
|
|
183 | (2) |
|
Setting the Whole Environment from a ConfigMap |
|
|
185 | (1) |
|
Using Environment Variables in Command Arguments |
|
|
186 | (1) |
|
Creating Config Files from ConfigMaps |
|
|
187 | (1) |
|
Updating Pods on a Config Change |
|
|
188 | (1) |
|
|
189 | (4) |
|
Using Secrets as Environment Variables |
|
|
189 | (1) |
|
|
190 | (1) |
|
|
191 | (1) |
|
|
192 | (1) |
|
|
192 | (1) |
|
Keeping Secrets and ConfigMaps |
|
|
192 | (1) |
|
Secrets Management Strategies |
|
|
193 | (2) |
|
Encrypt Secrets in Version Control |
|
|
193 | (1) |
|
Use a Dedicated Secrets Management Tool |
|
|
194 | (1) |
|
Encrypting Secrets with Sops |
|
|
195 | (2) |
|
Encrypting a File with Sops |
|
|
195 | (2) |
|
|
197 | (1) |
|
|
197 | (1) |
|
|
198 | (1) |
11 Security, Backups, and Cluster Health |
|
199 | (22) |
|
Access Control and Permissions |
|
|
199 | (6) |
|
Managing Access by Cluster |
|
|
199 | (1) |
|
Introducing Role-Based Access Control (RBAC) |
|
|
200 | (1) |
|
|
201 | (1) |
|
|
201 | (1) |
|
|
202 | (1) |
|
Guard Access to cluster-admin |
|
|
202 | (1) |
|
Applications and Deployment |
|
|
203 | (1) |
|
|
204 | (1) |
|
Cluster Security Scanning |
|
|
205 | (1) |
|
|
205 | (1) |
|
|
205 | (1) |
|
|
206 | (1) |
|
Container Security Scanning |
|
|
206 | (2) |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
207 | (1) |
|
|
207 | (1) |
|
|
208 | (6) |
|
Do I Need to Back Up Kubernetes? |
|
|
209 | (1) |
|
|
209 | (1) |
|
Backing Up Resource State |
|
|
210 | (1) |
|
|
210 | (1) |
|
Large and Small Disasters |
|
|
211 | (1) |
|
|
211 | (3) |
|
Monitoring Cluster Status |
|
|
214 | (4) |
|
|
214 | (2) |
|
CPU and Memory Utilization |
|
|
216 | (1) |
|
|
216 | (1) |
|
|
217 | (1) |
|
|
218 | (1) |
|
|
218 | (1) |
|
|
218 | (1) |
|
|
218 | (1) |
|
|
219 | (2) |
12 Deploying Kubernetes Applications |
|
221 | (18) |
|
Building Manifests with Helm |
|
|
221 | (5) |
|
What's Inside a Helm Chart? |
|
|
222 | (1) |
|
|
223 | (1) |
|
|
224 | (1) |
|
Quoting Values in Templates |
|
|
225 | (1) |
|
|
225 | (1) |
|
|
226 | (5) |
|
|
226 | (1) |
|
Specifying Values in a Helm Release |
|
|
227 | (1) |
|
Updating an App with Helm |
|
|
227 | (1) |
|
Rolling Back to Previous Versions |
|
|
228 | (1) |
|
Creating a Helm Chart Repo |
|
|
228 | (1) |
|
Managing Helm Chart Secrets with Sops |
|
|
229 | (2) |
|
Managing Multiple Charts with Helmfile |
|
|
231 | (3) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (1) |
|
Advanced Manifest Management Tools |
|
|
234 | (4) |
|
|
234 | (1) |
|
|
235 | (1) |
|
|
236 | (1) |
|
|
236 | (1) |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (1) |
13 Development Workflow |
|
239 | (14) |
|
|
239 | (5) |
|
|
239 | (2) |
|
|
241 | (1) |
|
|
241 | (1) |
|
|
242 | (1) |
|
|
242 | (1) |
|
|
242 | (2) |
|
|
244 | (4) |
|
|
244 | (1) |
|
|
245 | (1) |
|
maxSurge and maxUnavailable |
|
|
245 | (1) |
|
|
246 | (1) |
|
|
247 | (1) |
|
|
247 | (1) |
|
Handling Migrations with Helm |
|
|
248 | (2) |
|
|
248 | (1) |
|
|
249 | (1) |
|
|
249 | (1) |
|
|
250 | (1) |
|
|
250 | (3) |
14 Continuous Deployment in Kubernetes |
|
253 | (18) |
|
What Is Continuous Deployment? |
|
|
253 | (1) |
|
Which CD Tool Should I Use? |
|
|
254 | (1) |
|
|
254 | (2) |
|
|
255 | (1) |
|
|
255 | (1) |
|
|
255 | (1) |
|
|
255 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
256 | (1) |
|
|
257 | (1) |
|
|
257 | (1) |
|
|
257 | (1) |
|
A CI/CD Pipeline with Cloud Build |
|
|
257 | (9) |
|
Setting Up Google Cloud and GKE |
|
|
258 | (1) |
|
Forking the Demo Repository |
|
|
258 | (1) |
|
Create Artifact Registry Container Repository |
|
|
258 | (1) |
|
|
259 | (1) |
|
Building the Test Container |
|
|
259 | (1) |
|
|
260 | (1) |
|
Building the Application Container |
|
|
260 | (1) |
|
|
261 | (1) |
|
|
261 | (1) |
|
Validating the Kubernetes Manifests |
|
|
261 | (1) |
|
|
262 | (1) |
|
Creating the First Build Trigger |
|
|
262 | (1) |
|
|
263 | (1) |
|
Deploying from a Cl/CD Pipeline |
|
|
263 | (2) |
|
Creating a Deploy Trigger |
|
|
265 | (1) |
|
Adapting the Example Pipeline |
|
|
266 | (1) |
|
|
266 | (3) |
|
|
266 | (3) |
|
|
269 | (2) |
15 Observability and Monitoring |
|
271 | (14) |
|
|
271 | (8) |
|
|
271 | (1) |
|
|
271 | (2) |
|
|
273 | (1) |
|
|
274 | (2) |
|
|
276 | (1) |
|
|
277 | (1) |
|
|
278 | (1) |
|
The Observability Pipeline |
|
|
279 | (1) |
|
|
280 | (4) |
|
External Closed-Box Checks |
|
|
280 | (2) |
|
|
282 | (2) |
|
|
284 | (1) |
16 Metrics in Kubernetes |
|
285 | (28) |
|
What Are Metrics, Really? |
|
|
285 | (2) |
|
|
285 | (1) |
|
|
286 | (1) |
|
What Can Metrics Tell Us? |
|
|
287 | (1) |
|
|
287 | (7) |
|
Services: The RED Pattern |
|
|
288 | (1) |
|
Resources: The USE Pattern |
|
|
289 | (1) |
|
|
290 | (1) |
|
|
291 | (3) |
|
|
294 | (5) |
|
What's Wrong with a Simple Average? |
|
|
295 | (1) |
|
Means, Medians, and Outliers |
|
|
295 | (1) |
|
|
296 | (1) |
|
Applying Percentiles to Metrics Data |
|
|
296 | (2) |
|
We Usually Want to Know the Worst |
|
|
298 | (1) |
|
|
298 | (1) |
|
Graphing Metrics with Dashboards |
|
|
299 | (4) |
|
Use a Standard Layout for All Services |
|
|
299 | (1) |
|
Build an Information Radiator with Primary Dashboards |
|
|
300 | (1) |
|
Dashboard Things That Break |
|
|
301 | (2) |
|
|
303 | (3) |
|
What's Wrong with Alerts? |
|
|
303 | (1) |
|
On-Call Should Not Be Hell |
|
|
304 | (1) |
|
Urgent, Important, and Actionable Alerts |
|
|
304 | (1) |
|
Track Your Alerts, Out-of-Hours Pages, and Wake-Ups |
|
|
305 | (1) |
|
Metrics Tools and Services |
|
|
306 | (5) |
|
|
306 | (2) |
|
|
308 | (1) |
|
|
309 | (1) |
|
|
309 | (1) |
|
|
309 | (1) |
|
|
310 | (1) |
|
|
311 | (2) |
Afterword |
|
313 | (4) |
Index |
|
317 | |