I need to change the liveness probe we have for our Redis instances and make it fail in case it is not able to return keys (due to being overloaded). Currently, we are just checking if it accepts TCP connections.
livenessProbe:
initialDelaySeconds: 20
periodSeconds: 10
tcpSocket:
port: "redis"
One solution that I can think of is to set and fetch a key from the exec command. But I am not sure how to do that. The commands could be something like this:
set test "test"
get "test"
If the set of commands fail or takes too much time, the liveness should fail.
What would be the best way to implement this?
You can make the liveness and readiness probes to execute a bash script:
livenessProbe:
exec:
command:
- /bin/sh
- /health.sh
initialDelaySeconds: 60
periodSeconds: 100
And add the part were you login to the Redis instance from inside with the redis cli and if fails exit code anything but 0