
Learn Docker/Kubernetes container development and operation from the beginning.
Description
Book Introduction
A Complete Guide to Docker/Kubernetes Container Technology for Practical Application Development and Operation
This is a practical introductory book that summarizes the core of container technology using Docker and Kubernetes.
It is structured so that you can learn step by step, starting from the concept of container virtualization technology, Docker-based application deployment and image creation, network configuration, and the orchestration system Kubernetes.
This book has been fully revised and expanded since its first edition to reflect the latest changes in the ecosystem. It contains the author's extensive experience in container development and practical case studies, making it useful for everyone from beginners to intermediate users.
This is a practical introductory book that summarizes the core of container technology using Docker and Kubernetes.
It is structured so that you can learn step by step, starting from the concept of container virtualization technology, Docker-based application deployment and image creation, network configuration, and the orchestration system Kubernetes.
This book has been fully revised and expanded since its first edition to reflect the latest changes in the ecosystem. It contains the author's extensive experience in container development and practical case studies, making it useful for everyone from beginners to intermediate users.
- You can preview some of the book's contents.
Preview
index
Translator's Preface xiii
Beta Reader Review xiv
Beginning xvi
Acknowledgments xviii
CHAPTER 1 Containers and Docker Basics 1
1.1 What is a container? 1
__1.1.1 Containerized Virtualization 2
__1.1.2 Container Use Case 3
5 Disadvantages of COLUMN Containers
1.2 What is Docker? 5
__1.2.1 History of Docker and Docker, Inc. 6
__1.2.2 Docker 7 Focused on Application Deployment
__1.2.3 Docker Access 8
COLUMN Moby Project 11
1.3 Why Use Containers? 11
__1.3.1 Ensuring reproducibility through immutable applications and execution environments 12
COLUMN Cloud IaC and Immutable Infrastructure 15
COLUMN Container Technology and Serverless Platforms 16
__1.3.2 Ease of Application Configuration Management 16
__1.3.3 High portability regardless of environment 18
__1.3.4 Efficiency of Container-Based Development 20
1.4 Building a Local Container Execution Environment 20
__1.4.1 Installing Docker Desktop 21
COLUMN ARM Architecture 24
__1.4.2 Docker Desktop Setup 25
__1.4.3 Docker Desktop Troubleshooting 30
COLUMN Linux Environment Installation 32
COLUMN Docker Subscription Plan 32
CHAPTER 2 CONTAINER DEPLOYMENT 33
2.1 Running Applications in Containers 33
__2.1.1 Container Images and Container Basics 34
2.2 Creating a Simple Application and Container Image 37
__2.2.1 Dockerfile Instruction 39
Overwrite 40 when executing COLUMN CMD
Learn how to execute commands with COLUMN ENTRYPOINT 42
COLUMN Other Instructions in the Dockerfile 44
COLUMN CMD Specification Method 45
__2.2.2 Running a Container 45
COLUMN Short Docker Commands 46
2.3 Handling Images 48
__2.3.1 docker image build ― Image building 50
__2.3.2 docker search ― Image search 54
__2.3.3 docker image pull ― Retrieving an image 56
__2.3.4 docker image ls ― Image list 57
__2.3.5 docker image tag ― Image tag 57
__2.3.6 docker login ― Container registry login 60
__2.3.7 docker image push ― Image release 64
Publishing Container Images to GHCR 67
2.4 Handling Containers 67
__2.4.1 Container Life Cycle 68
__2.4.2 docker container run ― Creating and running a container 69
71 Frequently Used Options When Executing the COLUMN Command
__2.4.3 docker container ls ― container list 72
__2.4.4 docker container stop ― Stop the container 74
__2.4.5 docker container rm ― Destroying a container 74
__2.4.6 docker container logs ― Checking logs (standard stream output) 76
__2.4.7 docker container exec ― Execute a command in a running container 77
__2.4.8 docker container cp ― copy file 78
2.5 Commands for Operations Management 79
__2.5.1 prune ― destruction 79
__2.5.2 docker container stats ― Get usage status 80
2.6 Docker Compose 81
__2.6.1 Running a Single Container with Docker Compose 81
__2.6.2 Running Multiple Containers with Compose 84
CHAPTER 3 Building and Deploying Practical Containers 93
3.1 Configuring Applications and Containers 93
__3.1.1 One Container = One Process? 95
__3.1.2 One concern per container 98
3.2 Container Portability 100
__3.2.1 Differences with Kernel and Architecture 100
COLUMN Containers 101 on Windows
__3.2.2 Library, Dynamic Linking 101
3.3 Container-Friendly Applications 102
__3.3.1 Building an image including a configuration file 103
__3.3.2 Using configuration files outside the container 103
COLUMN It's not just container-friendly products.
107
3.4 How to handle security information 107
__3.4.1 Container 107 Receiving Security Information
__3.4.2 Difficulties in managing version control systems and security information 108
__3.4.3 Managing Security Information Using Secrets 109
COLUMN Software Supply Chain Attacks 111
__3.4.4 There is no perfect solution 111
3.5 How to Use Persistent Data 112
__3.5.1 Data Volume 112
__3.5.2 Data Volume Container 114
CHAPTER 4 Building Applications Using Multiple Containers 119
4.1 Configuring Web Applications 119
__4.1.1 Application Specification 120
__4.1.2 Architecture 120
4.2 Building MySQL 123
__4.2.1 Creating a password for a user connecting to MySQL 124
__4.2.2 Setting up additional MySQL containers 125
__4.2.3 MySQL Dockerfile 126
__4.2.4 Configuring the MySQL Container 126
4.3 Building the Database Migrator 128
__4.3.1 Migrating a Database with golang-migrate 128
__4.3.2 Migration Execution Script 131
__4.3.3 Database Migrator Dockerfile 132
COLUMN .dockerignore file 134
__4.3.4 Configuring the Database Migrator Container 134
4.4 Building an API Server and Web Server 139
__4.4.1 Repository Directory Configuration 140
COLUMN Polyrepo and Monorepo 142
__4.4.2 Executable file and command details 142
__4.4.3 Building an API Server 144
__4.4.4 Building a Web Server 151
4.5 Building a Reverse Proxy 158
__4.5.1 Template structure of nginx container 159
COLUMN entrykit 163
__4.5.2 Dockerfile 163
4.6 Running a Task Management App by Configuring Multiple Containers 164
__4.6.1 compose.yaml 164
__4.6.2 Running the Task Management App 170
4.7 Improving the Development Experience with Multiple Container Configurations with Tilt 171
__4.7.1 Tilt Execution 171
__4.7.2 Tilt's Powerful Features 172
4.8 Container Orchestration Basics 176
Chapter 5: Introduction to Kubernetes 177
5.1 What is Kubernetes? 178
__5.1.1 The Rise of Docker and the Birth of Kubernetes 178
__5.1.2 Kubernetes Phase 179
5.2 Running Kubernetes Locally 181
__5.2.1 Building a Local Kubernetes Environment in Docker Desktop 181
COLUMN Other Kubernetes Build Tools 187
5.3 Kubernetes Overview 187
5.4 Kubernetes Cluster and Node 188
COLUMN Management Components that Make Up the Control Plane 190
5.5 Namespaces 191
5.6 Pad 192
__5.6.1 Creating and Deploying Pods 193
__5.6.2 Manipulating Pads 195
COLUMN Address of the pod and the container inside the pod 197
5.7 ReplicaSet 197
5.8 Deployment 199
__5.8.1 ReplicaSet Life Cycle 202
__5.8.2 Executing a Rollback 204
5.9 Service 205
__5.9.1 Traffic Routing Using Label Selectors 208
Analysis of the name of the COLUMN service 211
__5.9.2 ClusterIP Service 211
__5.9.3 Headless Service 211
__5.9.4 NodePort Service 213
__5.9.5 LoadBalancer Service 214
__5.9.6 ExternalName Service 214
5.10 Ingress 215
__5.10.1 Ingress Controller and Ingress Class 215
__5.10.2 Access via Ingress 216
COLUMN How to specify resource types and resource names with kubectl 221
Detecting Manifest File Updates with COLUMN Tilt and Automatically Updating Resources 222
COLUMN kk9s 223
COLUMN Kubernetes API 224
CHAPTER 6: Deploying Kubernetes and Building a Cluster 226
6.1 Configuring the Task Management App 226
__6.1.1 Kubernetes Resources Configuring the Task Management App 227
6.2 Deploying the Task Management App to Kubernetes 227
__6.2.1 Namespace 228
__6.2.2 Secret 228
__6.2.3 MySQL Distribution 232
COLUMN StatefulSet's serviceName 237
__6.2.4 Deploying the Database Migrator 238
__6.2.5 Deploying the API Server 241
__6.2.6 Web Server Deployment 245
6.3 Publishing Kubernetes Applications Online 251
__6.3.1 Deploying Azure Kubernetes Service 251
COLUMN Publishing Your Application with Your Own Domain and HTTPS 257
COLUMN kubectx 259
CHAPTER 7 Leveraging Kubernetes 260
7.1 Pod Deployment Strategy 260
__7.1.1 RollingUpdate 261
kubectl patch command to update part of COLUMN resource 266
__7.1.2 Setting up status checks when running containers 268
COLUMN Safely Stopping Applications and Deleting Pods 271
__7.1.3 Blue-Green Deployment 272
COLUMN 277 Products that Implement Service Mesh
7.2 Running Regular Batch Jobs in Kubernetes 278
__7.2.1 CronJob 278
__7.2.2 Running cron jobs with time zone considerations 284
__7.2.3 Running a one-time job from a cron job 284
7.3 User Management and Role-Based Access Control (RBAC) 285
__7.3.1 Implementing Permission Control Using RBAC 286
__7.3.2 Creating a Cluster Role 288
__7.3.3 Creating a Service Account 290
__7.3.4 Creating a Cluster Role Binding 291
__7.3.5 General User 294
CHAPTER 8: Packaging Kubernetes Applications 299
8.1 Kustomize 300
__8.1.1 Basic Usage 301
COLUMN Not recommended commonLabels 309
__8.1.2 Reuse and Partial Overlays 310
__8.1.3 Handling Secrets in Kustomize 315
__8.1.4 Generating a Manifest Over the Network 321
8.2 Helm 323
__8.2.1 Installing Helm 324
__8.2.2 Helm Charts and Repositories 325
__8.2.3 Installing Chart 328
__8.2.4 Creating Your Own Chart 332
COLUMN Recommended Labels for Kubernetes 347
__8.2.5 Registering a Chart in the Registry 347
COLUMN Connecting GHCR Packages and Repositories 351
COLUMN Open Container Initiative (OCI) 353
CHAPTER 9 CONTAINER OPERATIONS 354
9.1 Log Operation 354
__9.1.1 Container Log 354
__9.1.2 Container Log Operations 358
__9.1.3 Building a log collection and management configuration using the Elastic Stack 360
COLUMN Choosing a Stable Elasticsearch 384
COLUMN Cloud's Own Log Management 385
__9.1.4 stern 385
9.2 Highly Available Kubernetes Operations 387
__9.2.1 Kubernetes Behavior During Node Failure 387
__9.2.2 Failure-Resilient Pod Deployment Strategy with Pod AntiAffinity 388
__9.2.3 Separating CPU-intensive pods with Node Affinity 394
__9.2.4 Autoscaling Pods Using the Horizontal Pod Autoscaler 399
__9.2.5 Autoscaling Nodes Using Cluster Autoscaler 401
COLUMN 402: A Structure for Lightweight Kubernetes Cluster and Node Operation
CHAPTER 10 Creating and Operating Optimal Container Images 403
10.1 What is the optimal container image for operation? 403
__10.1.1 Problem 404 due to increased image size
10.2 Lightweight Base Image 404
__10.2.1 scratch 405
__10.2.2 BusyBox 411
__10.2.3 Alpine Linux 415
COLUMN Whether to use the Alpine Linux base image 417
__10.2.4 Distroless 418
10.3 Creating a lightweight container image 423
__10.3.1 Reducing the size of your deployed application 423
__10.3.2 Be aware of the layer structure of container images 424
10.4 Multi-stage builds 428
__10.4.1 Separating Build Containers and Run Containers 429
COLUMN Using an external image as a stage 432
10.5 BuildKit 433
__10.5.1 What is BuildKit? 433
__10.5.2 Container Multi-Platform Support 433
__10.5.3 Building Multi-Platform Images with BuildKit 435
COLUMN QEMU 436
COLUMN: How far should multi-platform images go? 441
10.6 Using and Creating Secure Container Images 441
__10.6.1 Minimally Configuring Container Images 442
__10.6.2 Avoid running in privileged mode 442
__10.6.3 Avoid running as root user 442
__10.6.4 Using Trusted Container Images and Tools 446
__10.6.5 Checking Container Image Vulnerabilities with Trivy 448
10.7 Building Container Images with CI Tools 451
__10.7.1 GitHub Actions 452
__10.7.2 Creating a Repository from a Template 453
__10.7.3 Workflow Settings 455
__10.7.4 Workflow Execution 460
Avoiding the latest image tag in COLUMN operations 464
CHAPTER 11 Continuous Delivery of Containers 465
11.1 What is Continuous Delivery? 465
__11.1.1 Problems Caused by Unpolished Deployment Processes 465
__11.1.2 The Importance of Software Delivery and the CI/CD Distinction 466
__11.1.3 Continuous Delivery with GitOps 467
11.2 Flux 469
__11.2.1 Flux Installation 469
__11.2.2 Application Deployment 470
11.3 Argo CD 475
__11.3.1 Argo CD Installation 475
__11.3.2 Application Deployment 478
11.4 PipeCD 484
__11.4.1 PipeCD Features 484
__11.4.2 Building a Quick Start Environment 485
__11.4.3 Application Deployment 489
COLUMN Why Build a Control Plane and Piped Separately in PipeCD 493
11.5 Full Automation of Software Delivery 495
__11.5.1 Automatically updating container image tags defined in the manifest 495
COLUMN 507: Incorporating an Approval Process into GitOps
CHAPTER 12: Various Uses of Containers 508
12.1 Unifying and Sharing Development Environments in Team Development 508
__12.1.1 Unifying the Software and Tools You Use 508
__12.1.2 Development Environment and Collective Intelligence 510
Can COLUMN Containers Replace Vagrant? 511
12.2 Using Command Line Tools in Containers 512
__12.2.1 Running Trivy in a Container 512
__12.2.2 Running a shell script in a container 515
12.3 Load Testing 517
__12.3.1 Locust Overview 517
__12.3.2 Load Testing Applications in Kubernetes 518
Running load tests on COLUMN k6 526
APPENDIX A: Setting Up Development Tools 528
A.1 WSL2 528
__A.1.1 WSL2 Conditions 529
__A.1.2 Installing WSL2 529
__A.1.3 Distributions available for WSL2 530
__A.1.4 make installation 531
COLUMN Establishing a Development Style Using WSL2 532
A.2 asdf 532
__A.2.1 What is asdf? 533
__A.2.2 asdf installation 533
__A.2.3 Tool Installation 534
__A.2.4 Set the version used 534
A.3 kind 535
__A.3.1 kind installation 536
__A.3.2 Building a Multi-Node Kubernetes Cluster in Your Local Environment 536
COLUMN Docker in Docker / Container in Container 538
A.4 Rancher Desktop 538
APPENDIX B Various Container Orchestration Environments 542
B.1 Google Kubernetes Engine 542
__B.1.1 Preparing to Build a GKE Cluster 543
__B.1.2 Building a GKE Cluster 545
B.2 Amazon Elastic Kubernetes Service 548
__B.2.1 Preparing to Build an EKS Cluster 548
__B.2.2 Building an EKS Cluster Using eksctl 550
COLUMN EKS on Fargate 555
B.3 Azure Kubernetes Service 556
__B.3.1 Preparing to Build an AKS Cluster 557
__B.3.2 Building an AKS Cluster 559
__B.3.3 AKS Cluster Operations 560
B.4 Building a Kubernetes Cluster in an On-Premises Environment 561
__B.4.1 Preparing to Build an On-Premises Cluster 561
__B.4.2 Building an EKS Cluster Using Kubespray 563
B.5 Amazon Elastic Container Service 566
__B.5.1 Creating an ECS Cluster and Defining Container Deployments with CDK 567
__B.5.2 Creating an ECS Cluster and Deploying Containers with CDK 569
COLUMN Amazon ECS Anywhere 571
APPENDIX C Container Development and Operation Tips 572
C.1 Container Runtime 572
__C.1.1 containerd 573
COLUMN Kubernetes' Docker Deprecation: The Ruckus 574
C.1.2 nerdctl 574
C.2 Kubernetes Tip 575
__C.2.1 Debugging Existing Pods via Ephemeral Containers 575
__C.2.2 Hardening Security Using Pod Security Admission 578
COLUMN Open Policy Agent 581
C.3 Container Development and Deployment Tips 581
__C.3.1 Automatically Updating Containers with Compose Watch 581
__C.3.2 Handling Kubernetes Applications with Tilt 583
C.4 Improving Container Development Efficiency Using Generative AI 585
__C.4.1 Using ChatGPT 586
__C.4.2 Using GitHub Copilot 587
C.5 Alpine Linux Package Manager apk 589
__C.5.1 Manipulating Package Manager APK 589
__C.5.2 alpine-sdk package 592
Reference 593
Search 595
Beta Reader Review xiv
Beginning xvi
Acknowledgments xviii
CHAPTER 1 Containers and Docker Basics 1
1.1 What is a container? 1
__1.1.1 Containerized Virtualization 2
__1.1.2 Container Use Case 3
5 Disadvantages of COLUMN Containers
1.2 What is Docker? 5
__1.2.1 History of Docker and Docker, Inc. 6
__1.2.2 Docker 7 Focused on Application Deployment
__1.2.3 Docker Access 8
COLUMN Moby Project 11
1.3 Why Use Containers? 11
__1.3.1 Ensuring reproducibility through immutable applications and execution environments 12
COLUMN Cloud IaC and Immutable Infrastructure 15
COLUMN Container Technology and Serverless Platforms 16
__1.3.2 Ease of Application Configuration Management 16
__1.3.3 High portability regardless of environment 18
__1.3.4 Efficiency of Container-Based Development 20
1.4 Building a Local Container Execution Environment 20
__1.4.1 Installing Docker Desktop 21
COLUMN ARM Architecture 24
__1.4.2 Docker Desktop Setup 25
__1.4.3 Docker Desktop Troubleshooting 30
COLUMN Linux Environment Installation 32
COLUMN Docker Subscription Plan 32
CHAPTER 2 CONTAINER DEPLOYMENT 33
2.1 Running Applications in Containers 33
__2.1.1 Container Images and Container Basics 34
2.2 Creating a Simple Application and Container Image 37
__2.2.1 Dockerfile Instruction 39
Overwrite 40 when executing COLUMN CMD
Learn how to execute commands with COLUMN ENTRYPOINT 42
COLUMN Other Instructions in the Dockerfile 44
COLUMN CMD Specification Method 45
__2.2.2 Running a Container 45
COLUMN Short Docker Commands 46
2.3 Handling Images 48
__2.3.1 docker image build ― Image building 50
__2.3.2 docker search ― Image search 54
__2.3.3 docker image pull ― Retrieving an image 56
__2.3.4 docker image ls ― Image list 57
__2.3.5 docker image tag ― Image tag 57
__2.3.6 docker login ― Container registry login 60
__2.3.7 docker image push ― Image release 64
Publishing Container Images to GHCR 67
2.4 Handling Containers 67
__2.4.1 Container Life Cycle 68
__2.4.2 docker container run ― Creating and running a container 69
71 Frequently Used Options When Executing the COLUMN Command
__2.4.3 docker container ls ― container list 72
__2.4.4 docker container stop ― Stop the container 74
__2.4.5 docker container rm ― Destroying a container 74
__2.4.6 docker container logs ― Checking logs (standard stream output) 76
__2.4.7 docker container exec ― Execute a command in a running container 77
__2.4.8 docker container cp ― copy file 78
2.5 Commands for Operations Management 79
__2.5.1 prune ― destruction 79
__2.5.2 docker container stats ― Get usage status 80
2.6 Docker Compose 81
__2.6.1 Running a Single Container with Docker Compose 81
__2.6.2 Running Multiple Containers with Compose 84
CHAPTER 3 Building and Deploying Practical Containers 93
3.1 Configuring Applications and Containers 93
__3.1.1 One Container = One Process? 95
__3.1.2 One concern per container 98
3.2 Container Portability 100
__3.2.1 Differences with Kernel and Architecture 100
COLUMN Containers 101 on Windows
__3.2.2 Library, Dynamic Linking 101
3.3 Container-Friendly Applications 102
__3.3.1 Building an image including a configuration file 103
__3.3.2 Using configuration files outside the container 103
COLUMN It's not just container-friendly products.
107
3.4 How to handle security information 107
__3.4.1 Container 107 Receiving Security Information
__3.4.2 Difficulties in managing version control systems and security information 108
__3.4.3 Managing Security Information Using Secrets 109
COLUMN Software Supply Chain Attacks 111
__3.4.4 There is no perfect solution 111
3.5 How to Use Persistent Data 112
__3.5.1 Data Volume 112
__3.5.2 Data Volume Container 114
CHAPTER 4 Building Applications Using Multiple Containers 119
4.1 Configuring Web Applications 119
__4.1.1 Application Specification 120
__4.1.2 Architecture 120
4.2 Building MySQL 123
__4.2.1 Creating a password for a user connecting to MySQL 124
__4.2.2 Setting up additional MySQL containers 125
__4.2.3 MySQL Dockerfile 126
__4.2.4 Configuring the MySQL Container 126
4.3 Building the Database Migrator 128
__4.3.1 Migrating a Database with golang-migrate 128
__4.3.2 Migration Execution Script 131
__4.3.3 Database Migrator Dockerfile 132
COLUMN .dockerignore file 134
__4.3.4 Configuring the Database Migrator Container 134
4.4 Building an API Server and Web Server 139
__4.4.1 Repository Directory Configuration 140
COLUMN Polyrepo and Monorepo 142
__4.4.2 Executable file and command details 142
__4.4.3 Building an API Server 144
__4.4.4 Building a Web Server 151
4.5 Building a Reverse Proxy 158
__4.5.1 Template structure of nginx container 159
COLUMN entrykit 163
__4.5.2 Dockerfile 163
4.6 Running a Task Management App by Configuring Multiple Containers 164
__4.6.1 compose.yaml 164
__4.6.2 Running the Task Management App 170
4.7 Improving the Development Experience with Multiple Container Configurations with Tilt 171
__4.7.1 Tilt Execution 171
__4.7.2 Tilt's Powerful Features 172
4.8 Container Orchestration Basics 176
Chapter 5: Introduction to Kubernetes 177
5.1 What is Kubernetes? 178
__5.1.1 The Rise of Docker and the Birth of Kubernetes 178
__5.1.2 Kubernetes Phase 179
5.2 Running Kubernetes Locally 181
__5.2.1 Building a Local Kubernetes Environment in Docker Desktop 181
COLUMN Other Kubernetes Build Tools 187
5.3 Kubernetes Overview 187
5.4 Kubernetes Cluster and Node 188
COLUMN Management Components that Make Up the Control Plane 190
5.5 Namespaces 191
5.6 Pad 192
__5.6.1 Creating and Deploying Pods 193
__5.6.2 Manipulating Pads 195
COLUMN Address of the pod and the container inside the pod 197
5.7 ReplicaSet 197
5.8 Deployment 199
__5.8.1 ReplicaSet Life Cycle 202
__5.8.2 Executing a Rollback 204
5.9 Service 205
__5.9.1 Traffic Routing Using Label Selectors 208
Analysis of the name of the COLUMN service 211
__5.9.2 ClusterIP Service 211
__5.9.3 Headless Service 211
__5.9.4 NodePort Service 213
__5.9.5 LoadBalancer Service 214
__5.9.6 ExternalName Service 214
5.10 Ingress 215
__5.10.1 Ingress Controller and Ingress Class 215
__5.10.2 Access via Ingress 216
COLUMN How to specify resource types and resource names with kubectl 221
Detecting Manifest File Updates with COLUMN Tilt and Automatically Updating Resources 222
COLUMN kk9s 223
COLUMN Kubernetes API 224
CHAPTER 6: Deploying Kubernetes and Building a Cluster 226
6.1 Configuring the Task Management App 226
__6.1.1 Kubernetes Resources Configuring the Task Management App 227
6.2 Deploying the Task Management App to Kubernetes 227
__6.2.1 Namespace 228
__6.2.2 Secret 228
__6.2.3 MySQL Distribution 232
COLUMN StatefulSet's serviceName 237
__6.2.4 Deploying the Database Migrator 238
__6.2.5 Deploying the API Server 241
__6.2.6 Web Server Deployment 245
6.3 Publishing Kubernetes Applications Online 251
__6.3.1 Deploying Azure Kubernetes Service 251
COLUMN Publishing Your Application with Your Own Domain and HTTPS 257
COLUMN kubectx 259
CHAPTER 7 Leveraging Kubernetes 260
7.1 Pod Deployment Strategy 260
__7.1.1 RollingUpdate 261
kubectl patch command to update part of COLUMN resource 266
__7.1.2 Setting up status checks when running containers 268
COLUMN Safely Stopping Applications and Deleting Pods 271
__7.1.3 Blue-Green Deployment 272
COLUMN 277 Products that Implement Service Mesh
7.2 Running Regular Batch Jobs in Kubernetes 278
__7.2.1 CronJob 278
__7.2.2 Running cron jobs with time zone considerations 284
__7.2.3 Running a one-time job from a cron job 284
7.3 User Management and Role-Based Access Control (RBAC) 285
__7.3.1 Implementing Permission Control Using RBAC 286
__7.3.2 Creating a Cluster Role 288
__7.3.3 Creating a Service Account 290
__7.3.4 Creating a Cluster Role Binding 291
__7.3.5 General User 294
CHAPTER 8: Packaging Kubernetes Applications 299
8.1 Kustomize 300
__8.1.1 Basic Usage 301
COLUMN Not recommended commonLabels 309
__8.1.2 Reuse and Partial Overlays 310
__8.1.3 Handling Secrets in Kustomize 315
__8.1.4 Generating a Manifest Over the Network 321
8.2 Helm 323
__8.2.1 Installing Helm 324
__8.2.2 Helm Charts and Repositories 325
__8.2.3 Installing Chart 328
__8.2.4 Creating Your Own Chart 332
COLUMN Recommended Labels for Kubernetes 347
__8.2.5 Registering a Chart in the Registry 347
COLUMN Connecting GHCR Packages and Repositories 351
COLUMN Open Container Initiative (OCI) 353
CHAPTER 9 CONTAINER OPERATIONS 354
9.1 Log Operation 354
__9.1.1 Container Log 354
__9.1.2 Container Log Operations 358
__9.1.3 Building a log collection and management configuration using the Elastic Stack 360
COLUMN Choosing a Stable Elasticsearch 384
COLUMN Cloud's Own Log Management 385
__9.1.4 stern 385
9.2 Highly Available Kubernetes Operations 387
__9.2.1 Kubernetes Behavior During Node Failure 387
__9.2.2 Failure-Resilient Pod Deployment Strategy with Pod AntiAffinity 388
__9.2.3 Separating CPU-intensive pods with Node Affinity 394
__9.2.4 Autoscaling Pods Using the Horizontal Pod Autoscaler 399
__9.2.5 Autoscaling Nodes Using Cluster Autoscaler 401
COLUMN 402: A Structure for Lightweight Kubernetes Cluster and Node Operation
CHAPTER 10 Creating and Operating Optimal Container Images 403
10.1 What is the optimal container image for operation? 403
__10.1.1 Problem 404 due to increased image size
10.2 Lightweight Base Image 404
__10.2.1 scratch 405
__10.2.2 BusyBox 411
__10.2.3 Alpine Linux 415
COLUMN Whether to use the Alpine Linux base image 417
__10.2.4 Distroless 418
10.3 Creating a lightweight container image 423
__10.3.1 Reducing the size of your deployed application 423
__10.3.2 Be aware of the layer structure of container images 424
10.4 Multi-stage builds 428
__10.4.1 Separating Build Containers and Run Containers 429
COLUMN Using an external image as a stage 432
10.5 BuildKit 433
__10.5.1 What is BuildKit? 433
__10.5.2 Container Multi-Platform Support 433
__10.5.3 Building Multi-Platform Images with BuildKit 435
COLUMN QEMU 436
COLUMN: How far should multi-platform images go? 441
10.6 Using and Creating Secure Container Images 441
__10.6.1 Minimally Configuring Container Images 442
__10.6.2 Avoid running in privileged mode 442
__10.6.3 Avoid running as root user 442
__10.6.4 Using Trusted Container Images and Tools 446
__10.6.5 Checking Container Image Vulnerabilities with Trivy 448
10.7 Building Container Images with CI Tools 451
__10.7.1 GitHub Actions 452
__10.7.2 Creating a Repository from a Template 453
__10.7.3 Workflow Settings 455
__10.7.4 Workflow Execution 460
Avoiding the latest image tag in COLUMN operations 464
CHAPTER 11 Continuous Delivery of Containers 465
11.1 What is Continuous Delivery? 465
__11.1.1 Problems Caused by Unpolished Deployment Processes 465
__11.1.2 The Importance of Software Delivery and the CI/CD Distinction 466
__11.1.3 Continuous Delivery with GitOps 467
11.2 Flux 469
__11.2.1 Flux Installation 469
__11.2.2 Application Deployment 470
11.3 Argo CD 475
__11.3.1 Argo CD Installation 475
__11.3.2 Application Deployment 478
11.4 PipeCD 484
__11.4.1 PipeCD Features 484
__11.4.2 Building a Quick Start Environment 485
__11.4.3 Application Deployment 489
COLUMN Why Build a Control Plane and Piped Separately in PipeCD 493
11.5 Full Automation of Software Delivery 495
__11.5.1 Automatically updating container image tags defined in the manifest 495
COLUMN 507: Incorporating an Approval Process into GitOps
CHAPTER 12: Various Uses of Containers 508
12.1 Unifying and Sharing Development Environments in Team Development 508
__12.1.1 Unifying the Software and Tools You Use 508
__12.1.2 Development Environment and Collective Intelligence 510
Can COLUMN Containers Replace Vagrant? 511
12.2 Using Command Line Tools in Containers 512
__12.2.1 Running Trivy in a Container 512
__12.2.2 Running a shell script in a container 515
12.3 Load Testing 517
__12.3.1 Locust Overview 517
__12.3.2 Load Testing Applications in Kubernetes 518
Running load tests on COLUMN k6 526
APPENDIX A: Setting Up Development Tools 528
A.1 WSL2 528
__A.1.1 WSL2 Conditions 529
__A.1.2 Installing WSL2 529
__A.1.3 Distributions available for WSL2 530
__A.1.4 make installation 531
COLUMN Establishing a Development Style Using WSL2 532
A.2 asdf 532
__A.2.1 What is asdf? 533
__A.2.2 asdf installation 533
__A.2.3 Tool Installation 534
__A.2.4 Set the version used 534
A.3 kind 535
__A.3.1 kind installation 536
__A.3.2 Building a Multi-Node Kubernetes Cluster in Your Local Environment 536
COLUMN Docker in Docker / Container in Container 538
A.4 Rancher Desktop 538
APPENDIX B Various Container Orchestration Environments 542
B.1 Google Kubernetes Engine 542
__B.1.1 Preparing to Build a GKE Cluster 543
__B.1.2 Building a GKE Cluster 545
B.2 Amazon Elastic Kubernetes Service 548
__B.2.1 Preparing to Build an EKS Cluster 548
__B.2.2 Building an EKS Cluster Using eksctl 550
COLUMN EKS on Fargate 555
B.3 Azure Kubernetes Service 556
__B.3.1 Preparing to Build an AKS Cluster 557
__B.3.2 Building an AKS Cluster 559
__B.3.3 AKS Cluster Operations 560
B.4 Building a Kubernetes Cluster in an On-Premises Environment 561
__B.4.1 Preparing to Build an On-Premises Cluster 561
__B.4.2 Building an EKS Cluster Using Kubespray 563
B.5 Amazon Elastic Container Service 566
__B.5.1 Creating an ECS Cluster and Defining Container Deployments with CDK 567
__B.5.2 Creating an ECS Cluster and Deploying Containers with CDK 569
COLUMN Amazon ECS Anywhere 571
APPENDIX C Container Development and Operation Tips 572
C.1 Container Runtime 572
__C.1.1 containerd 573
COLUMN Kubernetes' Docker Deprecation: The Ruckus 574
C.1.2 nerdctl 574
C.2 Kubernetes Tip 575
__C.2.1 Debugging Existing Pods via Ephemeral Containers 575
__C.2.2 Hardening Security Using Pod Security Admission 578
COLUMN Open Policy Agent 581
C.3 Container Development and Deployment Tips 581
__C.3.1 Automatically Updating Containers with Compose Watch 581
__C.3.2 Handling Kubernetes Applications with Tilt 583
C.4 Improving Container Development Efficiency Using Generative AI 585
__C.4.1 Using ChatGPT 586
__C.4.2 Using GitHub Copilot 587
C.5 Alpine Linux Package Manager apk 589
__C.5.1 Manipulating Package Manager APK 589
__C.5.2 alpine-sdk package 592
Reference 593
Search 595
Detailed image
.jpg)
Into the book
Let's take web application development as an example.
Containers allow you to quickly prepare applications for your local development environment and deploy them as-is, regardless of platform.
Since each container uses the same execution environment, problems depending on the execution environment can be minimized.
Additionally, web servers such as Apache or nginx can be set up in containers without complicated steps.
System configuration management, including middleware, is also defined in the settings file.
Just introducing containers can make development and operations easier than they are now.
--- p.12
Looking at what we've covered so far, you might be tempted to convert all your structures to containers, but containers aren't suitable for everything.
There are also some areas where using containers, such as data stores, can be difficult.
/ Recently, managed data stores with low load and scalability are also being serviced on cloud platforms, so you can use them in an appropriate combination without having to force containers.
It is important to choose the right function for the right place.
Servers that are stateless, such as web servers or API servers, can be containerized without spending a lot of time.
/ Considering the advantage of high portability, container technology can only be effective if introduced to both development and operational environments.
There are already many success stories, and cloud managed services are becoming easier to use.
--- p.19
Pods created with Deployments and ReplicaSets are suitable for resident applications such as web servers, but Jobs are suitable for large-scale computation and batch applications.
Even if all caught pods are terminated normally, the pods are not deleted and remain, so you can analyze the logs and execution results of the pods after termination.
It can be easily scaled out by running multiple pods in parallel, and it is easy to process by running as a pod and connecting with Kubernetes services.
--- p.239
A scratch image is the first image created by injecting files from outside the container via the Dockerfile command.
If we follow the parents of all existing container images, they all end up at the scratch image.
That is, scratch is the ancestor of the container image.
/ scratch The inside is empty.
When creating an image based on this, the necessary files are copied from outside the container to configure the image.
Up until now, you could enter the container using sh, so at first glance, the inside of the container may seem no different from a normal Linux system.
So you might wonder how we can generate an image from a blank scratch image that looks like it faithfully reproduces the OS.
/ Let's actually create an Ubuntu image.
--- p.405
In team development, unified tools and versions can help avoid unnecessary trouble.
When working on multiple projects simultaneously, the host environment may become contaminated as projects are switched.
To avoid problems like this, it's a good idea to provide a common development environment in a container that is isolated from the host and includes the necessary tools.
/ For example, to use data stores such as MySQL and Redis, you need client tools to manipulate them.
Consider using a team standard such as redis-tools, which includes mycli1, a high-performance MySQL client, and Redis Cli2, a Redis client.
Containers allow you to quickly prepare applications for your local development environment and deploy them as-is, regardless of platform.
Since each container uses the same execution environment, problems depending on the execution environment can be minimized.
Additionally, web servers such as Apache or nginx can be set up in containers without complicated steps.
System configuration management, including middleware, is also defined in the settings file.
Just introducing containers can make development and operations easier than they are now.
--- p.12
Looking at what we've covered so far, you might be tempted to convert all your structures to containers, but containers aren't suitable for everything.
There are also some areas where using containers, such as data stores, can be difficult.
/ Recently, managed data stores with low load and scalability are also being serviced on cloud platforms, so you can use them in an appropriate combination without having to force containers.
It is important to choose the right function for the right place.
Servers that are stateless, such as web servers or API servers, can be containerized without spending a lot of time.
/ Considering the advantage of high portability, container technology can only be effective if introduced to both development and operational environments.
There are already many success stories, and cloud managed services are becoming easier to use.
--- p.19
Pods created with Deployments and ReplicaSets are suitable for resident applications such as web servers, but Jobs are suitable for large-scale computation and batch applications.
Even if all caught pods are terminated normally, the pods are not deleted and remain, so you can analyze the logs and execution results of the pods after termination.
It can be easily scaled out by running multiple pods in parallel, and it is easy to process by running as a pod and connecting with Kubernetes services.
--- p.239
A scratch image is the first image created by injecting files from outside the container via the Dockerfile command.
If we follow the parents of all existing container images, they all end up at the scratch image.
That is, scratch is the ancestor of the container image.
/ scratch The inside is empty.
When creating an image based on this, the necessary files are copied from outside the container to configure the image.
Up until now, you could enter the container using sh, so at first glance, the inside of the container may seem no different from a normal Linux system.
So you might wonder how we can generate an image from a blank scratch image that looks like it faithfully reproduces the OS.
/ Let's actually create an Ubuntu image.
--- p.405
In team development, unified tools and versions can help avoid unnecessary trouble.
When working on multiple projects simultaneously, the host environment may become contaminated as projects are switched.
To avoid problems like this, it's a good idea to provide a common development environment in a container that is isolated from the host and includes the necessary tools.
/ For example, to use data stores such as MySQL and Redis, you need client tools to manipulate them.
Consider using a team standard such as redis-tools, which includes mycli1, a high-performance MySQL client, and Redis Cli2, a Redis client.
--- pp.508-509
Publisher's Review
A practical introduction to container technology that you can learn by following along.
In the ever-changing software development environment, container technology has become a necessity, not an option. Docker and Kubernetes are now core tools that every developer must understand.
The omnidirectional demands spanning frontend, backend, infrastructure, and DevOps are demanding container technology from all developers.
This book is structured to help you learn container technology step by step, focusing on Docker and Kubernetes.
Rather than simply listing concepts, it provides practice-oriented examples and structure, allowing even beginners to develop a practical sense that can be applied immediately to actual work.
It is packed with essential practical skills, from image building, multi-container configuration, and orchestration strategies using Kubernetes.
This revised edition has been comprehensively revised and supplemented to reflect the changing modern ecosystem, and the author's practical experience and technical insight have been incorporated to create a more in-depth and practical guide.
Beyond conceptual learning, you will develop the mindset necessary for development and operations, and be able to apply container technology in practice.
A friendly and practical guide for all developers, from beginners to practitioners, who want to learn container technology properly.
Take your first step on your container technology journey with this book!
Key Contents
● Concepts, structure, and execution principles of containers and Docker
● Practice building and running Docker images, and port forwarding
● Configuring and running multiple containers using Compose
● Network connection, mounting, and secret management between containers
● Building a Docker-based web application and API server
● Setting up a real-world MySQL data store and migrator container
High-availability operation and scaling strategy through Kubernetes
● Practical skills such as security settings, volumes, and log collection in the operating environment
In the ever-changing software development environment, container technology has become a necessity, not an option. Docker and Kubernetes are now core tools that every developer must understand.
The omnidirectional demands spanning frontend, backend, infrastructure, and DevOps are demanding container technology from all developers.
This book is structured to help you learn container technology step by step, focusing on Docker and Kubernetes.
Rather than simply listing concepts, it provides practice-oriented examples and structure, allowing even beginners to develop a practical sense that can be applied immediately to actual work.
It is packed with essential practical skills, from image building, multi-container configuration, and orchestration strategies using Kubernetes.
This revised edition has been comprehensively revised and supplemented to reflect the changing modern ecosystem, and the author's practical experience and technical insight have been incorporated to create a more in-depth and practical guide.
Beyond conceptual learning, you will develop the mindset necessary for development and operations, and be able to apply container technology in practice.
A friendly and practical guide for all developers, from beginners to practitioners, who want to learn container technology properly.
Take your first step on your container technology journey with this book!
Key Contents
● Concepts, structure, and execution principles of containers and Docker
● Practice building and running Docker images, and port forwarding
● Configuring and running multiple containers using Compose
● Network connection, mounting, and secret management between containers
● Building a Docker-based web application and API server
● Setting up a real-world MySQL data store and migrator container
High-availability operation and scaling strategy through Kubernetes
● Practical skills such as security settings, volumes, and log collection in the operating environment
GOODS SPECIFICS
- Date of issue: May 29, 2025
- Page count, weight, size: 624 pages | 1,192g | 188*245*30mm
- ISBN13: 9791194587279
You may also like
카테고리
korean
korean