I have a process running inside an Ubuntu container and would like to redeploy the container if the process gets killed. I added the following liveness probe in container spec
livenessProbe:
exec:
command:
- ps -ef | grep my_process_name
initialDelaySeconds: 120
periodSeconds: 30
However this doesnt work. When I do a kubectl describe pods <pod_id>
I get the following event.
1h 6m 20 {kubelet k8s-agent-71e8d996-0} spec.containers{my_process_name} Warning Unhealthy Liveness probe failed: rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"ps -ef | grep my_process_name\\\": executable file not found in $PATH\"\n"
And it keeps redeploying the container. If I bash into the container and do a 'ps -ef' it works but this doesnt Whats a good way to use the liveness probe to check if a process is running or not ? Thanks.
Clearly ps
is not being found in the path. You could try using /bin/ps
instead of ps
.