0
0
KubernetesConceptBeginner · 3 min read

What Is Readiness Probe in Kubernetes: Simple Explanation and Example

A readiness probe in Kubernetes is a check that tells the system if a container is ready to accept traffic. It helps Kubernetes know when to send requests to a pod by confirming the app inside is fully up and running.
⚙️

How It Works

Think of a readiness probe like a restaurant's "Open" sign. Even if the restaurant building is there, the kitchen might not be ready to serve food yet. The readiness probe checks if the app inside the container is ready to handle requests before letting traffic in.

Kubernetes runs this check regularly by calling a command, HTTP endpoint, or TCP socket inside the container. If the probe says "ready," Kubernetes sends user requests to that pod. If not, it waits and keeps checking until the app is ready.

💻

Example

This example shows a readiness probe using an HTTP GET request to check if the app responds on port 8080 at path /health. Kubernetes will only send traffic to the pod when this check passes.

yaml
apiVersion: v1
kind: Pod
metadata:
  name: example-pod
spec:
  containers:
  - name: example-container
    image: nginx
    readinessProbe:
      httpGet:
        path: /health
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 10
Output
Kubernetes checks the /health endpoint on port 8080 every 10 seconds after waiting 5 seconds from container start. If the endpoint returns a success status, the pod is marked ready.
🎯

When to Use

Use readiness probes when your app needs time to start or load data before it can serve requests. This prevents users from getting errors by sending traffic too early.

For example, if your app connects to a database or loads configuration on startup, a readiness probe ensures Kubernetes waits until these steps finish. It is also useful during rolling updates to avoid sending traffic to pods that are not ready yet.

Key Points

  • Readiness probes check if a container is ready to receive traffic.
  • They can use HTTP, TCP, or command checks.
  • Kubernetes stops sending traffic to pods that fail readiness checks.
  • They help improve app reliability and user experience.

Key Takeaways

Readiness probes tell Kubernetes when a pod is ready to accept traffic.
They prevent sending requests to pods that are still starting or not fully ready.
Use HTTP, TCP, or command checks to define readiness probes.
Proper readiness probes improve app stability and user experience.