我正在嘗試使用此啟動探針
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。
到底是怎么回事 ??
uj5u.com熱心網友回復:
您需要啟動一個 shell 來運行您的腳本:
startupProbe:
exec:
command:
- sh
- -c
- >-
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/432962.html
標籤:Kubernetes 启动探针
上一篇:調度何時應用于pod?
