How to implement multiple handlers in readinessprobe

51 views Asked by At

We have a requirement to have both http and exec in a single readiness probe.

Check 1: Launch a particular URL and check if we get a success response Check 2: Execute a UNIX script/code to check some availability of files

If both the checks are success then the pod can be declared as ready.

We tried below. It seems multiple handles under single readinessProbe is not supported. Is there any other alternative simple way to achieve this?

readinessProbe:
  exec:
   command:
   - /bin/sh
   -c
   - "unix script to run"
 httpGet:
   path: /http url
 intialDelaySeconds: 60
 periodSeconds: 10
 timeoutSeconds: 10
1

There are 1 answers

0
iamwillbin On

I agree with Mr larsks' comment.

You can create a custom script that performs both http check and internal health checks. Use this script as the command in an exec probe.

The script should exit with a 0 status code if both checks pass, indicating readiness.

Here's an example:

#!/bin/bash

# Perform HTTP check
curl -f http://localhost:8080/healthz > /dev/null
if [[ $? -ne 0 ]]; then
  exit 1
fi

# Perform internal health checks
# ... (add your internal checks here)

exit 0