如何否定要使用的退出代码状态Kubernetes
livenessProbe
?
我将使用该grep
命令,我想在下面做一个检查。
grep
没有命中则返回退出值 0grep
有命中由于通常情况下,如果命中,grep 将返回 0,我可以像下面显示的那样否定它吗?
!$(cat filet.txt | grep keyword)
是的,你可以试试
例子 :
livenessProbe:
exec:
command:
- /bin/bash
- -c
- cat filet.txt | grep keyword
initialDelaySeconds: 10
periodSeconds: 10
如果有帮助,你应该结帐
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
你也可以试试 -c
echo 'Test' | grep -c T
1
echo 'Test' | grep -c N
0
外壳脚本
#!/bin/sh
if [ $(echo 'Test' | grep -c T) ]; then
exit 1
else
exit 0
fi
最简单的方法是编写 shell 脚本并根据需要管理活跃度的退出代码 0 或 1,并根据活跃度将重新启动 pod。
livenessProbe:
exec:
command:
- /bin/sh
- -c
- /home/test/health.sh
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句