I have a file in /tmp/healthy
as mentioned in official documentation and YAML is available
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
But in my case file always be here and it will contain message like Success or Failure
It is possible with livenessProbe:command
to behave on these messages?
The point of a liveness probe is usually just to check if a pod is up and reachable. cat
is decent command to use for liveness probes because it always returns success as long as the file is there. It is just checking if Kubelet can reach the pod.
If I'm understanding what you mean though, it is possible to have the result of the liveness probe depend on the contents of the file. You can execute any bash and exit with a 1 or 0 (fail or suceed) to control the result you want.
For example, if you want the liveness probe to fail if your file contains any failure message:
livenessProbe:
exec:
command:
- /bin/bash
- '-c'
- grep -zqv "Failure" file.txt