Kubernetes Readiness Probes

 Kubernetes Readiness Probes

Description

  • We understand that liveness probes and the way they assist keep our apps healthy by ensuring unhealthy containers are restarted automatically. Same like liveness probes, Kubernetes permit us to also define a readiness looked for our pod.
  • The readiness probe is deployed periodically and examines whether the precise pod should receive client requests or not.
  • Whenever a container’s readiness probe returns back success, it’s signaling that the container is ready to simply accept requests.
  • This notion of being prepared is clearly something that’s specific to every container.
  • Almost as liveness probe Kubernetes sends requests to container and supported the result either successful or unsuccessful response it decides container is prepared to require traffic or still preparing for that.
  • The liveness probes not like, if a container fails the readiness check, it won’t be killed or restarted. 
  • This is a very good practice to always add readiness probe even it’s a simplest app within the container.

Readiness Probe Types

There are three sorts of Readiness Probe.

1.HTTP GET

  • This type of probe conveyed request on the container’s IP address, a port and path we specify.
  • The Probe is always taken into account a failure and container are going to be treated as not ready and no traffic will get diverted thereto .

2.TCP SOCKET

  • TCP Socket probe struggle to open a TCP connection to the required port of the container.
  • If the connection is built successfully, container would marked as ready and it’ll receive traffic.
  • Kubernetes in other case will wait and runs the probe to see the status again.

3.EXEC Probe

  •  The EXEC probe executes some commands you provide inside the container and checks the command’s exit status code.
  • The probe is successful if the status code is 0.
  • 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:/

2 thoughts on “Kubernetes Readiness Probes”

Leave a Comment