gcloud beta command in build step in cloudbuild.yaml. Should I use entrypoint or args?

2.5k Views Asked by At

I'm trying to build and deploy a Docker image to Cloud Run. And I'd like to set min-instances=1 so I can avoid cold starts.

I'm building and deploying it using Cloud Build through the gcloud CLI.

So this is was my 1st attempt from the gcloud CLI:

gcloud builds submit . --config=./cloudbuild.yaml

And here are the build steps that are described in my cloudbuild.yaml:

steps:
  # STEP_1: DOCKER BUILDS IMAGE
  # STEP_2: DOCKER PUSHES IMAGE TO CLOUD REGISTRY

  # STEP_3: GCLOUD SHOULD DEPLOY TO CLOUD RUN (DESCRIBED BELOW)

  - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
    entrypoint: gcloud
    args:
      - "run"
      - "deploy"
      - "my-service"
      - "--image=gcr.io/$PROJECT_ID/my-image"
      - "--platform=managed"
      - "--region=us-central1"
      - "--min-instances=1"

You see that the build STEP_3 runs: gcloud run deploy my-service ... min-instances=1

And I'm getting the following error:

The `--min-instances` flag is not supported in the GA release track on the 
fully managed version of Cloud Run. Use `gcloud beta` to set `--min-instances` on Cloud Run (fully managed).

So I guess I'll have to use gcloud beta commands. But I have some questions in that case:

Do I also need to add the beta command to my gcloud builds submit . command?

And how should I set it in cloudbuilt.yaml? Do I add it to the entrypoint or as an argument in args?

OPTION #1

  - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
    entrypoint: "gcloud beta"
    args:
      - "run"
   // ETC

OPTION #2

  - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
    entrypoint: gcloud
    args:
      - "beta"
      - "run"
   // ETC
1

There are 1 best solutions below

0
On BEST ANSWER

There is nothing like a hidden reason for either.

Use under args. All the elements are concatenated into a string.