我有一个在 Ubuntu 容器内运行的进程,如果该进程被终止,我想重新部署该容器。我在容器规范中添加了以下活性探针
livenessProbe:
exec:
command:
- ps -ef | grep my_process_name
initialDelaySeconds: 120
periodSeconds: 30
Run Code Online (Sandbox Code Playgroud)
然而这不起作用。当我做一个kubectl describe pods <pod_id>
我得到以下事件。
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"
Run Code Online (Sandbox Code Playgroud)
它不断重新部署容器。如果我猛击容器并执行“ps -ef”,它会起作用,但这不是使用活性探针检查进程是否正在运行的好方法?谢谢。
确保ps
已安装。如果不运行:apt-get update && apt-get install procps
为了方便复制粘贴OP在问题下的评论:-)。
下面worker.py
是需要检查的过程:
livenessProbe:
exec:
command:
- /bin/bash
- -c
- ps -ef | grep worker.py | grep -v grep
initialDelaySeconds: 10
periodSeconds: 10
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4361 次 |
最近记录: |