0

我正在尝试使用此启动探针

          startupProbe:
            exec:
              command:
                - >-
                  test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd="v" | grep -E 'r5|v5' | wc -l) -eq 2 && echo $? || echo $?
            initialDelaySeconds: 5 #How many seconds to wait after the container has started
            timeoutSeconds: 1 #Timeout of the probe
            successThreshold: 1 #Threshold needed to mark the container healthy
            periodSeconds   : 10 #Wait time between probe executions
            failureThreshold: 110 #Threshold needed to mark the container unhealthy.

这是一个 Java 应用程序,可能需要很长时间(约 15 分钟)才能加载一些组件。这是一个遗留应用程序,我对此无能为力。

我正在响应响应,试图得到两行结果,然后返回 0 或 1 作为退出代码供探针决定。

虽然我得到了他的错误

Startup probe errored: rpc error: code = Unknown desc = failed to exec in container: failed to start exec "8ad860ffc7a87e95fb65e37dc14945c04fa205f9a524c7f7f08f9d6ef7d75": OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd=\"v\" | grep -E 'r5|v5' | wc -l) -eq 2 && echo $? || echo $?": stat test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd="v" | grep -E 'r5|v5' | wc -l) -eq 2 && echo $? || echo $?: no such file or directory: unknown

如果我不使用该&& echo $? || echo $?部件,则探针会抛出退出代码为2而不是的错误1

到底是怎么回事 ??

4

1 回答 1

2

您需要启动一个 shell 来运行您的脚本:

startupProbe:
  exec:
    command:
    - sh
    - -c
    - >-
      ...
于 2022-02-24T03:13:13.973 回答