我正在尝试将测试功能从 Gen1 移至 Gen2。我通过控制台将其删除,并使用以下命令(通过 Github 操作)进行部署。我在底部收到错误,这没有意义,因为我没有指定任何内存大小。
有人经历过吗?
gcloud -q functions deploy hello_world \
--gen2 \
--runtime python310 \
--trigger-http \
--allow-unauthenticated \
--region us-central1 \
--source functions/src \
--service-account=${{ secrets.GCP_SA_EMAIL }}
ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[OK],
message=[Could not create Cloud Run service hello-world.
spec.template.spec.containers.resources.limits.memory: Invalid value
specified for memory. For the specified value, maxScale may not exceed 83.
错误信息:
spec.template.spec.containers.resources.limits.memory: Invalid value
specified for memory. For the specified value, maxScale may not exceed 83.
意味着现有的第 1 代云函数可能将 maxScale 设置为大于 83。根据 文档,迁移到 gen2 默认内存可能默认为 256 MB,并且最大比例大于 83,这可能是给出以上错误。
因此我设置了
--max-instances=30
根据内存平衡最大实例。
但是您也可以根据需要修改此值 --max-instances .
同样适用于
--memory
标志。
更新的命令将是:
gcloud -q functions deploy hello_world \
--gen2 \
--runtime python310 \
--memory=512MiB \
--max-instances=30 \
--trigger-http \
--allow-unauthenticated \
--region us-central1 \
--source functions/src \
--service-account=${{ secrets.GCP_SA_EMAIL }}
参考:gcloud功能部署