GoogleCloudPlatform / cloud-run-button

Let anyone deploy your GitHub repos to Google Cloud Run with a single click
https://cloud.run
Apache License 2.0
528 stars 92 forks source link

Add alpha to deploy command when http2 option is true #213

Closed simoneb closed 3 years ago

simoneb commented 3 years ago

Is there a way to execute the beta version of the gcloud application when clicking the cloud run button?

jamesward commented 3 years ago

Once you are in Cloud Shell's CLI?

simoneb commented 3 years ago

From the cloud run button. It seems that clicking the button always executes the command in the shell with the "stable" version of the gcloud command. I'm asking if there's a way to make it execute gcloud beta instead.

jamesward commented 3 years ago

Under the covers Cloud Run Button actually doesn't call gcloud it calls the APIs directly. If you are adding a button to something and want to call gcloud beta you can from custom scripts: https://github.com/GoogleCloudPlatform/cloud-run-button#customizing-deployment-parameters

If you want to add something to Cloud Run Button to do a beta thing, then we'd have to just translate what you want to do to an API call.

simoneb commented 3 years ago

I can't see a way to provide custom parameters to cloud, can you provide an example?

jamesward commented 3 years ago

Like you want to tweak the gcloud run deploy command that Cloud Run Button "runs"? If so, yeah there isn't a way to do that without explicitly adding support for what you need to Cloud Run Button. We recently added the new --use-http2 flag and if you want to see what was needed, see: https://github.com/GoogleCloudPlatform/cloud-run-button/pull/203/files

What flag are you looking for?

simoneb commented 3 years ago

As far as I understand, http2 is only supported by gcloud beta. If you try to run an app with http2 using plain gcloud you'll get this in the cloud shell:

Error: error attempting to read the app.json from the cloned repository: failed to parse app.json file: failed to parse app.json: json: unknown field "http2"
jamesward commented 3 years ago

I'm trying the button for: https://github.com/GoogleCloudPlatform/kotlin-samples/tree/master/run/grpc-hello-world-bidi-streaming

(It did work but maybe our latest change was rolled back.)

simoneb commented 3 years ago

I was trying this, which seems to be similar, and I got that error https://github.com/GoogleCloudPlatform/golang-samples/tree/master/run/h2c

jamesward commented 3 years ago

Oh! The app.json option is in the wrong place there. Sending a PR to that repo. One sec.

jamesward commented 3 years ago

https://github.com/GoogleCloudPlatform/golang-samples/pull/1918

jamesward commented 3 years ago

It needs to be nested in an options block. Try my fork: https://github.com/jamesward/golang-samples/tree/patch-1/run/h2c

jamesward commented 3 years ago

But you are right that running the presented deploy command does indeed fail and we should fix that.

[ ! ] FYI, running the following command:
        gcloud run deploy h2c\
          --project=jw-demo\
          --platform=managed\
          --region=us-central1\
          --image=gcr.io/jw-demo/h2c\
          --allow-unauthenticated\
          --use-http2

gcloud run deploy h2c\
           --project=jw-demo\
           --platform=managed\
           --region=us-central1\
           --image=gcr.io/jw-demo/h2c\
           --allow-unauthenticated\
           --use-http2

ERROR: (gcloud.beta.run.deploy) The `--use-http2` flag is only supported in the alpha release track on the fully m
anaged version of Cloud Run. Use `gcloud alpha` to set `--use-http2` on Cloud Run (fully managed). Alternatively, 
specify `--platform gke` or run `gcloud config set run/platform gke`.

Trying again with gcloud alpha run deploy ... works. So we should adapt the commands we show to account for this.

simoneb commented 3 years ago

This is what I was trying to say since my first post.

jamesward commented 3 years ago

Makes sense now. Thanks for reporting!