build, push image and deploy to CloudRun

1,488 views
Skip to first unread message

Shin Fukuda

unread,
Feb 13, 2020, 9:47:28 PM2/13/20
to Google Cloud Developers
Hello.

It's may be some my miss understanding. Anyway my question is How to deploy to CloudRun with Cloudbuild ?

here is my cloudbuild.yaml
steps:
  args: [ 'build', '-f', 'Dockerfile', '-t', 'gcr.io/[PROJECT_ID]/go-clock-20200129:$_ENV-$SHORT_SHA', '.' ]
  args: [ 'push', 'gcr.io/[PROJECT_ID]/go-clock-20200129', '.' ]
  images: ['gcr.io/[PROJECT_ID]/go-clock-20200129']
  id: 'go-clock-build'
  args: ['beta', 'run', 'deploy', 'godocker', '--image', 'gcr.io/[PROJECT_ID]/go_docker_20200129:$_ENV-$SHORT_SHA', '--region','asia-northeast1', '--platform', 'managed', '--allow-unauthenticated']
  images: ['gcr.io/[PROJECT_ID]/go_docker_20200129:$_ENV-$SHORT_SHA']

Cloudbuild is successed, did nothing but build and push image. There is no action "run deploy" code.  

...
...
PUSH
Pushing gcr.io/[PROJECT_ID]//go_docker_20200129:57e9763
The push refers to repository [gcr.io/[PROJECT_ID]//go_docker_20200129]
f9d24a121577: Preparing
f9d24a121577: Preparing
a1a384955b64: Preparing
03901b4a2ea8: Preparing
03901b4a2ea8: Layer already exists
f9d24a121577: Pushed
a1a384955b64: Pushed
57e9763: digest: sha256:c1c9bd2eXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxa size: 1160
DONE

On the other hand, my IAM account CAN DO "Deployed Image" pushing to CloudRun.
------------------------------------------------------------------------------------------------------- REMOTE BUILD OUTPUT -------------------------------------------------------------------------------------------------------
starting build "3f9e2210-c33f-48ac-975b-6e93da778a7b"

FETCHSOURCE
Fetching storage object: gs://[PROJECT_ID]_cloudbuild/source/1581642916.48-b3ae564f54e44493ac3d6196b2bcdfc9.tgz#1581642917512267
Copying gs://[PROJECT_ID]_cloudbuild/source/1581642916.48-b3ae564f54e44493ac3d6196b2bcdfc9.tgz#1581642917512267...
/ [1 files][  393.0 B/  393.0 B]                                                
Operation completed over 1 objects/393.0 B.                                      
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Deploying container to Cloud Run service [gogogo] in project [PROJECT_ID] region [asia-northeast1]
Deploying...
Setting IAM Policy.....................................done
Creating Revision........................................................................................................................................................................................................................................................done
Routing traffic.....done
Done.
Service [gogogo] revision [gogogo-00003-bav] has been deployed and is serving 100 percent of traffic at https://XXXXXX-jocpwhyidq-an.a.run.app
PUSH
DONE
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ID                                    CREATE_TIME                DURATION  SOURCE                                                                                         IMAGES  STATUS
3f9e2210-c33f-48ac-975b-6e93da778a7b  2020-02-14T01:15:17+00:00  42S       gs://[PROJECT_ID]_cloudbuild/source/1581642916.48-b3ae564f54e44493ac3d6196b2bcdfc9.tgz  -       SUCCESS

What shoud I do next ?
Thank you.

----
shin

Elliott (Google Cloud Platform Support)

unread,
Feb 17, 2020, 5:36:23 PM2/17/20
to Google Cloud Developers

Hello Shin,


I’ve found a document here, which may help you. You’ll find how to build and deploy. I don’t see anything extraordinary in the example you provided but if you follow the steps I gave you and get stuck at a point, I could offer more specific advice.


shin fukuda

unread,
Feb 17, 2020, 7:27:29 PM2/17/20
to Elliott (Google Cloud Platform Support), Google Cloud Developers

Hello Elliott-san

Thank you for your reply and document. I'll check it and try. If anything goes wrong, I'll let you know.

shin

2020年2月18日(火) 7:36 'Elliott (Google Cloud Platform Support)' via Google Cloud Developers <google-c...@googlegroups.com>:

Hello Shin,


I’ve found a document here, which may help you. You’ll find how to build and deploy. I don’t see anything extraordinary in the example you provided but if you follow the steps I gave you and get stuck at a point, I could offer more specific advice.


--
You received this message because you are subscribed to a topic in the Google Groups "Google Cloud Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-cloud-dev/r3MLmcZq2Uc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-cloud-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-dev/5fe374a9-08fe-46ab-b8fc-4d5dd211ab88%40googlegroups.com.

Shin Fukuda

unread,
Feb 19, 2020, 2:53:53 AM2/19/20
to Google Cloud Developers
Hello again.

I found something clue to solve my issue.

$ diff -u _cloudbuild.yaml cloudbuild.yaml 
--- _cloudbuild.yaml 2020-02-14 06:05:25.266852760 +0000
+++ cloudbuild.yaml 2020-02-19 01:26:40.874445501 +0000
@@ -13,6 +13,6 @@
  args: ['beta', 'run', 'services', 'add-iam-policy-binding', '${_SERVICE_NAME}', '--region', '${_REGION}', '--member', 'allUsers', '--role', 'roles/run.invoker']
 substitutions:
   _REGION: us-central1
-  _SERVICE_NAME: go_docker_20200129
+  _SERVICE_NAME: go-docker-20200129
 images:

In CloudRun, "Service Name" parameters requrire for public (or private) access. My cloudbuid.yaml uses "Service name" with UNDERSOCRE!
So it causes something not-good at deploying at Cloudrun. Maybe..., I'll keep trying.


2020年2月18日火曜日 9時27分29秒 UTC+9 Shin Fukuda:

Hello Elliott-san

Thank you for your reply and document. I'll check it and try. If anything goes wrong, I'll let you know.

shin

2020年2月18日(火) 7:36 'Elliott (Google Cloud Platform Support)' via Google Cloud Developers <google-cloud-dev@googlegroups.com>:

Hello Shin,


I’ve found a document here, which may help you. You’ll find how to build and deploy. I don’t see anything extraordinary in the example you provided but if you follow the steps I gave you and get stuck at a point, I could offer more specific advice.


--
You received this message because you are subscribed to a topic in the Google Groups "Google Cloud Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-cloud-dev/r3MLmcZq2Uc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-cloud-dev+unsubscribe@googlegroups.com.

Jad El Houssami

unread,
Feb 19, 2020, 3:30:38 PM2/19/20
to Google Cloud Developers
Hello Shin, 

Thanks for your update. I agree that indeed using underscores instead of dashes with the ‘service name’ may be what is preventing proper deployment. In an effort to point you in the right direction, I suggest that you refer to this page for more information on how to build a cloudbuild.yaml file, additionally, you may use this GitHub page for some examples.

Keep in mind that Google Groups are generally reserved for discussions and opinions about Google products, you may want to refer to Stack Exchange for how-to and technical questions since the answer-question format on those sites will give your question greater visibility.
Reply all
Reply to author
Forward
0 new messages