GCP Firestore (Datastore mode)

Detailed information on the GCP Firestore state store component

Setup a GCP Firestone state store

You can use the GCP Datastore emulator to run locally using the instructions here.

You can then interact with the server using localhost:8081.

Follow the instructions here to get started with setting up Firestore in Google Cloud.

Create a Dapr component

The next step is to create a Dapr component for Firestore.

Create the following YAML file named firestore.yaml:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: state.gcp.firestore
  8. version: v1
  9. metadata:
  10. - name: type
  11. value: <REPLACE-WITH-CREDENTIALS-TYPE> # Required. Example: "serviceaccount"
  12. - name: project_id
  13. value: <REPLACE-WITH-PROJECT-ID> # Required.
  14. - name: private_key_id
  15. value: <REPLACE-WITH-PRIVATE-KEY-ID> # Required.
  16. - name: private_key
  17. value: <REPLACE-WITH-PRIVATE-KEY> # Required.
  18. - name: client_email
  19. value: <REPLACE-WITH-CLIENT-EMAIL> # Required.
  20. - name: client_id
  21. value: <REPLACE-WITH-CLIENT-ID> # Required.
  22. - name: auth_uri
  23. value: <REPLACE-WITH-AUTH-URI> # Required.
  24. - name: token_uri
  25. value: <REPLACE-WITH-TOKEN-URI> # Required.
  26. - name: auth_provider_x509_cert_url
  27. value: <REPLACE-WITH-AUTH-X509-CERT-URL> # Required.
  28. - name: client_x509_cert_url
  29. value: <REPLACE-WITH-CLIENT-x509-CERT-URL> # Required.
  30. - name: entity_kind
  31. value: <REPLACE-WITH-ENTITY-KIND> # Optional. default: "DaprState"

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Apply the configuration

In Kubernetes

To apply the Firestore state store to Kubernetes, use the kubectl CLI:

  1. kubectl apply -f firestore.yaml

Running locally

To run locally, create a components dir containing the YAML file and provide the path to the dapr run command with the flag --components-path.

Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)