如何在 cloudbuild.yaml 中指定用于云运行的自定义 service.yaml?

Isb*_*ter 6 google-cloud-platform google-cloud-build google-cloud-run cloudbuild.yaml

我在 Google Cloud Run 服务上部署了一个 docker 容器。它有一个非常基本的cloudbuild.yaml文件,可以从 git 推送到主分支触发。

\n

我希望将云运行机的内存从512MB自动增加到8GB。我知道可以在 Cloud Run UI 中单击“EDIT @\xc2\xa0DEPLOY NEW REVISION”,然后手动选择 8gb。但我希望自动进行此设置。

\n

您可以通过以下方式从 Cloud Run 获取 .yaml:

\n
gcloud run services describe SERVICE --format export > service.yaml\n
Run Code Online (Sandbox Code Playgroud)\n
gcloud run services describe SERVICE --format export > service.yaml\n
Run Code Online (Sandbox Code Playgroud)\n

您可以将当前的 .yaml 半自动替换为:

\n

gcloud run services replace service.yaml

\n

但是,有什么方法可以让实际的 Cloud Build将部署容器映像service.yaml中的自定义加载到 Cloud Run步骤吗?

\n

cloudbuild.yaml

\n
apiVersion: serving.knative.dev/v1\nkind: Service\nmetadata:\n  annotations:\n    client.knative.dev/user-image: \'gcr.io/project/service:ebbe555\'\n    run.googleapis.com/ingress: all\n    run.googleapis.com/ingress-status: all\n    run.googleapis.com/launch-stage: BETA\n  labels:\n    cloud.googleapis.com/location: europe-north1\n  name: service\n  namespace: \'467851153648\'\nspec:\n  template:\n    metadata:\n      annotations:\n        autoscaling.knative.dev/maxScale: \'100\'\n        autoscaling.knative.dev/minScale: \'1\'\n        client.knative.dev/user-image: \'gcr.io/project/service:ebbe555\'\n        run.googleapis.com/client-name: gcloud\n        run.googleapis.com/client-version: 378.0.0\n        run.googleapis.com/execution-environment: gen2\n      name: faq-engine-00004-vov\n    spec:\n      containerConcurrency: 80\n      containers:\n        - image: \'gcr.io/project/service:ebbe555\'\n          ports:\n            - containerPort: 8081\n              name: http1\n          resources:\n            limits:\n              cpu: 4000m\n              memory: 8Gi\n      serviceAccountName: service@project.iam.gserviceaccount.com\n      timeoutSeconds: 300\n  traffic:\n    - latestRevision: true\n      percent: 100\n
Run Code Online (Sandbox Code Playgroud)\n

谢谢!

\n

Ral*_*mos 3

将 @GuillaumeBlaqueire 和 @Lsbister 的评论发布为社区 wiki,以提高可见性:

要部署 Cloud Run 服务,请使用 YAML ( service.yaml)gcloud run services replace或 gcloud 命令gcloud run deploy。您不能将服务 YAML 与“部署”操作一起使用。

如果您只想使用部署命令将容器的内存设置为 8GBi,则应该使用--memory该标志。