Cloud Run as an internal async worker

Cloud Pub/Sub + Cloud Run

Introduction

Knative Eventing to Cloud Run

Create a Cloud Pub/Sub topic

gcloud pubsub topics create cloudrun-atamel-topic

Create a bucket and enable notifications

gsutil mb gs://cloudrun-atamel-bucket/
gsutil notification create -t cloudrun-atamel-topic -f json gs://cloudrun-atamel-bucket/

Deploy Cloud Run Service

gcloud builds submit --tag gcr.io/cloudrun-atamel/vision-csharp:v1
gcloud beta run deploy vision-csharp --image gcr.io/cloudrun-atamel/vision-csharp:v1

Integrate with Cloud Pub/Sub

gcloud projects add-iam-policy-binding cloudrun-atamel --member=serviceAccount:service-165810103461@gcp-sa-pubsub.iam.gserviceaccount.com --role=roles/iam.serviceAccountTokenCreator
gcloud iam service-accounts create cloud-run-pubsub-invoker --display-name "Cloud Run Pub/Sub Invoker"
gcloud beta run services add-iam-policy-binding vision-csharp --member=serviceAccount:cloud-run-pubsub-invoker@cloudrun-atamel.iam.gserviceaccount.com --role=roles/run.invoker
gcloud beta pubsub subscriptions create cloudrun-atamel-subscription --topic cloudrun-atamel-topic --push-endpoint=https://vision-csharp-u6v7imyeip-uc.a.run.app/ --push-auth-service-account=cloud-run-pubsub-invoker@cloudrun-atamel.iam.gserviceaccount.com

The Moment of Truth!

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mete Atamel

I'm a Developer Advocate at Google Cloud, helping developers with serverless and orchestration technologies