问题描述
我正在使用 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",".","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。
(以上两个配置属于不同的应用。)
解决方法
您需要实际使用外壳,因为这是外壳功能。 sh -c "foo | bar"
之类的。还要记住,所有相关命令都需要在目标图像中可用。