Probes, Logging, and Debugging
SummaryIntroduces Kubernetes observability through health probes (startup, liveness,...
Introduces Kubernetes observability through health probes (startup, liveness,...
Introduces Kubernetes observability through health probes (startup, liveness, readiness), container logging, cluster events, and ephemeral debug containers. Covers how probes govern Pod lifecycle, how kubectl logs and events surface runtime behavior, and how ephemeral containers enable live debugging of distroless or stripped-down images.
Probes, Logging, and Debugging
Production clusters run thousands of containers. Some freeze. Some crash. Some start accepting traffic before the application has finished initializing. Without a feedback mechanism, Kubernetes would route requests to containers that cannot handle them, leave deadlocked processes running indefinitely, and provide no visibility into why a workload failed.
Kubernetes addresses this with three categories of observability tooling.
Health probes let containers report their own status. A startup probe protects slow-starting applications from premature termination. A liveness probe detects containers that are running but no longer functional — a deadlock, an unrecoverable state, a hung process — and triggers a restart. A readiness probe signals whether a container can handle incoming traffic; failing it removes the Pod from Service endpoints without killing it. Together, these three probes give Kubernetes granular control over the Pod lifecycle.
Logging and events provide the diagnostic trail. Container logs capture stdout and stderr output — application logs, error traces, startup messages. Cluster events record state transitions: image pulls, scheduling decisions, probe failures, OOM kills. When a Pod misbehaves, logs and events are the first place to look.
Ephemeral debug containers solve a problem that minimal container images create. Distroless images and scratch-based containers ship without shells, package managers, or diagnostic tools. Attaching an ephemeral container to a running Pod gives you a full debugging toolkit — curl, dig, strace, tcpdump — without modifying the original image or restarting the Pod.
What This Chapter Covers
The following sections provide:
-
Liveness, Readiness, and Startup Probes: Probe types, mechanisms (HTTP, exec, TCP, gRPC), tuning parameters, common mistakes, and a complete multi-probe YAML manifest.
-
Logging, Events, and Debug Containers: kubectl logs variations, event inspection, a systematic approach to diagnosing common Pod failure states (Pending, CrashLoopBackOff, ImagePullBackOff, Running-but-unreachable), and hands-on use of ephemeral containers. Ends with exercises covering probe configuration and debugging workflows.
These topics map directly to the CKAD exam’s observability domain. Tasks may ask you to add a liveness probe to an existing Deployment, retrieve logs from a crashed container, or diagnose why a Pod is stuck in Pending.