Directory Image
This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Privacy Policy.

Kubernetes Readiness Probes

Author: Mansoor Ahmed
by Mansoor Ahmed
Posted: Oct 21, 2020

Kubernetes Readiness Probes

  • We already know about liveness probes and how they help keep our apps healthy by ensuring unhealthy containers are restarted automatically.

  • Similar to liveness probes, Kubernetes allows us to also define a readiness probe for our pod.

  • The readiness probe is invoked periodically and determines whether the specific pod should receive client requests or not.

  • When a container’s readiness probe returns success, it’s signaling that the container is ready to accept requests.

  • This notion of being ready is obviously something that’s specific to each container.

  • Same as liveness probe Kubernetes sends requests to container and based on the result either successful or unsuccessful response it decides container is ready to take traffic or still getting ready for that.

  • Unlike liveness probes, if a container fails the readiness check, it won’t be killed or restarted.

  • It is good practice to always add readiness probe even it’s a simplest app in the container.

Readiness Probe Types

There are three types of Readiness Probe.

  1. HTTP GET

  • This type of probe send request on the container’s IP address, a port and path we specify.

  • Probe is considered a failure and container will be treated as not ready and no traffic will get diverted to it.

  1. TCP SOCKET

  • TCP Socket probe tries to open a TCP connection to the specified port of the container.

  • If the connection is established successfully, container will marked as ready and it will receive traffic.

  • Otherwise, Kubernetes will wait and runs the probe to check the status again.

  1. EXEC Probe

  • An EXEC probe executes some commands you provide inside the container and checks the command’s exit status code.

  • If the status code is 0, the probe is successful.

  • All other codes are considered failures.

Readiness Probe Examples

my-rn-exec.yaml

Kind: Pod

apiversion: v1

metadata:

name: myapp-rn-exc

Spec:

Containers:

-name: my app

image: ahmedmansoor/hi

Ports:

-containerPort: 80

Readiness Probe:

exec:

command:

-ls

  • tmp/ready

my-rn-tcp.yaml

Kind: Pod

apiversion: v1

metadata:

name: myapp-rn-tcp

Spec:

Containers:

-name: my app

image: ahmedmansoor/hi

Ports:

-containerPort: 80

Readiness Probe:

tcpSocket

Port : 8080

my-rn-http.yaml

Kind: Pod

apiversion: v1

metadata:

name:myapp-rn-http

Spec:

Containers:

-name: my app

image: ahmedmansoor/hi

Ports:

-containerPort:80

Readiness Probe:

http Get:

Port: 80 path:/

About the Author

Mansoor Ahmed Chemical Engineer,Web developer

Rate this Article
Leave a Comment
Author Thumbnail
I Agree:
Comment 
Pictures
Author: Mansoor Ahmed

Mansoor Ahmed

Member since: Oct 10, 2020
Published articles: 124

Related Articles