Key Takeaways
Treat the datacenter as one pool, not a map of servers.
Why orchestration emerged. Monolithic applications bundle tightly connected parts, so a change or scaling need can affect the whole system. Microservices can be developed and scaled independently, but dozens of separate components are harder to place, configure, and keep healthy by hand. Containers package an application with its files and dependencies while isolating its processes with Linux namespaces and limiting resources with cgroups. Unlike virtual machines, containers share the host kernel, which reduces overhead but makes their isolation less complete.
One platform, many machines. Kubernetes accepts descriptions of what an application needs, then schedules its components across a cluster as if the machines were one pool of compute. This hides routine placement decisions from developers and automates operational work, but it does not make an application horizontally scalable or remove the need to manage its dependencies.
The central trade is abstraction, not disappearance of complexity. A cluster-wide platform lets teams stop reasoning about each server for every deployment, much as a compiler frees programmers from managing individual machine instructions. Yet abstraction moves complexity into boundaries: resource requests, network behavior, and failure handling still require explicit design. Kubernetes is most valuable when teams want repeatable deployment across varied infrastructure, not when a single small application would be simpler on one well-understood machine.
Keep Pods small, grouping containers only when they must cooperate.
A Pod is the unit. Kubernetes schedules Pods, not standalone containers. A Pod holds one or more closely related containers on the same node; they share a network identity and can communicate through localhost. Their filesystems remain separate unless they mount a shared volume. The Pod behaves like a small logical machine dedicated to one application component.
Group by operational need. A web server and a database usually belong in separate Pods: they can run on different nodes, scale differently, and fail independently. A web server and a helper that continuously refreshes files for it are a better pair, because they share a directory and work together as one service. A useful test is whether the containers must run together, form one component, and scale together. If not, separate them.
The Pod boundary is an architectural choice disguised as a deployment detail. Grouping tightly coupled helpers can simplify shared networking and files, while combining independently scaled services creates accidental coupling. This resembles process design in operating systems: a shared address space makes cooperation easy but also ties components to one failure and resource boundary. The practical discipline is to justify co-location, rather than treating a Pod as a convenient box for every process involved in an application.
Declare the desired state; let controllers repair the difference.
Specify the outcome. Kubernetes is built around declarative control: a user states, for example, that three copies should run, and controllers compare that desired state with what actually exists. If a Pod disappears, a ReplicaSet creates a replacement. If the requested replica count changes, it adds or removes Pods. The replacement is a new Pod, not the old one moved to another machine.
Different jobs need different controllers. Deployments manage ReplicaSets and provide a controlled way to update application versions. DaemonSets run a Pod on each eligible node, while Jobs run tasks meant to finish and CronJobs schedule such tasks. These controllers create or update API resources; the Scheduler assigns nodes, and each node’s Kubelet starts containers. The division of work makes recovery repeatable, though it is not instantaneous.
This is a control loop, a familiar idea from engineering: measure the current condition, compare it with a target, and apply corrective action. Its strength is that operators describe intent rather than script every recovery step. Its limitation is that convergence takes time and depends on healthy components, available capacity, and accurate specifications. Declarative systems therefore reduce coordination work, but they do not eliminate the need to observe what the system is doing while it catches up.
Give moving Pods stable service names, never hard-code their IPs.
Pods are temporary addresses. A Pod can be replaced after a crash, node failure, or scale change, and its replacement receives a different IP. A Service provides a stable address and port for a group of Pods selected by labels. Kubernetes updates the Service’s endpoints as matching Pods appear, disappear, or become unready, and distributes new connections among available endpoints.
Choose the right entry point. Other Pods can discover Services through DNS, commonly by the Service name within the same namespace. For external access, NodePort exposes a port on cluster nodes, LoadBalancer requests an infrastructure-provided load balancer, and Ingress routes HTTP traffic to multiple Services through a shared entry point. These mechanisms differ in reach and behavior, so choose based on the traffic path rather than assuming every Service is public.
Stable naming separates what a client wants from where a provider happens to run. That is a basic service-discovery pattern in distributed systems: replace direct knowledge of instances with a contract that survives churn. The Service abstraction is powerful, but it does not make networking invisible. Connection-level balancing, DNS timing, readiness, and external routing can still shape user experience. Treat the stable address as a boundary that simplifies clients, not as proof that every underlying connection is reliable.
Make probes and rollout rules catch bad versions before users do.
Check two different conditions. A liveness probe asks whether a container should keep running; repeated failures cause Kubernetes to replace it. A readiness probe asks whether a running container should receive traffic; failure removes the Pod from Service endpoints without restarting it. The book’s deliberately faulty web server returns errors after several requests, showing how an HTTP probe can detect a failure that does not crash the process. Probes should be lightweight, and startup delays must be allowed for.
Guard changes in production. A Deployment can roll out a new image gradually, retain earlier ReplicaSets for rollback, and control how many Pods are added or unavailable during the update. A readiness probe plus an appropriate minReadySeconds interval can prevent a version that quickly becomes unhealthy from replacing all working replicas. This limits exposure, but no rollout policy can replace testing or sound application compatibility.
Probes turn an application’s private notion of health into an operational signal. That is useful because a process can be alive yet unable to serve requests, but a probe can also misdiagnose shared dependency failures. Restarting a frontend will not repair a broken database. The strongest design distinguishes local process failure from temporary inability to serve traffic, then uses rollouts to limit the blast radius. Reliability comes from matching the signal to the failure, not from adding checks indiscriminately.
Keep configuration, credentials, and durable data outside image layers.
Separate settings from software. Container images should hold the application and its runtime environment, not values that vary between development and production. ConfigMaps store ordinary settings as key-value entries or files; containers can receive them through environment variables, command arguments, or mounted volumes. Secrets serve a similar purpose for sensitive values such as credentials and certificates. Secret volumes expose decoded files in memory, while environment variables can be revealed unintentionally through logs or child processes.
Choose storage by lifetime. A container’s writable filesystem disappears when that container is replaced. A Pod volume can preserve files across container restarts, while a PersistentVolumeClaim requests storage that can survive Pod replacement. PersistentVolumes and StorageClasses separate the application’s storage request from the underlying provider. This makes manifests more portable, but durability still depends on the actual storage system and its policies.
Separating code, configuration, credentials, and data creates clearer change boundaries. A configuration update need not require rebuilding software, and a storage choice need not be hard-coded into the application manifest. This resembles separation of concerns in software architecture, but the security boundary deserves special care: encoding a Secret is not the same as controlling who can read it. Portability is also conditional, since different storage providers offer different capabilities and failure guarantees.
Use StatefulSets when each replica needs its own identity and disk.
Some replicas are not interchangeable. A ReplicaSet creates copies from one template, so its replicas normally share the same claim reference. That is a poor fit for a distributed database in which each member needs separate storage and a predictable identity. A StatefulSet assigns ordered names, such as an application name followed by an index, and pairs each instance with its own PersistentVolumeClaim.
Preserve identity carefully. A governing headless Service gives each Pod a discoverable DNS name, and the StatefulSet recreates a lost instance with the same name and storage claim. Scaling proceeds in order, and scaling down removes the highest-numbered instance first. Claims are retained when instances are scaled down, protecting data but requiring deliberate cleanup. Because two members sharing one identity and disk can corrupt state, forcibly deleting a Pod is dangerous unless its old process is certainly gone.
The distinction between interchangeable workers and individually meaningful members is crucial in distributed computing. Stable names and separate disks give clustered software the continuity it expects, while ordered startup and shutdown reduce risky simultaneous changes. But Kubernetes supplies identity and storage attachment, not database replication or consensus. A StatefulSet cannot make an unsafe data system safe by itself. The application’s own recovery protocol must remain responsible for consistency when members fail or become unreachable.
Request resources for scheduling; cap them to protect neighboring workloads.
Requests reserve a planning budget. A container’s CPU and memory requests tell the Scheduler what it must be able to accommodate before placing a Pod. The Scheduler sums requested resources, not current consumption, so a node can reject a Pod even when its applications appear idle. CPU requests also influence how unused CPU time is shared among containers.
Limits constrain use. CPU can be throttled when a container exceeds its limit. Memory cannot be reclaimed as smoothly, so exceeding a memory limit can lead to an OOM kill and repeated restarts. Kubernetes derives Quality of Service classes from requests and limits: BestEffort has none, Guaranteed has matching requests and limits for CPU and memory across containers, and other configurations are Burstable. LimitRanges set per-container defaults or bounds; ResourceQuotas cap aggregate namespace use.
Requests and limits solve different problems: placement is a capacity-planning question, while limits are a contention-control mechanism. Confusing them leads either to stranded capacity or to unstable neighbors. The QoS categories make tradeoffs legible, but a numeric policy is only as good as the measurements behind it. Monitoring actual use over time matters because workloads change with traffic, and memory pressure can punish a container even when its own configured ceiling is not the only constraint.
Grant each workload only the API and network access it needs.
Treat Pods as potential security boundaries. Applications use ServiceAccounts to authenticate to the API server. With role-based access control, Roles define permitted actions in a namespace, while bindings attach them to users, groups, or ServiceAccounts. ClusterRoles and ClusterRoleBindings cover cluster-level access or reusable permissions. The book’s core rule is least privilege: give each workload its own appropriately limited identity instead of making every Pod an administrator.
Restrict what containers can touch. Security contexts can run processes as non-root, make the container filesystem read-only, or add and drop specific Linux capabilities. PodSecurityPolicy, in the book’s Kubernetes version, lets administrators constrain these choices. NetworkPolicies can deny traffic by default and selectively allow connections by Pod labels, namespace labels, or IP ranges, provided the networking plugin supports enforcement.
Security is strongest when access is constrained at multiple layers. RBAC governs what a workload can ask the control plane to do; container settings reduce what a compromised process can do on its node; network policies limit its reach to other workloads. These controls address different attack paths, so none substitutes for the others. Policy complexity can also become a source of outages. Clear ownership, testing, and careful defaults matter as much as the rule set itself.
Assume containers restart, and make startup and shutdown safe.
A restart is a new container. Even if its Pod remains, the replacement container gets a fresh writable filesystem. Use a volume if useful files must survive that restart, but recognize that preserving corrupted cache data can keep a failure alive. A ReplicaSet counts matching Pods, not whether their applications are functioning, so repeated crashes do not necessarily trigger replacement elsewhere.
Handle change without breaking clients. Init containers can prepare a Pod or wait for a prerequisite before its main containers start. Readiness checks keep an unprepared application out of traffic. On deletion, the Kubelet runs a pre-stop hook, sends SIGTERM, waits through the configured grace period, then may force termination. Since routing updates take time, an application may need to briefly keep accepting connections, finish active requests, and close cleanly.
The operational model is not simply start or stop. Startup, readiness, routing updates, active requests, and termination unfold across separate processes and machines. That makes graceful behavior a coordination problem, not just a signal handler. A short shutdown delay can reduce connection failures, but it cannot guarantee every proxy has updated. Critical cleanup should therefore not depend solely on a process’s final moments; durable recovery mechanisms are safer than assuming a shutdown hook always completes.
Extend Kubernetes with domain-specific APIs, not piles of one-off scripts.
Build on the API model. A CustomResourceDefinition adds a new resource type without modifying the main API server. A custom controller watches instances of that type and creates ordinary resources in response. In the book’s example, a Website object containing a Git source prompts a controller to create a Deployment and Service, hiding those lower-level details from the user.
Reuse higher-level platforms. The Service Catalog offers a common way to request broker-provided services, such as databases, and bind credentials to workloads. OpenShift adds application builds, templates, user management, and routes. Helm packages groups of Kubernetes resources as reusable application charts. These tools show how Kubernetes can become a platform for other platforms, though each layer adds its own concepts and operational responsibilities.
Extensibility works because the API is treated as a shared language for both intent and automation. Domain-specific objects can make a common task easier and let controllers encode specialist knowledge once rather than forcing every user to reconstruct it. The design test is whether an abstraction hides repetitive complexity without concealing important failure modes. Each new controller or package manager also becomes part of the system’s trusted control plane, so simplicity for the user must be balanced with observability and governance.
Analysis
Kubernetes in Action is a progressive technical guide, not a single narrow recipe. It begins with the pressures that make orchestration useful, moves through the objects application developers manipulate, and then reveals the control plane, security model, resource economics, and extension mechanisms behind them. Its central argument is that Kubernetes is more than a container launcher: it is a declarative system for coordinating application state across machines.
The book’s most durable conceptual move is separating intention from action. A manifest states what should exist; controllers continually compare that claim with observed state and create or remove resources to close the gap. This turns failures and deployments into reconciliation problems rather than sequences of manual commands. The same model explains both the platform’s power and its opacity: actions are asynchronous, distributed, and mediated by multiple components, so a command can succeed before the application is truly usable.
The architecture also makes boundaries the key design question. Pods determine which containers share a lifecycle and network identity. Services separate clients from changing Pod addresses. Claims separate application storage needs from infrastructure details. ServiceAccounts and policies divide authority. These abstractions are useful precisely because each gives a team a stable contract, but contracts can hide important behavior, including delayed endpoint changes, storage limitations, and probe mistakes.
The source is a 2017-era guide, tested around Kubernetes 1.8, and includes features and API versions that have since evolved or been replaced. Its examples should therefore be read as explanations of concepts, not copied blindly into a current cluster. The enduring value lies in understanding the relationships: what declares state, what reconciles it, what a client can observe, and what happens when assumptions fail. Kubernetes reduces repetitive infrastructure work; it does not remove the need to design applications for failure, security, and change.
Review Summary
Kubernetes in Action receives overwhelmingly positive reviews, with readers praising its comprehensive coverage, clear explanations, and logical progression. Many consider it the best book on Kubernetes, suitable for beginners and experienced users alike. Readers appreciate the detailed examples, diagrams, and in-depth exploration of advanced concepts. While some note that certain sections may be outdated due to Kubernetes' rapid evolution, most still find the core content valuable and eagerly anticipate a new edition.
Glossary
Pod
Smallest deployable groupA Pod is Kubernetes’ basic deployable unit. It contains one or more containers that run on the same node and share a network identity. Containers in one Pod can communicate through localhost, while shared files require a volume. Pods are replaceable, so their IP addresses and writable container filesystems should not be treated as permanent.
Reconciliation loop
Desired-state correction cycleA reconciliation loop is the repeated process by which a Kubernetes controller observes resources, compares the actual cluster state with the desired state specified by users, and takes action to reduce the difference. A replica controller, for example, creates missing Pods or removes excess ones. Controllers work through the API server rather than directly commanding node agents.
Service
Stable address for endpointsA Service provides a stable IP address and port for a set of Pods or other endpoints. A selector commonly identifies the Pods included, and Kubernetes updates the associated Endpoints as those Pods change. Clients connect to the Service rather than tracking temporary Pod addresses. Services can also be exposed externally or used to refer to certain external services.
Readiness probe
Test for receiving trafficA readiness probe checks whether a container is ready to serve requests. Kubernetes removes a Pod that fails the check from the endpoints of Services that would send it traffic, but does not restart the container for that reason. Probes can execute a command, make an HTTP request, or attempt a TCP connection.
PersistentVolumeClaim
Request for persistent storageA PersistentVolumeClaim is a namespaced request for storage with specified capacity and access modes. Kubernetes binds it to a suitable PersistentVolume, which represents the underlying storage. A Pod uses the claim rather than naming a storage provider directly. This separates application storage requirements from infrastructure configuration and can support dynamic provisioning.
ConfigMap
Non-secret configuration storeA ConfigMap stores non-sensitive configuration as key-value entries, including complete configuration files. A Pod can expose its contents to containers as environment variables, command arguments, or files through a volume. Separating configuration from an image allows the same application image to be used with different settings, although applications must reload changed files themselves.
StatefulSet
Controller for stable stateful replicasA StatefulSet manages Pods that need stable identities and individual persistent storage. It assigns predictable ordered names, creates separate claims from volume claim templates, and uses a governing headless Service for network discovery. Replacements retain the corresponding identity and storage claim. StatefulSets serialize important scaling actions to reduce the risk of disturbing clustered applications.
HorizontalPodAutoscaler
Automatic replica count controllerA HorizontalPodAutoscaler adjusts the desired replica count of a scalable resource, such as a Deployment, based on measured metrics. In the book’s examples, it uses average CPU utilization relative to requested CPU, and can also use pod or object metrics. It requires a metrics source, configured minimum and maximum replica counts, and suitable workload behavior.
role-based access control (RBAC)
Permissions assigned through rolesRBAC controls which authenticated users, groups, or ServiceAccounts may perform actions on Kubernetes resources. Roles and ClusterRoles specify permitted verbs and resources; RoleBindings and ClusterRoleBindings associate those permissions with subjects. Namespaced bindings constrain access to a namespace, while cluster-level bindings can grant broader access.
CustomResourceDefinition
Registration for a custom resource typeA CustomResourceDefinition registers a new API resource type with Kubernetes, allowing users to create, retrieve, and delete instances through the API server. A custom controller can watch those instances and create standard Kubernetes resources in response. A CRD extends the resource vocabulary, while a controller supplies behavior; without one, instances may simply store data.
Container Network Interface
Plugin contract for pod networkingThe Container Network Interface, or CNI, is a plugin interface used to connect containers to a network. Kubernetes can use different CNI plugins to provide pod connectivity, including communication across nodes and, when supported, network policy enforcement. Kubernetes specifies required networking behavior but does not itself supply every underlying network implementation.
FAQ
What's Kubernetes in Action about?
- Comprehensive Guide: Kubernetes in Action by Marko Luksa is a detailed exploration of Kubernetes, a powerful system for managing containerized applications. It covers fundamental concepts, architecture, and practical applications.
- Hands-On Learning: The book emphasizes practical usage with hands-on tutorials and examples, helping readers apply concepts in real-world scenarios.
- Structured Approach: It is organized into parts that progressively build knowledge, starting from basic concepts to advanced topics, making it suitable for both beginners and experienced users.
Why should I read Kubernetes in Action?
- Expert Insights: Written by Marko Luksa, a recognized Kubernetes expert, the book offers valuable insights and best practices for both beginners and experienced users.
- Real-World Applications: It focuses on real-world scenarios and best practices, preparing readers for challenges in production environments.
- Up-to-Date Content: The book covers the latest features and updates in Kubernetes, ensuring readers learn the most current practices in container orchestration.
What are the key takeaways of Kubernetes in Action?
- Kubernetes Architecture: Readers will gain a thorough understanding of Kubernetes architecture, including the roles of the master and worker nodes.
- Pod Management: The book covers creating, managing, and scaling Pods, which is essential for maintaining application availability and performance.
- Service Discovery: It explains how to expose applications through Services, enabling seamless communication with Pods, crucial for building resilient applications.
What are the best quotes from Kubernetes in Action and what do they mean?
- "Kubernetes is not just a tool; it’s a platform.": This highlights Kubernetes as a comprehensive ecosystem for managing containerized applications.
- "The power of Kubernetes lies in its ability to automate the deployment, scaling, and management of applications.": This emphasizes Kubernetes' core benefit of reducing manual intervention.
- "Understanding the architecture is key to mastering Kubernetes.": This suggests that a solid grasp of Kubernetes' architecture is essential for effective use.
How does Kubernetes in Action explain the concept of Pods?
- Basic Deployable Units: Pods are the smallest deployable units in Kubernetes, containing one or more containers that share the same network namespace.
- Lifecycle Management: The book explains how Pods are managed by controllers to ensure the desired number of Pods are running, handling failures and scaling.
- Communication: It discusses how Pods communicate with each other and external services, emphasizing the importance of networking in Kubernetes.
What is the role of Services in Kubernetes as described in Kubernetes in Action?
- Stable Network Identity: Services provide a stable IP address and DNS name for accessing a set of Pods, abstracting the underlying Pods' IP addresses.
- Load Balancing: Services distribute traffic among the Pods they manage, ensuring no single Pod is overwhelmed, which is crucial for performance.
- Types of Services: The book explains different types of Services, such as ClusterIP, NodePort, and LoadBalancer, each serving specific use cases.
How does Kubernetes in Action address scaling applications?
- Manual and Automatic Scaling: The book discusses both manual scaling through commands and automatic scaling using Horizontal Pod Autoscalers.
- Resource Requests and Limits: It emphasizes setting resource requests and limits for Pods to ensure optimal scheduling and performance.
- Best Practices: Readers are provided with best practices for scaling, including monitoring metrics and adjusting replica counts based on demand.
What are StatefulSets, and how are they explained in Kubernetes in Action?
- Managing Stateful Applications: StatefulSets manage stateful applications requiring stable identities and persistent storage, crucial for databases.
- Stable Network Identity: Each Pod in a StatefulSet has a unique, stable network identity, simplifying the management of clustered applications.
- Persistent Storage: The book explains how StatefulSets work with PersistentVolumeClaims to ensure each Pod has access to its own storage.
How does Kubernetes in Action cover security in Kubernetes?
- Role-Based Access Control (RBAC): The book details how RBAC secures clusters by defining roles and permissions for users and service accounts.
- Pod Security Policies: It introduces Pod Security Policies to control security settings of Pods, adding an additional security layer.
- Network Policies: The book discusses using Network Policies to control traffic between Pods, allowing for fine-grained security controls.
What is the significance of CustomResourceDefinitions (CRDs) in Kubernetes in Action?
- Extending Functionality: CRDs allow users to define custom resources, extending Kubernetes capabilities beyond built-in resources.
- Creating Custom Controllers: The book explains creating custom controllers to manage CRDs, automating the lifecycle of custom resources.
- Real-World Applications: Examples illustrate how CRDs manage specific application types, enhancing Kubernetes' usability for various use cases.
How does Kubernetes manage resources?
- Resource Requests and Limits: Kubernetes allows specifying resource requests and limits for CPU and memory, ensuring containers have necessary resources.
- Scheduling Based on Requests: The Scheduler uses resource requests to determine node suitability, ensuring pods are scheduled on nodes with enough resources.
- Quality of Service Classes: Pods are categorized into QoS classes based on resource requests and limits, helping prioritize pods during resource contention.
What is the role of the Horizontal Pod Autoscaler in Kubernetes?
- Automatic Scaling: The Horizontal Pod Autoscaler adjusts the number of pod replicas based on observed CPU utilization or other metrics.
- Metrics Collection: It relies on metrics collected by cAdvisor and aggregated by Heapster to make scaling decisions.
- Configuration: Users can configure the HPA by specifying target metrics, minimum and maximum replicas, and the resource to monitor.
Download PDF
Download EPUB
.epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.