The container-level health-checking system that lets Kubernetes decide when to restart a container, when to stop sending it traffic, and when to give a slow-starter time to initialize. A core Workloads & Troubleshooting topic on the CKA exam. Synthesized from CKA Day 18 — Kubernetes Health Probes Explained.
The Problem: Kubernetes Is Blind Without Probes
By default, Kubernetes only knows whether a container’s main process is running. It has no insight into:
Whether the application has finished initializing (database connections, cache warm-up)
Whether the application is functionally healthy (responding to requests, not deadlocked)
Whether the application is in a degraded state that warrants a restart
Probes are user-defined health checks that run inside or against containers. The kubelet on each node executes them and reacts according to their results.
The Three Probe Types
Probe
Question It Answers
Action on Failure
Scope
Liveness
Is the container alive and should keep running?
Restart the container
Container
Readiness
Is the container ready to serve traffic?
Remove from Service Endpoints
Pod + Service
Startup
Has a slow-starting container finished booting?
Disable other probes until success
Container (guard)
Golden Rule: Liveness protects the container (kill & restart), Readiness protects the Service (stop routing traffic), Startup protects slow starters (prevent premature death).
Probe Mechanisms
Kubernetes can check health in four ways. The mechanism is declared under the probe block (livenessProbe, readinessProbe, or startupProbe).
1. HTTP GET Probe
Sends an HTTP GET request to a specified path and port. Any response code between 200 and 399 is considered success.
RBAC Note: Paths like /healthz, /livez, /readyz, and /metrics are non-resource URLs in Kubernetes RBAC. Granting external monitoring systems access to these endpoints requires a ClusterRole with nonResourceURLs rules, bound via ClusterRoleBinding. See Kubernetes RBAC for the full ClusterRole pattern. Source: CKA Day 24
Field
Description
path
URL path to request
port
Container port (name or number)
httpHeaders
Optional headers to send
scheme
HTTP (default) or HTTPS
Best for: Web applications, REST APIs, microservices with a dedicated health endpoint.
2. TCP Socket Probe
Attempts to open a TCP connection to the specified port. Success = connection established.
Total time before liveness restart = 30 + (10 × 3) = 60 seconds
Exam Trap: Many candidates assume failureThreshold: 3 means 3 seconds. It means 3 probe periods.
Liveness Probe Deep Dive
Purpose
Detect when a container has entered a broken but running state — infinite loops, deadlocks, memory leaks that haven’t caused an OOMKill, or thread starvation.
What Happens on Failure?
kubelet marks the container as failed
kubelet kills the container process (SIGTERM, then SIGKILL after grace period)
kubelet creates a new container from the same image
The Pod stays on the same node; its IP may or may not change depending on restart policy
Restart count increments (kubectl get pod shows RESTARTS)
If a container takes 2 minutes to start but liveness begins after 10 seconds with failureThreshold: 3, it will be killed before ever becoming healthy. This is the classic “crash loop” caused by misconfigured probes.
Fix: Add a startup probe with a generous failureThreshold.
Readiness Probe Deep Dive
Purpose
Determine whether a container is ready to accept traffic. An application may be running but not yet usable (e.g., loading configuration, warming caches, waiting for a leader election).
What Happens on Failure?
kubelet marks the Pod as NotReady
The Pod’s IP is removed from the Service’s EndpointSlice (and Endpoints object)
kube-proxy stops routing new traffic to this Pod
Existing connections are NOT terminated — only new requests are affected
Once readiness succeeds again, the IP is re-added automatically
New Pods must pass readiness before the Deployment counts them as “available”
Old Pods are terminated only after new Pods are ready
If readiness never succeeds, the rollout stalls — this is a common deployment failure mode
Readiness and Autoscaling
HPA counts only ready replicas when calculating current utilization. A Pod that is Running but NotReady does not count toward the replica target, which can cause HPA to scale up unnecessarily. Source: CKA Day 17
Startup Probe Deep Dive
Purpose
Give slow-starting containers (JVM apps, ML model loading, large dependency downloads) enough time to initialize without being killed by aggressive liveness checks.
How It Works
While the startup probe is running, liveness and readiness probes are disabled
Once the startup probe succeeds, liveness and readiness begin their normal cycles
If the startup probe fails up to failureThreshold, the container is restarted
If no startup probe is defined, liveness and readiness start immediately after container creation
Write probes from memory: You will see YAML-writing questions. Memorize the structure: probeType: { mechanism: { ... }, timingFields }
Check events first:kubectl describe pod <name> | grep -i probe`
Endpoint check:kubectl get endpoints <svc> shows whether readiness is working
Restart count:kubectl get pod <name> → RESTARTS column tells you if liveness is firing
No imperative probe support:kubectl run cannot add probes. Use YAML manifests or kubectl create with --dry-run=client -o yaml and edit.
Production Best Practices
Practice
Rationale
Separate /healthz and /ready
Liveness checks “not deadlocked”; readiness checks “dependencies up”. They often test different things.
Always use startup probes for slow apps
JVM, .NET, ML models — anything with >30s startup time.
Keep liveness stricter than readiness
Liveness should catch real failure; readiness should tolerate brief dependency hiccups.
Don’t probe external dependencies in liveness
If a database is down, you don’t want to restart every app Pod. Keep liveness local.
Set timeoutSeconds realistically
Default 1s is too aggressive for remote endpoints or busy containers.
Log probe traffic separately
Exclude health-check endpoints from application request logs to reduce noise.
Practical Practice
Exam-style hands-on tasks for this topic. Complete each task before reviewing the solution. Time yourself — CKA tasks average 5–7 minutes.
Task 1: Add a Liveness Probe to a Deployment
You are asked to add a liveness probe httpGet on /healthz port 8080 to an existing Deployment web.
Requirements: The probe must restart the container on 3 consecutive failures, checking every 10s after an initial delay of 30s.
Verification:kubectl get pod -l app=web shows 0 restarts under normal conditions.
Solution:
kubectl get deployment web -o yaml > web.yaml# Edit web.yaml to add under containers[]:# livenessProbe:# httpGet:# path: /healthz# port: 8080# initialDelaySeconds: 30# periodSeconds: 10# failureThreshold: 3kubectl apply -f web.yaml
Task 2: Add a Readiness Probe to a Database Pod
You are asked to add a readiness probe tcpSocket on port 3306 to a database Pod mysql.
Requirements: The probe should remove the Pod from Service Endpoints if the port is unreachable.
Verification:kubectl get endpoints mysql includes the Pod IP only when ready.
Solution:
kubectl get pod mysql -o yaml > mysql.yaml# Edit mysql.yaml to add under containers[]:# readinessProbe:# tcpSocket:# port: 3306# initialDelaySeconds: 5# periodSeconds: 5kubectl apply -f mysql.yaml
Task 3: Fix a Pod That Keeps Restarting Due to a Bad Liveness Probe
A Pod keeps restarting. You inspect the liveness probe and find a path/port mismatch.
Requirements: Identify the mismatch, edit the Pod or Deployment, and verify the restarts stop.
Verification:kubectl get pod <pod> shows stable RESTARTS count.
Solution:
kubectl describe pod <pod> | grep -A 10 Events# Look for "Liveness probe failed: HTTP probe failed with statuscode 404" or connection refused.# Common fixes: correct the path to the actual health endpoint, or change the port to the container's listening port.kubectl edit deployment <deployment># Adjust livenessProbe.httpGet.path and port to match the application.