Understanding Kubernetes: Part 35 Readiness Probe
Last updated
Last updated
📢 If you’ve been following our Kubernetes series 2025, welcome back! For new readers, check out Liveness Probe
A Readiness Probe in Kubernetes is a diagnostic tool used to determine if a pod is ready to serve traffic. Unlike the Liveness Probe, which checks if a pod is still running, the readiness probe checks whether the pod is ready to accept requests. If the readiness probe fails, the pod is considered not ready, and Kubernetes will stop sending traffic to it. However, the pod will not be restarted (unlike in the case of a liveness probe failure).
For example:
Consider a web application pod that takes some time to initialize after being started (e.g., loading configurations, establishing database connections, etc.). You don’t want Kubernetes to send traffic to the pod until it is fully initialized. In such a scenario, you can use a readiness probe to ensure the pod only starts receiving traffic once it’s ready to handle requests.
Readiness Probe Capabilities:
Types of Checks: Like the liveness probe, readiness probes can use HTTP requests, TCP socket connections, or execute commands to check the pod’s readiness.
HTTP Check: Sends an HTTP request to a specified path and expects a successful response (e.g., 200 OK).
TCP Check: Tries to establish a TCP connection on a specified port.
Exec Check: Executes a command inside the container. If the command succeeds (exit code 0), the pod is considered ready.
Failure Thresholds: You can configure how many consecutive failures must occur before Kubernetes considers the pod not ready.
Customizability: The readiness probe can be configured with parameters such as initialDelaySeconds
, periodSeconds
, timeoutSeconds
, successThreshold
, and failureThreshold
.
In my previous role:
As a Senior DevOps Engineer, I used readiness probes to manage the traffic routing for services that had complex initialization processes. For example, I configured a web application to check the availability of its database before accepting any traffic. If the readiness probe failed, Kubernetes would ensure that no requests were routed to the pod until the database was accessible. This helped ensure that users never experienced failed requests due to the application being in an unready state.
Here’s a simple YAML for a Readiness Probe:
HTTP Readiness Probe:
In this example:
The readinessProbe
sends an HTTP GET request to the /readiness
endpoint on port 8080
of the web-container
.
The probe will start checking after a delay of 10 seconds (initialDelaySeconds
), then continue every 5 seconds (periodSeconds
).
If the probe takes longer than 2 seconds to respond, it will fail (timeoutSeconds
).
If the probe fails 3 consecutive times (failureThreshold
), the pod will be marked as not ready and will stop receiving traffic.
TCP Readiness Probe:
In this example:
The readinessProbe
attempts to establish a TCP connection on port 3306
to check if the database service is ready.
The probe checks every 10 seconds, starting after an initial delay of 5 seconds.
Readiness probes are critical for ensuring that Kubernetes only sends traffic to pods that are ready to handle it. They help avoid service disruptions by preventing traffic from reaching pods that are still initializing or in a non-ready state.
Take your Kubernetes journey to the next level with the Master Kubernetes: Zero to Hero course! 🌟 Whether you’re a beginner or aiming to sharpen your skills, this hands-on course covers:
✅ Kubernetes Basics — Grasp essential concepts like nodes, pods, and services. ✅ Advanced Scaling — Learn HPA, VPA, and resource optimization. ✅ Monitoring Tools — Master Prometheus, Grafana, and AlertManager. ✅ Real-World Scenarios — Build production-ready Kubernetes setups.
Don’t miss your chance to become a Kubernetes expert! 💻✨
Apply Code DEVOPS20 for 20% OFF!
🔥 Start Learning Now: [Join the Master Kubernetes Course + FREE Access to Terraform Course]()
🚀 Stay ahead in DevOps and SRE! 🔔 and never miss a beat on Kubernetes and more. 🌟
🔥 Start Learning Now: