如何否定在Kubernetes livenessProbe中使用的退出代码状态
我将使用grep命令,下面我想做一个检查。
grep没有命中grep有命中由于通常情况下,grep将返回0,如果有命中,我能否定如下所示吗?
!$(cat filet.txt | grep keyword)发布于 2021-09-23 04:26:43
是的,你可以试一试
例子:
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 T1
echo 'Test' | grep -c N外壳脚本
#!/bin/sh
if [ $(echo 'Test' | grep -c T) ]; then
exit 1
else
exit 0
fi最简单的方法是编写shell脚本,并根据您的需要管理活动退出代码0或1,并根据该活性重新启动结荚。
livenessProbe:
exec:
command:
- /bin/sh
- -c
- /home/test/health.shhttps://stackoverflow.com/questions/69293621
复制相似问题