To do this, The image must have shell (sh/bash) and curl version 8+ and this script will always return “TRUE” for 90 seconds then to the real probe.
readinessProbe:
exec:
command:
- "sh"
- "-c"
- |
# Get the pod's uptime in seconds
POD_UPTIME=$(cat /proc/1/stat | awk '{print $22}')
CURRENT_TIME=$(date +%s)
SECONDS_UP=$((CURRENT_TIME - POD_UPTIME / 100))
# Check if the pod has been up for more than 90 seconds
if [ $SECONDS_UP -lt 90 ]; then
echo "Pod uptime is less than 90 seconds"
exit 0
fi
# If pod uptime is more than 90 seconds, run the curl check
curl --fail -o /dev/null -sS -m 2 127.0.0.1:3000/health
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 3
Good luck.