Kubernetes Patterns, 2nd Edition (Early Release)
The evolution of microservices and containers in recent years has significantly changed the way we design, develop, and run software. Modern architectures require an entirely new set of patterns and practices.
Kubernetes Patterns presents reusable patterns and principles for designing and implementing cloud native applications on Kubernetes. This book is ideal for developers and architects familiar with basic Kubernetes concepts who want to learn how to solve common cloud native challenges with proven design patterns.
Download the e-book to explore:
Foundational patterns covering core principles and practices for building and running container-based cloud native applications
Behavioral patterns that delve into finer-grained concepts for managing various types of container and platform interactions
Structural patterns for organizing containers within a Pod to address specific use cases
Configuration patterns that provide insight into how to handle application configurations in Kubernetes
Security patterns for hardening access to cloud native applications running on Kubernetes
Advanced patterns that cover more complex topics such as operators and autoscaling
Note: This preview edition download contains chapters 1–5.
With Early Release ebooks, you get books in their earliest form—the authors’ raw and unedited content as they write— so you can take advantage of these technologies long before the official release of these titles.
Liveness checks are useful for keeping applications healthy by killing unhealthy containers and replacing them with new ones. But sometimes a container may not be healthy, and restarting it may not help either. The most common example is when a container is still starting up and not ready to handle any requests yet. Or maybe a container is overloaded, and its latency is increasing, and you want it to shield itself from additional load for a while.
For this kind of scenario, Kubernetes has readiness probes. The methods (HTTP, TCP, Exec, gRPC) and timing options for performing readiness checks are the same as liveness checks, but the corrective action is different. Rather than restarting the container, a failed readiness probe causes the container to be removed from the service endpoint and not receive any new traffic. Readiness probes signal when a container is ready so that it has some time to warm up before getting hit with requests from the service. It is also useful for shielding the container from traffic at later stages, as readi ness probes are performed regularly, similarly to liveness checks. Example 2-2 shows how a readiness probe can be implemented by probing the existence of a file the application creates when it is ready for operations.
Example 2-2. Container with readiness probe
apiVersion: v1 kind: Pod metadata: name: pod-with-readiness-check spec: containers: - image: k8spatterns/random-generator:1.0 name: random-generator readinessProbe: exec: command: [ "stat", "/var/run/random-generator-ready" ]
(1) Check for the existence of a file the application creates to indicate it’s ready to
serve request. stat returns an error if the file does not exist, letting the readiness