From aa96c2dcae992d35941b7b110b49aca398a22e0a Mon Sep 17 00:00:00 2001 From: Sivamuthu Kumar Date: Thu, 19 Mar 2020 17:33:35 -0400 Subject: [PATCH] Add GCP pubsub docs (#446) --- howto/setup-pub-sub-message-broker/README.md | 1 + .../setup-pub-sub-message-broker/setup-gcp.md | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 howto/setup-pub-sub-message-broker/setup-gcp.md diff --git a/howto/setup-pub-sub-message-broker/README.md b/howto/setup-pub-sub-message-broker/README.md index c0ec72bf3..4eb67ea03 100644 --- a/howto/setup-pub-sub-message-broker/README.md +++ b/howto/setup-pub-sub-message-broker/README.md @@ -46,3 +46,4 @@ kubectl apply -f pubsub.yaml - [Setup NATS](./setup-nats.md) - [Setup Azure Service bus](./setup-azure-servicebus.md) - [Setup RabbitMQ](./setup-rabbitmq.md) +- [Setup GCP Pubsub](./setup-gcp.md) diff --git a/howto/setup-pub-sub-message-broker/setup-gcp.md b/howto/setup-pub-sub-message-broker/setup-gcp.md new file mode 100644 index 000000000..191121de1 --- /dev/null +++ b/howto/setup-pub-sub-message-broker/setup-gcp.md @@ -0,0 +1,72 @@ +# Setup GCP Pubsub + +Follow the instructions [here](https://cloud.google.com/pubsub/docs/quickstart-console) on setting up Google Cloud Pub/Sub system. + +## Create a Dapr component + +The next step is to create a Dapr component for Google Cloud Pub/Sub + +Create the following YAML file named `messagebus.yaml`: + +```yml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: +spec: + type: pubsub.gcp.pubsub + metadata: + - name: topic + value: + - name: type + value: service_account + - name: project_id + value: # replace + - name: private_key_id + value: #replace + - name: client_email + value: #replace + - name: client_id + value: # replace + - name: auth_uri + value: https://accounts.google.com/o/oauth2/auth + - name: token_uri + value: https://oauth2.googleapis.com/token + - name: auth_provider_x509_cert_url + value: https://www.googleapis.com/oauth2/v1/certs + - name: client_x509_cert_url + value: https://www.googleapis.com/robot/v1/metadata/x509/.iam.gserviceaccount.com + - name: private_key + value: # replace x509 cert here + - name: disableEntityManagement + value: # Optional. Default: false. When set to true, topics and subscriptions do not get created automatically. +``` + +- `topic` is the Pub/Sub topic name. +- `type` is the GCP credentials type. +- `project_id` is the GCP project id. +- `private_key_id` is the GCP private key id. +- `client_email` is the GCP client email. +- `client_id` is the GCP client id. +- `auth_uri` is Google account OAuth endpoint. +- `token_uri` is Google account token uri. +- `auth_provider_x509_cert_url` is the GCP credentials cert url. +- `client_x509_cert_url` is the GCP credentials project x509 cert url. +- `private_key` is the GCP credentials private key. +- `disableEntityManagement` Optional. Default: false. When set to true, topics and subscriptions do not get created automatically. + +The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here](../../concepts/secrets/README.md) + +## Apply the configuration + +### In Kubernetes + +To apply the Google Cloud pub/sub to Kubernetes, use the `kubectl` CLI: + +```bash +kubectl apply -f messagebus.yaml +``` + +### Running locally + +The Dapr CLI will automatically create a directory named `components` in your current working directory. To use Cloud Pubsub, replace the contents of `messagebus.yaml` file with the contents of yaml above.