Reputation: 111
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.
Upvotes: 10
Views: 11549
Reputation: 11013
Make sure ps
is installed. If it does not run: apt-get update && apt-get install procps
For the ease of copy-pasting OP's comment under the question :-).
Below, worker.py
is the process that needs to be checked:
livenessProbe:
exec:
command:
- /bin/bash
- -c
- ps -ef | grep worker.py | grep -v grep
initialDelaySeconds: 10
periodSeconds: 10
Upvotes: 13
Reputation: 8827
Clearly ps
is not being found in the path. You could try using /bin/ps
instead of ps
.
Upvotes: 0