Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ the name of the project you want to use.

## Enable the Services

Set the active project:

```sh
gcloud config set project ${GOOGLE_CLOUD_PROJECT}
```

```sh
gcloud services enable --project="${GOOGLE_CLOUD_PROJECT}" \
gcloud services enable \
bigtable.googleapis.com \
cloudbuild.googleapis.com \
cloudfunctions.googleapis.com \
Expand All @@ -44,10 +50,8 @@ gcloud services enable --project="${GOOGLE_CLOUD_PROJECT}" \
## Create Pub/Sub Topics

```sh
gcloud pubsub topics create testing \
--project="${GOOGLE_CLOUD_PROJECT}"
gcloud pubsub topics create gcs-changes \
--project="${GOOGLE_CLOUD_PROJECT}"
gcloud pubsub topics create testing
gcloud pubsub topics create gcs-changes
```

## Create a Bucket
Expand Down Expand Up @@ -77,7 +81,6 @@ Add this service account to the topic:Grant the

```shell
gcloud pubsub topics add-iam-policy-binding \
--project="${GOOGLE_CLOUD_PROJECT}" \
--role="roles/pubsub.publisher" \
--member="serviceAccount:${GCS_SA}" \
gcs-changes
Expand All @@ -98,7 +101,6 @@ readonly SA_ID="eventarc-trigger-sa"
readonly SA_NAME="${SA_ID}@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"

gcloud iam service-accounts create "${SA_ID}" \
"--project=${GOOGLE_CLOUD_PROJECT}" \
--description="Event Arg Triggers"
```

Expand Down Expand Up @@ -158,7 +160,6 @@ Create a Cloud Run deployment running the hello world example:

```sh
gcloud run deploy gcf-hello-world-http \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-http:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -169,7 +170,6 @@ Test it by sending a request with `curl(1)`:

```sh
HTTP_SERVICE_URL=$(gcloud run services describe \
--project="${GOOGLE_CLOUD_PROJECT}" \
--platform="managed" \
--region="us-central1" \
--format="value(status.url)" \
Expand All @@ -185,7 +185,6 @@ triggers:

```sh
gcloud run deploy gcf-hello-world-pubsub \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-pubsub:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -199,7 +198,6 @@ PROJECT_NUMBER="$(gcloud projects list \
--filter="PROJECT_ID=${GOOGLE_CLOUD_PROJECT}" \
--format="value(project_number)")"
gcloud beta eventarc triggers create gcf-hello-world-pubsub-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--destination-run-service="gcf-hello-world-pubsub" \
--destination-run-region="us-central1" \
Expand All @@ -210,7 +208,6 @@ Test by sending a message to the right topic:

```sh
TOPIC=$(gcloud beta eventarc triggers describe gcf-hello-world-pubsub-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--format="value(transport.pubsub.topic)")
NONCE=$(date +%s)-${RANDOM}
Expand All @@ -221,7 +218,6 @@ And then verify this message shows up in the log:

```sh
gcloud logging read \
--project="${GOOGLE_CLOUD_PROJECT}" \
--format="value(textPayload)" \
"resource.type=cloud_run_revision AND resource.labels.service_name=gcf-hello-world-pubsub AND logName:stdout"
```
Expand All @@ -233,7 +229,6 @@ triggers:

```sh
gcloud run deploy gcf-hello-world-storage \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-storage:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -244,7 +239,6 @@ Create a trigger for Cloud Storage events:

```sh
gcloud beta eventarc triggers create gcf-hello-world-storage-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--destination-run-service="gcf-hello-world-storage" \
--destination-run-region="us-central1" \
Expand All @@ -257,7 +251,6 @@ And then verify this message shows up in the log:

```sh
gcloud logging read \
--project="${GOOGLE_CLOUD_PROJECT}" \
--format="value(textPayload)" \
"resource.type=cloud_run_revision AND resource.labels.service_name=gcf-hello-world-storage AND logName:stdout"
```
Expand All @@ -268,7 +261,6 @@ Finally verify this works by running the Cloud Build:

```sh
gcloud builds submit \
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--substitutions=SHORT_SHA=$(git rev-parse --short HEAD)" \
"--config=ci/build-examples.yaml"
```
Expand Down Expand Up @@ -314,13 +306,11 @@ pack build -v \
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-tutorial-cloud-bigtable"
docker push "gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-tutorial-cloud-bigtable"
gcloud run deploy gcf-tutorial-cloud-bigtable \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-tutorial-cloud-bigtable:latest" \
--region="us-central1" \
--platform="managed" \
--allow-unauthenticated
BIGTABLE_SERVICE_URL=$(gcloud run services describe \
--project="${GOOGLE_CLOUD_PROJECT}" \
--platform="managed" \
--region="us-central1" \
--format="value(status.url)" \
Expand All @@ -333,7 +323,7 @@ curl -H "projectID: ${GOOGLE_CLOUD_PROJECT}" -H "instanceID: test-instance-0" -H
Create the instance:

```shell
gcloud --project="${GOOGLE_CLOUD_PROJECT}" spanner instances create test-instance-0 \
gcloud spanner instances create test-instance-0 \
--config="regional-us-central1" \
--description="Test instance for CI builds" \
--nodes=1
Expand All @@ -358,14 +348,12 @@ pack build -v \
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-tutorial-cloud-spanner"
docker push "gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-tutorial-cloud-spanner"
gcloud run deploy gcf-tutorial-cloud-spanner \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-tutorial-cloud-spanner:latest" \
--region="us-central1" \
--platform="managed" \
--set-env-vars=GOOGLE_CLOUD_PROJECT="${GOOGLE_CLOUD_PROJECT}",SPANNER_INSTANCE=test-instance-0,SPANNER_DATABASE=test-db \
--allow-unauthenticated
SPANNER_SERVICE_URL=$(gcloud run services describe \
--project="${GOOGLE_CLOUD_PROJECT}" \
--platform="managed" \
--region="us-central1" \
--format="value(status.url)" \
Expand Down
10 changes: 7 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ docker kill ${ID}
## Deploying to Cloud Run

This example assumes that `GOOGLE_CLOUD_PROJECT` is set to a GCP project with
the right services enabled:
the correct services enabled:

```sh
GOOGLE_CLOUD_PROJECT=... # use a real project
Expand All @@ -102,11 +102,16 @@ Push this image to Google Container Registry:
docker push gcr.io/${GOOGLE_CLOUD_PROJECT}/hello-world:latest
```

Set the active project:

```sh
gcloud config set project ${GOOGLE_CLOUD_PROJECT}
```

Deploy this application to Cloud Run:

```sh
gcloud run deploy gcf-cpp-hello \
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--image=gcr.io/${GOOGLE_CLOUD_PROJECT}/hello-world:latest" \
"--region=${GOOGLE_CLOUD_REGION}" \
"--platform=managed" \
Expand All @@ -117,7 +122,6 @@ Fetch the service URL:

```bash
SERVICE_URL=$(gcloud run services list \
"--project=${GOOGLE_CLOUD_PROJECT}" \
"--platform=managed" \
'--format=csv[no-heading](URL)' \
"--filter=SERVICE:gcf-cpp-hello")
Expand Down
13 changes: 6 additions & 7 deletions examples/site/howto_deploy_cloud_event/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ To deploy this image in Cloud Run use this command. You need to select
a Cloud Run region for your deployment. We will use `us-central1` in this
guide:

Set the active project:

```sh
gcloud config set project ${GOOGLE_CLOUD_PROJECT}
```

```shell
gcloud run deploy gcf-cpp-hello-world-pubsub \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-cpp-hello-world-pubsub:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -130,7 +135,6 @@ Verify unauthenticated requests are allowed:

```shell
gcloud run services get-iam-policy gcf-cpp-hello-world-pubsub \
--project="${GOOGLE_CLOUD_PROJECT}" \
--region="us-central1" \
--platform="managed"
```
Expand All @@ -152,7 +156,6 @@ proceed run this command (maybe with an addition `--topic-transport` option):

```shell
gcloud beta eventarc triggers create gcf-cpp-hello-world-pubsub-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--destination-run-service="gcf-cpp-hello-world-pubsub" \
--destination-run-region="us-central1" \
Expand All @@ -163,7 +166,6 @@ Find out what topic is used to this new trigger:

```shell
TOPIC=$(gcloud beta eventarc triggers describe gcf-cpp-hello-world-pubsub-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--format="value(transport.pubsub.topic)")
```
Expand All @@ -181,7 +183,6 @@ to verify the Pub/Sub message was received:

```shell
gcloud logging read \
--project="${GOOGLE_CLOUD_PROJECT}" \
--format="value(textPayload)" \
"resource.type=cloud_run_revision AND resource.labels.service_name=gcf-cpp-hello-world-pubsub AND logName:stdout"
# Output: Hello Event
Expand All @@ -193,15 +194,13 @@ Delete the trigger:

```shell
gcloud beta eventarc triggers delete gcf-cpp-hello-world-pubsub-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1"
```

Delete the Cloud Run deployment:

```sh
gcloud run services delete gcf-cpp-hello-world-pubsub \
--project="${GOOGLE_CLOUD_PROJECT}" \
--region="us-central1" \
--platform="managed"
```
Expand Down
10 changes: 7 additions & 3 deletions examples/site/howto_deploy_to_cloud_run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,15 @@ To deploy this image in Cloud Run use this command. You need to select
a Cloud Run region for your deployment. We will use `us-central1` in this
guide:

Set the active project:

```sh
gcloud config set project ${GOOGLE_CLOUD_PROJECT}
```


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superduper nit: double space

```sh
gcloud run deploy gcf-cpp-hello-world-http \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-cpp-hello-world-http:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -134,7 +140,6 @@ Find out what URL was assigned to your function, and use `curl` to send a reques

```shell
HTTP_SERVICE_URL=$(gcloud run services describe \
--project="${GOOGLE_CLOUD_PROJECT}" \
--platform="managed" \
--region="us-central1" \
--format="value(status.url)" \
Expand All @@ -150,7 +155,6 @@ Delete the Cloud Run deployment:

```sh
gcloud run services delete gcf-cpp-hello-world-http \
--project="${GOOGLE_CLOUD_PROJECT}" \
--region="us-central1" \
--platform="managed"
```
Expand Down
8 changes: 6 additions & 2 deletions examples/site/testing_pubsub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,17 @@ pack build \
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-pubsub"
```

Set the active project:

```sh
gcloud config set project ${GOOGLE_CLOUD_PROJECT}
```

Deploy this function to Cloud Run:

```shell
docker push "gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-pubsub"
gcloud run deploy gcf-hello-world-storage \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-pubsub:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -96,7 +101,6 @@ Setup a Pub/Sub trigger:

```shell
gcloud beta eventarc triggers create gcf-hello-world-pubsub-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--destination-run-service="gcf-hello-world-pubsub" \
--destination-run-region="us-central1" \
Expand Down
9 changes: 6 additions & 3 deletions examples/site/testing_storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ pack build \
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-storage"
```

Set the active project:

```sh
gcloud config set project ${GOOGLE_CLOUD_PROJECT}
```

Then deploy this function to Cloud Run:

```shell
docker push "gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-storage"
gcloud run deploy gcf-hello-world-storage \
--project="${GOOGLE_CLOUD_PROJECT}" \
--image="gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-storage:latest" \
--region="us-central1" \
--platform="managed" \
Expand All @@ -105,7 +110,6 @@ topic:

```shell
gcloud beta eventarc triggers create gcf-hello-world-storage-trigger \
--project="${GOOGLE_CLOUD_PROJECT}" \
--location="us-central1" \
--destination-run-service="gcf-hello-world-storage" \
--destination-run-region="us-central1" \
Expand All @@ -129,7 +133,6 @@ Remember to remove your deployment and the image once you have finished:

```sh
gcloud run services delete gcf-cpp-hello-world-storage \
--project="${GOOGLE_CLOUD_PROJECT}" \
--region="us-central1" \
--platform="managed"
gcloud container images delete \
Expand Down
Loading