0

我正在使用 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。
(以上两个配置属于不同的应用程序。)

4

1 回答 1

2

您需要实际使用外壳,因为这是外壳功能。sh -c "foo | bar"管他呢。还要记住,所有相关命令都需要在目标图像中可用。

于 2021-05-09T23:04:53.313 回答