From 26663223111fc21ffc75fdbc626d6ec81d999126 Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:47:02 -0800 Subject: [PATCH 1/7] Clarify actor state store support for MongoDB Fixes #3303 Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- .../supported-state-stores/setup-mongodb.md | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index 428953dd306..50686e7fd0d 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -47,20 +47,23 @@ spec: The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}} -If you wish to use MongoDB as an actor store, append the following to the yaml. +### Actor state store and transactions support + +For using as an actor state store or to leverage transactions, MongoDB must be running in a [Replica Set](https://www.mongodb.com/docs/manual/replication/). + +If you wish to use MongoDB as an actor store, add this metadata option to your Component YAML: ```yaml - name: actorStateStore value: "true" ``` - ## Spec metadata fields | Field | Required | Details | Example | |--------------------|:--------:|---------|---------| -| server | Y* | The server to connect to, when using DNS SRV record | `"server.example.com"` -| host | Y* | The host to connect to | `"mongo-mongodb.default.svc.cluster.local:27017"` +| server | Y1 | The server to connect to, when using DNS SRV record | `"server.example.com"` +| host | Y1 | The host to connect to | `"mongo-mongodb.default.svc.cluster.local:27017"` | username | N | The username of the user to connect with (applicable in conjunction with `host`) | `"admin"` | password | N | The password of the user (applicable in conjunction with `host`) | `"password"` | databaseName | N | The name of the database to use. Defaults to `"daprStore"` | `"daprStore"` @@ -68,11 +71,11 @@ If you wish to use MongoDB as an actor store, append the following to the yaml. | writeConcern | N | The write concern to use | `"majority"` | readConcern | N | The read concern to use | `"majority"`, `"local"`,`"available"`, `"linearizable"`, `"snapshot"` | operationTimeout | N | The timeout for the operation. Defaults to `"5s"` | `"5s"` -| params | N** | Additional parameters to use | `"?authSource=daprStore&ssl=true"` +| params | N2 | Additional parameters to use | `"?authSource=daprStore&ssl=true"` -> [*] The `server` and `host` fields are mutually exclusive. If neither or both are set, Dapr will return an error. +> [1] The `server` and `host` fields are mutually exclusive. If neither or both are set, Dapr will return an error. -> [**] The `params` field accepts a query string that specifies connection specific options as `=` pairs, separated by `"&"` and prefixed with `"?"`. e.g. to use "daprStore" db as authentication database and enabling SSL/TLS in connection, specify params as `"?authSource=daprStore&ssl=true"`. See [the mongodb manual](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-connection-options) for the list of available options and their use cases. +> [2] The `params` field accepts a query string that specifies connection specific options as `=` pairs, separated by `&` and prefixed with `?`. e.g. to use "daprStore" db as authentication database and enabling SSL/TLS in connection, specify params as `?authSource=daprStore&ssl=true`. See [the mongodb manual](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-connection-options) for the list of available options and their use cases. ## Setup MongoDB @@ -81,11 +84,11 @@ If you wish to use MongoDB as an actor store, append the following to the yaml. {{% codetab %}} You can run MongoDB locally using Docker: -``` +```sh docker run --name some-mongo -d mongo ``` -You can then interact with the server using `localhost:27017`. +You can then interact with the server at `localhost:27017`. If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`. @@ -94,7 +97,7 @@ If you do not specify a `databaseName` value in your component definition, make {{% codetab %}} The easiest way to install MongoDB on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/mongodb): -``` +```sh helm install mongo stable/mongodb ``` @@ -103,8 +106,9 @@ To interact with MongoDB, find the service with: `kubectl get svc mongo-mongodb` For example, if installing using the example above, the MongoDB host address would be: -`mongo-mongodb.default.svc.cluster.local:27017` - +```text +mongo-mongodb.default.svc.cluster.local:27017 +``` Follow the on-screen instructions to get the root password for MongoDB. The username is `admin` by default. @@ -117,6 +121,7 @@ The username is `admin` by default. This state store supports [Time-To-Live (TTL)]({{< ref state-store-ttl.md >}}) for records stored with Dapr. When storing data using Dapr, you can set the `ttlInSeconds` metadata property to indicate when the data should be considered "expired". ## Related links + - [Basic schema for a Dapr component]({{< ref component-schema >}}) - Read [this guide]({{< ref "howto-get-save-state.md#step-2-save-and-retrieve-a-single-state" >}}) for instructions on configuring state store components - [State management building block]({{< ref state-management >}}) From 1cdb40f5499c9c948824f2518fb970ff96879863 Mon Sep 17 00:00:00 2001 From: "Alessandro (Ale) Segala" <43508+ItalyPaleAle@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:16:18 -0800 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Mark Fussell Signed-off-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> --- .../supported-state-stores/setup-mongodb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index 50686e7fd0d..434afc5f8ac 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -49,7 +49,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr ### Actor state store and transactions support -For using as an actor state store or to leverage transactions, MongoDB must be running in a [Replica Set](https://www.mongodb.com/docs/manual/replication/). +When using as an actor state store or to leverage transactions, MongoDB must be running in a [Replica Set](https://www.mongodb.com/docs/manual/replication/). If you wish to use MongoDB as an actor store, add this metadata option to your Component YAML: @@ -73,7 +73,7 @@ If you wish to use MongoDB as an actor store, add this metadata option to your C | operationTimeout | N | The timeout for the operation. Defaults to `"5s"` | `"5s"` | params | N2 | Additional parameters to use | `"?authSource=daprStore&ssl=true"` -> [1] The `server` and `host` fields are mutually exclusive. If neither or both are set, Dapr will return an error. +> [1] The `server` and `host` fields are mutually exclusive. If neither or both are set, Dapr returns an error. > [2] The `params` field accepts a query string that specifies connection specific options as `=` pairs, separated by `&` and prefixed with `?`. e.g. to use "daprStore" db as authentication database and enabling SSL/TLS in connection, specify params as `?authSource=daprStore&ssl=true`. See [the mongodb manual](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-connection-options) for the list of available options and their use cases. From 75161a0bfeebc79c312aa259c2c744c20fbfdb39 Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:22:12 -0800 Subject: [PATCH 3/7] Changed to use the Helm chart by bitnami Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- .../supported-state-stores/setup-mongodb.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index 434afc5f8ac..c923f327d4d 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -95,23 +95,7 @@ If you do not specify a `databaseName` value in your component definition, make {{% /codetab %}} {{% codetab %}} -The easiest way to install MongoDB on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/mongodb): - -```sh -helm install mongo stable/mongodb -``` - -This installs MongoDB into the `default` namespace. -To interact with MongoDB, find the service with: `kubectl get svc mongo-mongodb`. - -For example, if installing using the example above, the MongoDB host address would be: - -```text -mongo-mongodb.default.svc.cluster.local:27017 -``` - -Follow the on-screen instructions to get the root password for MongoDB. -The username is `admin` by default. +You can conveniently install MongoDB on Kubernetes using the [Helm chart packaged by Bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mongodb/). Please refer to the documentation for the Helm chart for deploying MongoDB, both as a standalone server, and with a Replica Set (required for using transactions and actors). {{% /codetab %}} {{< /tabs >}} From 9af649127139631739d1c5d3b9db23d1f70fd5ab Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:24:56 -0800 Subject: [PATCH 4/7] Updatd Docker too Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- .../supported-state-stores/setup-mongodb.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index c923f327d4d..4a996bd114a 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -82,16 +82,15 @@ If you wish to use MongoDB as an actor store, add this metadata option to your C {{< tabs "Self-Hosted" "Kubernetes" >}} {{% codetab %}} -You can run MongoDB locally using Docker: +You can run a single MongoDB instance locally using Docker: ```sh docker run --name some-mongo -d mongo ``` -You can then interact with the server at `localhost:27017`. - -If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`. +You can then interact with the server at `localhost:27017`. If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`. +In order to use the MongoDB state store for transactions and as an actor state store, you will need to run MongoDB as a Replica Set. Please refer to [the official documentation](https://www.mongodb.com/compatibility/deploying-a-mongodb-cluster-with-docker) for how to create a 3-node Replica Set using Docker. {{% /codetab %}} {{% codetab %}} From de0bf93079da6fabdafa5dfa200f131474687dee Mon Sep 17 00:00:00 2001 From: Mark Fussell Date: Fri, 2 Feb 2024 08:52:40 -0800 Subject: [PATCH 5/7] Update daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md Signed-off-by: Mark Fussell --- .../supported-state-stores/setup-mongodb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index 4a996bd114a..2255429f895 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -90,7 +90,7 @@ docker run --name some-mongo -d mongo You can then interact with the server at `localhost:27017`. If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`. -In order to use the MongoDB state store for transactions and as an actor state store, you will need to run MongoDB as a Replica Set. Please refer to [the official documentation](https://www.mongodb.com/compatibility/deploying-a-mongodb-cluster-with-docker) for how to create a 3-node Replica Set using Docker. +In order to use the MongoDB state store for transactions and as an actor state store, you need to run MongoDB as a Replica Set. Refer to [the official documentation](https://www.mongodb.com/compatibility/deploying-a-mongodb-cluster-with-docker) for how to create a 3-node Replica Set using Docker. {{% /codetab %}} {{% codetab %}} From 6f7727c7b061855fedd4b8fb5f3a41163462d4dd Mon Sep 17 00:00:00 2001 From: Mark Fussell Date: Fri, 2 Feb 2024 08:53:54 -0800 Subject: [PATCH 6/7] Update daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md Signed-off-by: Mark Fussell --- .../supported-state-stores/setup-mongodb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index 2255429f895..8bcd5791cc1 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -94,7 +94,7 @@ In order to use the MongoDB state store for transactions and as an actor state s {{% /codetab %}} {{% codetab %}} -You can conveniently install MongoDB on Kubernetes using the [Helm chart packaged by Bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mongodb/). Please refer to the documentation for the Helm chart for deploying MongoDB, both as a standalone server, and with a Replica Set (required for using transactions and actors). +You can conveniently install MongoDB on Kubernetes using the [Helm chart packaged by Bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mongodb/). Refer to the documentation for the Helm chart for deploying MongoDB, both as a standalone server, and with a Replica Set (required for using transactions and actors). {{% /codetab %}} {{< /tabs >}} From f36672f58c0071b3cc81c090235082c3c33e7da6 Mon Sep 17 00:00:00 2001 From: Mark Fussell Date: Fri, 2 Feb 2024 09:02:06 -0800 Subject: [PATCH 7/7] Update daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md Signed-off-by: Mark Fussell --- .../supported-state-stores/setup-mongodb.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index 8bcd5791cc1..db3fec2ed77 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -95,6 +95,12 @@ In order to use the MongoDB state store for transactions and as an actor state s {{% codetab %}} You can conveniently install MongoDB on Kubernetes using the [Helm chart packaged by Bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mongodb/). Refer to the documentation for the Helm chart for deploying MongoDB, both as a standalone server, and with a Replica Set (required for using transactions and actors). +This installs MongoDB into the `default` namespace. +To interact with MongoDB, find the service with: `kubectl get svc mongo-mongodb`. +For example, if installing using the Helm defaults above, the MongoDB host address would be: +`mongo-mongodb.default.svc.cluster.local:27017` +Follow the on-screen instructions to get the root password for MongoDB. +The username is typically `admin` by default. {{% /codetab %}} {{< /tabs >}}