我正在使用 Exec 探针添加活性探针和就绪探针。
我的配置如下所示:
readinessProbe:
exec:
command: "/usr/bin/jps -l | grep QueueProcess"
periodSeconds: 10
failureThreshold: 2
successThreshold: 2
当上述方法不起作用时。我修改了这个并也尝试过:
readinessProbe:
exec:
command: ["/usr/bin/jps", "-l", "|", "grep","QueueProcess"]
periodSeconds: 10
failureThreshold: 2
successThreshold: 2
运行
kubectl describe pod
时,得到以下输出:
Normal Created 37s kubelet Created container app1
Normal Started 37s kubelet Started container app1
Warning Unhealthy 6s (x3 over 26s) kubelet Readiness probe failed: invalid argument count
usage: jps [-help]
jps [-q] [-mlvV] [<hostid>]
Definitions:
<hostid>: <hostname>[:<port>]
我尝试了另一个应用程序,我正在其中运行
grpcurl
来调用健康检查:
readinessProbe:
exec:
command: ["grpcurl", "-plaintext", "-protoset", "/app/HealthCheck.protoset", "localhost:8123", "service.HealthCheckService/GetHealthCheck","|", "jq", ".", "|","grep","200"]
periodSeconds: 10
failureThreshold: 2
successThreshold: 2
在运行
kubectl describe pod
时,我得到:
Normal Created 23s kubelet Created container app2
Normal Started 23s kubelet Started container app2
Warning Unhealthy 3s (x2 over 13s) kubelet Readiness probe failed: Too many arguments.
Try 'grpcurl -help' for more details.
这两者都失败了。 问题是,我怎样才能写一个里面有一个管道(或多个管道)的
Exec probe
?
我正在使用 EKS v1.18。
(以上两个配置属于不同的应用程序。)
您需要实际使用 shell,因为这是 shell 功能。
sh -c "foo | bar"
或其他什么。另请记住,所有相关命令都需要在目标图像中可用。
所以你的 YAML 应该是这样的:
readinessProbe:
exec:
command: ["sh", "-c", "/usr/bin/jps -l | grep QueueProcess"]
periodSeconds: 10
failureThreshold: 2
successThreshold: 2