GCP 云 运行:一份作业和“配置 <servicename> 没有任何准备好的修订版

GCP Cloud Run: One off jobs and "Configuration <servicename> does not have any ready Revision

我创建了一个非常简单的图像,它执行一次性作业(打印一些虚拟日志)并按如下方式退出:

➣ $ cat Dockerfile
from alpine:latest

COPY entrypoint.sh /usr/local/bin/entrypoint

ENTRYPOINT ["entrypoint"]

CMD ["100"]

...其中

➣ $ cat entrypoint.sh
#!/bin/sh

ITERATIONS=${1:-1000}
counter=1

while [ "$counter" -le "$ITERATIONS" ]; do
    echo "Executing and logging iteration no $counter"
      counter=$(($counter + 1))
done

尝试部署到云端时 运行、

使用以下命令:

gcloud beta run deploy logger --image=pkaramol/logging --cluster=pkaramol-cloudrun

失败并显示以下我无法解码的消息:

Service name (logging): logger Deploying container to Cloud Run on GKE service [logger] in namespace [default] of cluster [pkaramol-cloudrun] X Deploying new service... Configuration "logger" does not have any ready Rev ision. - Creating Revision... X Routing traffic... Configuration "logger" does not have any ready Revisio n. Deployment failed ERROR: (gcloud.beta.run.deploy) Configuration "logger" does not have any ready Revision.

...在其他一些情况下,需要很长时间

Deploying container to Cloud Run on GKE service [mylogger] in namespace [default] of cluster [pkaramol-cloudrun]
⠶ Deploying new service... Configuration "mylogger" is waiting for a Revision
 to become ready.
  ⠶ Creating Revision...
  . Routing traffic...

有什么建议吗?

当您的容器启动时,它必须启动一个程序作为 HTTP 服务器在端口 $PORT (8080) 上响应。

您几乎可以 运行 容器中的任何软件。接口是 HTTP Request/Response。 CPU 在 HTTP 请求之间空闲。

您的容器不符合 Cloud 运行 要求,当 Cloud 运行 在端口 $PORT 上检测到无响应/不正确响应时终止。

阅读此文档以更好地理解软件要求:

Container runtime contract