update state store to capture all metadata fields (#1127)

* update state store to capture all metadata fields

* Fix state store docs

* alphabetical order

* Update setup-aerospike.md

* Update setup-azure-blobstorage.md

* Update setup-azure-cosmosdb.md

* Update setup-azure-tablestorage.md

* Update setup-cassandra.md

* Update setup-cloudstate.md

* Update setup-consul.md

* Update setup-couchbase.md

* Update setup-firestore.md

* Update setup-hazelcast.md

* Update setup-memcached.md

* Update setup-mongodb.md

* Update setup-mysql.md

* Update setup-postgresql.md

* Update setup-redis.md

* Update setup-rethinkdb.md

* Update setup-sqlserver.md

* Update setup-zookeeper.md

* Update setup-aerospike.md

* Update setup-azure-blobstorage.md

* Update setup-azure-cosmosdb.md

Co-authored-by: Mark Fussell <mfussell@microsoft.com>
This commit is contained in:
Mukundan Sundararajan 2021-01-29 10:26:44 -08:00 committed by GitHub
parent f17e18fb41
commit 11a1d27af2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 771 additions and 932 deletions

View File

@ -34,7 +34,26 @@ To optionally change the state store being used, replace the YAML file `statesto
{{% /codetab %}}
{{% codetab %}}
To deploy this into a Kubernetes cluster, fill in the `metadata` connection details of your [desired statestore component]({{< ref supported-state-stores >}}) in the yaml below, save as `statestore.yaml`, and run `kubectl apply -f statestore.yaml`.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
namespace: default
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
```
See the instructions [here]({{< ref "setup-state-store" >}}) on how to setup different state stores on Kubernetes.
{{% /codetab %}}
{{< /tabs >}}

View File

@ -9,13 +9,14 @@ no_list: true
The following stores are supported, at various levels, by the Dapr state management building block:
### Generic
| Name | CRUD | Transactional |
|----------------------------------------------------------------|------|---------------|
| [Aerospike]({{< ref setup-aerospike.md >}}) | ✅ | ❌ |
| [Cassandra]({{< ref setup-cassandra.md >}}) | ✅ | ❌ |
| [Apache Cassandra]({{< ref setup-cassandra.md >}}) | ✅ | ❌ |
| [Cloudstate]({{< ref setup-cloudstate.md >}}) | ✅ | ❌ |
| [Couchbase]({{< ref setup-couchbase.md >}}) | ✅ | ❌ |
| [etcd]({{< ref setup-etcd.md >}}) | ✅ | ❌ |
| [Hashicorp Consul]({{< ref setup-consul.md >}}) | ✅ | ❌ |
| [Hazelcast]({{< ref setup-hazelcast.md >}}) | ✅ | ❌ |
| [Memcached]({{< ref setup-memcached.md >}}) | ✅ | ❌ |
@ -24,8 +25,18 @@ The following stores are supported, at various levels, by the Dapr state managem
| [PostgreSQL]({{< ref setup-postgresql.md >}}) | ✅ | ✅ |
| [Redis]({{< ref setup-redis.md >}}) | ✅ | ✅ |
| [Zookeeper]({{< ref setup-zookeeper.md >}}) | ✅ | ❌ |
| [Azure CosmosDB]({{< ref setup-azure-cosmosdb.md >}}) | ✅ | ✅ |
| [Azure SQL Server]({{< ref setup-sqlserver.md >}}) | ✅ | ✅ |
| [Azure Table Storage]({{< ref setup-azure-tablestorage.md >}}) | ✅ | ❌ |
| [Azure Blob Storage]({{< ref setup-azure-blobstorage.md >}}) | ✅ | ❌ |
| [Google Cloud Firestore]({{< ref setup-firestore.md >}}) | ✅ | ❌ |
### Google Cloud Platform (GCP)
| Name | CRUD | Transactional |
|-------------------------------------------------------|------|---------------|
| [GCP Firestore]({{< ref setup-firestore.md >}}) | ✅ | ❌ |
### Microsoft Azure
| Name | CRUD | Transactional |
|------------------------------------------------------------------|------|---------------|
| [Azure Blob Storage]({{< ref setup-azure-blobstorage.md >}}) | ✅ | ❌ |
| [Azure CosmosDB]({{< ref setup-azure-cosmosdb.md >}}) | ✅ | ✅ |
| [Azure SQL Server]({{< ref setup-sqlserver.md >}}) | ✅ | ❌ |
| [Azure Table Storage]({{< ref setup-azure-tablestorage.md >}}) | ✅ | ❌ |

View File

@ -5,6 +5,40 @@ linkTitle: "Aerospike"
description: Detailed information on the Aerospike state store component
---
## Component format
To setup Aerospike state store create a component of type `state.Aerospike`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.Aerospike
version: v1
metadata:
- name: hosts
value: <REPLACE-WITH-HOSTS> # Required. A comma delimited string of hosts. Example: "aerospike:3000,aerospike2:3000"
- name: namespace
value: <REPLACE-WITH-NAMESPACE> # Required. The aerospike namespace.
- name: set
value: <REPLACE-WITH-SET> # Optional
```
{{% alert title="Warning" color="warning" %}}
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 %}}
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| hosts | Y | Host name/port of database server | `"localhost:3000"`, `"aerospike:3000,aerospike2:3000"`
| namespace | Y | The Aerospike namespace | `"namespace"`
| set | N | The setName in the database | `"myset"`
## Setup Aerospike
{{< tabs "Self-Hosted" "Kubernetes" >}}
@ -27,7 +61,7 @@ helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubato
helm install --name my-aerospike --namespace aerospike stable/aerospike
```
This will install Aerospike into the `aerospike` namespace.
This installs Aerospike into the `aerospike` namespace.
To interact with Aerospike, find the service with: `kubectl get svc aerospike -n aerospike`.
For example, if installing using the example above, the Aerospike host address would be:
@ -37,44 +71,7 @@ For example, if installing using the example above, the Aerospike host address w
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Aerospike.
Create the following YAML file named `aerospike.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.Aerospike
version: v1
metadata:
- name: hosts
value: <REPLACE-WITH-HOSTS> # Required. A comma delimited string of hosts. Example: "aerospike:3000,aerospike2:3000"
- name: namespace
value: <REPLACE-WITH-NAMESPACE> # Required. The aerospike namespace.
- name: set
value: <REPLACE-WITH-SET> # Optional.
```
{{% alert title="Warning" color="warning" %}}
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 %}}
## Apply the configuration
### In Kubernetes
To apply the Aerospike state store to Kubernetes, use the `kubectl` CLI:
```
kubectl apply -f aerospike.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`.
## 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 >}})

View File

@ -5,22 +5,10 @@ linkTitle: "Azure Blob Storage"
description: Detailed information on the Azure Blob Store state store component
---
## Creating Azure Storage account
## Component format
[Follow the instructions](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal) from the Azure documentation on how to create an Azure Storage Account.
To setup Azure Blobstorage state store create a component of type `state.azure.blobstorage`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
If you wish to create a container for Dapr to use, you can do so beforehand. However, Blob Storage state provider will create one for you automatically if it doesn't exist.
In order to setup Azure Blob Storage as a state store, you will need the following properties:
- **AccountName**: The storage account name. For example: **mystorageaccount**.
- **AccountKey**: Primary or secondary storage key.
- **ContainerName**: The name of the container to be used for Dapr state. The container will be created for you if it doesn't exist.
## Create a Dapr component
The next step is to create a Dapr component for Azure Blob Storage.
Create the following YAML file named `azureblob.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
@ -44,29 +32,25 @@ 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 %}}
### Example
The following example uses the Kubernetes secret store to retrieve the secrets:
## Spec metadata fields
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.azure.blobstorage
version: v1
metadata:
- name: accountName
value: <REPLACE-WITH-ACCOUNT-NAME>
- name: accountKey
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
- name: containerName
value: <REPLACE-WITH-CONTAINER-NAME>
```
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| accountName | Y | The storage account name | `"mystorageaccount"`.
| accountKey | Y | Primary or secondary storage key | `"key"`
| containerName | Y | The name of the container to be used for Dapr state. The container will be created for you if it doesn't exist | `"container"`
## Setup Azure Blobstorage
[Follow the instructions](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal) from the Azure documentation on how to create an Azure Storage Account.
If you wish to create a container for Dapr to use, you can do so beforehand. However, Blob Storage state provider will create one for you automatically if it doesn't exist.
In order to setup Azure Blob Storage as a state store, you will need the following properties:
- **AccountName**: The storage account name. For example: **mystorageaccount**.
- **AccountKey**: Primary or secondary storage key.
- **ContainerName**: The name of the container to be used for Dapr state. The container will be created for you if it doesn't exist.
## Apply the configuration
@ -77,7 +61,6 @@ To apply Azure Blob Storage state store to Kubernetes, use the `kubectl` CLI:
```
kubectl apply -f azureblob.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`.
@ -97,9 +80,13 @@ curl -X POST http://localhost:3500/v1.0/state \
]'
```
will create the blob file in the containter with key as filename and value as the contents of file.
creates the blob file in the containter with `key` as filename and `value` as the contents of file.
## Concurrency
Azure Blob Storage state concurrency is achieved by using `ETag`s according to [the official documenation](https://docs.microsoft.com/en-us/azure/storage/common/storage-concurrency#managing-concurrency-in-blob-storage).
Azure Blob Storage state concurrency is achieved by using `ETag`s according to [the Azure Blob Storage documentation](https://docs.microsoft.com/en-us/azure/storage/common/storage-concurrency#managing-concurrency-in-blob-storage).
## 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 >}})

View File

@ -5,23 +5,9 @@ linkTitle: "Azure Cosmos DB"
description: Detailed information on the Azure CosmosDB state store component
---
## Create a Azure Cosmos DB account
## Component format
[Follow the instructions](https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-manage-database-account) from the Azure documentation on how to create an Azure CosmosDB account. The database and collection must be created in CosmosDB before Dapr can use it.
**Note : The partition key for the collection must be named "/partitionKey". Note: this is case-sensitive.**
In order to setup CosmosDB as a state store, you need the following properties:
- **URL**: the CosmosDB url. for example: https://******.documents.azure.com:443/
- **Master Key**: The key to authenticate to the CosmosDB account
- **Database**: The name of the database
- **Collection**: The name of the collection
## Create a Dapr component
The next step is to create a Dapr component for CosmosDB.
Create the following YAML file named `cosmosdb.yaml`:
To setup Azure CosmosDb state store create a component of type `state.azure.cosmosdb`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -47,52 +33,6 @@ 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 %}}
### Example
Here is an example of what the values could look like:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.azure.cosmosdb
version: v1
metadata:
- name: url
value: https://accountname.documents.azure.com:443
- name: masterKey
value: thekey==
- name: database
value: db1
- name: collection
value: c1
```
The following example uses the Kubernetes secret store to retrieve the secrets:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.azure.cosmosdb
version: v1
metadata:
- name: url
value: <REPLACE-WITH-URL>
- name: masterKey
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
- name: database
value: <REPLACE-WITH-DATABASE>
- name: collection
value: <REPLACE-WITH-COLLECTION>
```
If you wish to use CosmosDb as an actor store, append the following to the yaml.
```yaml
@ -100,23 +40,31 @@ If you wish to use CosmosDb as an actor store, append the following to the yaml.
value: "true"
```
## Apply the configuration
## Spec metadata fields
### In Kubernetes
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| url | Y | The CosmosDB url | `"https://******.documents.azure.com:443/"`.
| masterKey | Y | The key to authenticate to the CosmosDB account | `"key"`
| database | Y | The name of the database | `"db"`
| collection | Y | The name of the collection | `"collection"`
| actorStateStore | N | Consider this state store for actors. Defaults to `"false"` | `"true"`, `"false"`
To apply the CosmosDB state store to Kubernetes, use the `kubectl` CLI:
## Setup Azure Cosmos DB
```
kubectl apply -f cosmos.yaml
```
[Follow the instructions](https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-manage-database-account) from the Azure documentation on how to create an Azure CosmosDB account. The database and collection must be created in CosmosDB before Dapr can use it.
### Running locally
**Note : The partition key for the collection must be named "/partitionKey". Note: this is case-sensitive.**
To run locally, create a YAML file described above and provide the path to the `dapr run` command with the flag `--components-path`. See [this](https://github.com/dapr/cli#use-non-default-components-path) or run `dapr run --help` for more information on the path.
In order to setup CosmosDB as a state store, you need the following properties:
- **URL**: the CosmosDB url. for example: https://******.documents.azure.com:443/
- **Master Key**: The key to authenticate to the CosmosDB account
- **Database**: The name of the database
- **Collection**: The name of the collection
## Data format
To use the cosmos state store, your data must be sent to Dapr in json-serialized. Having it just json *serializable* will not work.
To use the CosmosDB state store, your data must be sent to Dapr in JSON-serialized. Having it just JSON *serializable* will not work.
If you are using the Dapr SDKs (e.g. https://github.com/dapr/dotnet-sdk) the SDK will serialize your data to json.
@ -124,7 +72,6 @@ For examples see the curl operations in the [Partition keys](#partition-keys) se
## Partition keys
For **non-actor state** operations, the Azure Cosmos DB state store will use the `key` property provided in the requests to the Dapr API to determine the Cosmos DB partition key. This can be overridden by specifying a metadata field in the request with a key of `partitionKey` and a value of the desired partition.
The following operation will use `nihilus` as the partition key value sent to CosmosDB:
@ -157,4 +104,9 @@ curl -X POST http://localhost:3500/v1.0/state/<store_name> \
```
For **actor** state operations, the partition key will be generated by Dapr using the appId, the actor type, and the actor id, such that data for the same actor will always end up under the same partition (you do not need to specify it). This is because actor state operations must use transactions, and in Cosmos DB the items in a transaction must be on the same partition.
For **actor** state operations, the partition key is generated by Dapr using the `appId`, the actor type, and the actor id, such that data for the same actor always ends up under the same partition (you do not need to specify it). This is because actor state operations must use transactions, and in CosmosDB the items in a transaction must be on the same partition.
## 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 >}})

View File

@ -5,22 +5,9 @@ linkTitle: "Azure Table Storage "
description: Detailed information on the Azure Table Storage state store component
---
## Create an Azure Storage account
## Component format
[Follow the instructions](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal) from the Azure documentation on how to create an Azure Storage Account.
If you wish to create a table for Dapr to use, you can do so beforehand. However, Table Storage state provider will create one for you automatically if it doesn't exist.
In order to setup Azure Table Storage as a state store, you will need the following properties:
**AccountName**: The storage account name. For example: **mystorageaccount**.
**AccountKey**: Primary or secondary storage key.
- **TableName**: The name of the table to be used for Dapr state. The table will be created for you if it doesn't exist.
## Create a Dapr component
The next step is to create a Dapr component for Azure Table Storage.
Create the following YAML file named `azuretable.yaml`:
To setup Azure Tablestorage state store create a component of type `state.azure.tablestorage`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -44,47 +31,28 @@ 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 %}}
### Example
## Spec metadata fields
The following example uses the Kubernetes secret store to retrieve the secrets:
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| accountName | Y | The storage account name | `"mystorageaccount"`.
| accountKey | Y | Primary or secondary storage key | `"key"`
| tableName | Y | The name of the table to be used for Dapr state. The table will be created for you if it doesn't exist | `"table"`
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.azure.tablestorage
version: v1
metadata:
- name: accountName
value: <REPLACE-WITH-ACCOUNT-NAME>
- name: accountKey
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
- name: tableName
value: <REPLACE-WITH-TABLE-NAME>
```
## Setup Azure Table Storage
## Apply the configuration
[Follow the instructions](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal) from the Azure documentation on how to create an Azure Storage Account.
### In Kubernetes
If you wish to create a table for Dapr to use, you can do so beforehand. However, Table Storage state provider will create one for you automatically if it doesn't exist.
To apply Azure Table Storage state store to Kubernetes, use the `kubectl` CLI:
```
kubectl apply -f azuretable.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`.
In order to setup Azure Table Storage as a state store, you will need the following properties:
- **AccountName**: The storage account name. For example: **mystorageaccount**.
- **AccountKey**: Primary or secondary storage key.
- **TableName**: The name of the table to be used for Dapr state. The table will be created for you if it doesn't exist.
## Partitioning
The Azure Table Storage state store will use the `key` property provided in the requests to the Dapr API to determine the `row key`. Service Name is used for `partition key`. This provides best performance, as each service type will store state in it's own table partition.
The Azure Table Storage state store uses the `key` property provided in the requests to the Dapr API to determine the `row key`. Service Name is used for `partition key`. This provides best performance, as each service type stores state in it's own table partition.
This state store creates a column called `Value` in the table storage and puts raw state inside it.
@ -111,3 +79,8 @@ will create the following record in a table:
Azure Table Storage state concurrency is achieved by using `ETag`s according to [the official documenation]( https://docs.microsoft.com/en-us/azure/storage/common/storage-concurrency#managing-concurrency-in-table-storage).
## 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 >}})

View File

@ -5,43 +5,9 @@ linkTitle: "Cassandra"
description: Detailed information on the Cassandra state store component
---
## Create a Cassandra state store
## Component format
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Cassandra locally with the Datastax Docker image:
```
docker run -e DS_LICENSE=accept --memory 4g --name my-dse -d datastax/dse-server -g -s -k
```
You can then interact with the server using `localhost:9042`.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install Cassandra on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/cassandra):
```
kubectl create namespace cassandra
helm install cassandra incubator/cassandra --namespace cassandra
```
This will install Cassandra into the `cassandra` namespace by default.
To interact with Cassandra, find the service with: `kubectl get svc -n cassandra`.
For example, if installing using the example above, the Cassandra DNS would be:
`cassandra.cassandra.svc.cluster.local`
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Cassandra.
Create the following YAML file named `cassandra.yaml`:
To setup Cassandra state store create a component of type `state.cassandra`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -75,43 +41,53 @@ 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 %}}
### Example
## Spec metadata fields
The following example uses the Kubernetes secret store to retrieve the username and password:
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| hosts | Y | Comma separated value of the hosts | `"cassandra.cassandra.svc.cluster.local"`.
| port | N | Port for communication. Default `"9042"` | `"9042"`
| username | Y | The username of database user. No default | `"user"`
| password | Y | The password for the user | `"password"`
| consistency | N | The consistency values | `"All"`, `"Quorum"`
| table | N | Table name. Defaults to `"items"` | `"items"`, `"tab"`
| keyspace | N | The cassandra keyspace to use. Defaults to `"dapr"` | `"dapr"`
| protoVersion | N | The proto version for the client. Defaults to `"4"` | `"3"`, `"4"`
| replicationFactor | N | The replication factor for the calls. Defaults to `"1"` | `"3"`
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.cassandra
version: v1
metadata:
- name: hosts
value: <REPLACE-WITH-HOSTS>
- name: username
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
- name: password
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
...
```
## Setup Cassandra
## Apply the configuration
{{< tabs "Self-Hosted" "Kubernetes" >}}
### In Kubernetes
To apply the Cassandra state store to Kubernetes, use the `kubectl` CLI:
{{% codetab %}}
You can run Cassandra locally with the Datastax Docker image:
```
kubectl apply -f cassandra.yaml
docker run -e DS_LICENSE=accept --memory 4g --name my-dse -d datastax/dse-server -g -s -k
```
### Running locally
You can then interact with the server using `localhost:9042`.
{{% /codetab %}}
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`.
{{% codetab %}}
The easiest way to install Cassandra on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/cassandra):
```
kubectl create namespace cassandra
helm install cassandra incubator/cassandra --namespace cassandra
```
This installs Cassandra into the `cassandra` namespace by default.
To interact with Cassandra, find the service with: `kubectl get svc -n cassandra`.
For example, if installing using the example above, the Cassandra DNS would be:
`cassandra.cassandra.svc.cluster.local`
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -5,13 +5,43 @@ linkTitle: "Cloudstate"
description: Detailed information on the Cloudstate state store component
---
## Component format
To setup Cloudstate state store create a component of type `state.cloudstate`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.cloudstate
version: v1
metadata:
- name: host
value: <REPLACE-WITH-HOST>
- name: serverPort
value: <REPLACE-WITH-PORT>
```
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| hosts | Y | Specifies the address for the Cloudstate API | `"localhost:8013"`
| serverPort | Y | Specifies the port to be opened in Dapr for Cloudstate to callback to. This can be any free port that is not used by either your application or Dapr | `"8080"`
> Since Cloudstate is running as an additional sidecar in the pod, you can reach it via `localhost` with the default port of `8013`.
## Introduction
The Cloudstate-Dapr integration is unique in the sense that it enables developers to achieve high-throughput, low latency scenarios by leveraging Cloudstate running as a sidecar *next* to Dapr, keeping the state near the compute unit for optimal performance while providing replication between multiple instances that can be safely scaled up and down. This is due to Cloudstate forming an Akka cluster between its sidecars with replicated in-memory entities.
Dapr leverages Cloudstate's CRDT capabilities with last-write-wins semantics.
## Setup a Cloudstate state store
## Setup Cloudstate
To install Cloudstate on your Kubernetes cluster, run the following commands:
@ -20,33 +50,7 @@ kubectl create namespace cloudstate
kubectl apply -n cloudstate -f https://github.com/cloudstateio/cloudstate/releases/download/v0.5.0/cloudstate-0.5.0.yaml
```
This will install Cloudstate into the `cloudstate` namespace with version `0.5.0`.
## Create a Dapr component
The next step is to create a Dapr component for Cloudstate.
Create the following YAML file named `cloudstate.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: cloudstate
namespace: default
spec:
type: state.cloudstate
version: v1
metadata:
- name: host
value: "localhost:8013"
- name: serverPort
value: "8080"
```
The `metadata.host` field specifies the address for the Cloudstate API. Since Cloudstate will be running as an additional sidecar in the pod, you can reach it via `localhost` with the default port of `8013`.
The `metadata.serverPort` field specifies the port to be opened in Dapr for Cloudstate to callback to. This can be any free port that is not used by either your application or Dapr.
This installs Cloudstate into the `cloudstate` namespace with version `0.5.0`.
## Apply the configuration
@ -64,7 +68,7 @@ The next examples shows you how to manually inject a Cloudstate sidecar into a D
*Notice the `HTTP_PORT` for the `cloudstate-sidecar` container is the port to be used in the Cloudstate component yaml in `host`.*
```
```yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
@ -159,4 +163,9 @@ roleRef:
subjects:
- kind: ServiceAccount
name: default
```
```
## 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 >}})

View File

@ -5,42 +5,10 @@ linkTitle: "HashiCorp Consul"
description: Detailed information on the HashiCorp Consul state store component
---
## Setup a HashiCorp Consul state store
## Component format
{{< tabs "Self-Hosted" "Kubernetes" >}}
To setup Hashicorp Consul state store create a component of type `state.consul`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
{{% codetab %}}
You can run Consul locally using Docker:
```
docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 consul
```
You can then interact with the server using `localhost:8500`.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install Consul on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/consul):
```
helm install consul stable/consul
```
This will install Consul into the `default` namespace.
To interact with Consul, find the service with: `kubectl get svc consul`.
For example, if installing using the example above, the Consul host address would be:
`consul.default.svc.cluster.local:8500`
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Consul.
Create the following YAML file named `consul.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
@ -68,41 +36,48 @@ 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 %}}
### Example
## Spec metadata fields
The following example uses the Kubernetes secret store to retrieve the acl token:
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| datacenter | Y | Datacenter to use | `"dc1"`
| httpAddr | Y | Address of the Consul server | `"consul.default.svc.cluster.local:8500"`
| aclToken | N | Per Request ACL Token. Default is `""` | `"token"`
| scheme | N | Scheme is the URI scheme for the Consul server. Default is `"http"` | `"http"`
| keyPrefixPath | N | Key prefix path in Consul. Default is `""` | `"dapr"`
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.consul
version: v1
metadata:
- name: datacenter
value: <REPLACE-WITH-DATACENTER>
- name: httpAddr
value: <REPLACE-WITH-HTTP-ADDRESS>
- name: aclToken
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
...
```
## Setup HashiCorp Consul
## Apply the configuration
{{< tabs "Self-Hosted" "Kubernetes" >}}
### In Kubernetes
To apply the Consul state store to Kubernetes, use the `kubectl` CLI:
{{% codetab %}}
You can run Consul locally using Docker:
```
kubectl apply -f consul.yaml
docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 consul
```
### Running locally
You can then interact with the server using `localhost:8500`.
{{% /codetab %}}
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`.
{{% codetab %}}
The easiest way to install Consul on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/consul):
```
helm install consul stable/consul
```
This installs Consul into the `default` namespace.
To interact with Consul, find the service with: `kubectl get svc consul`.
For example, if installing using the example above, the Consul host address would be:
`consul.default.svc.cluster.local:8500`
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -5,37 +5,10 @@ linkTitle: "Couchbase"
description: Detailed information on the Couchbase state store component
---
## Create a Couchbase state store
## Component format
{{< tabs "Self-Hosted" "Kubernetes" >}}
To setup Couchbase state store create a component of type `state.couchbase`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
{{% codetab %}}
You can run Couchbase locally using Docker:
```
docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase
```
You can then interact with the server using `localhost:8091` and start the server setup.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install Couchbase on Kubernetes is by using the [Helm chart](https://github.com/couchbase-partners/helm-charts#deploying-for-development-quick-start):
```
helm repo add couchbase https://couchbase-partners.github.io/helm-charts/
helm install couchbase/couchbase-operator
helm install couchbase/couchbase-cluster
```
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Couchbase.
Create the following YAML file named `couchbase.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
@ -61,16 +34,42 @@ 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 %}}
## Apply the configuration
## Spec metadata fields
### In Kubernetes
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| couchbaseURL | Y | The URL of the Couchbase server | `"http://localhost:8091"`
| username | Y | The username for the database | `"user"`
| password | Y | The password for access | `"password"`
| bucketName | Y | The bucket name to write to | `"bucket"`
To apply the Couchbase state store to Kubernetes, use the `kubectl` CLI:
## Setup Couchbase
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Couchbase locally using Docker:
```
kubectl apply -f couchbase.yaml
docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase
```
### Running locally
You can then interact with the server using `localhost:8091` and start the server setup.
{{% /codetab %}}
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`.
{{% codetab %}}
The easiest way to install Couchbase on Kubernetes is by using the [Helm chart](https://github.com/couchbase-partners/helm-charts#deploying-for-development-quick-start):
```
helm repo add couchbase https://couchbase-partners.github.io/helm-charts/
helm install couchbase/couchbase-operator
helm install couchbase/couchbase-cluster
```
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -1,80 +0,0 @@
---
type: docs
title: "etcd"
linkTitle: "etcd"
description: Detailed information on the etcd state store component
---
## Setup an etcd state store
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run etcd locally using Docker:
```
docker run -d --name etcd bitnami/etcd
```
You can then interact with the server using `localhost:2379`.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install etcd on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/etcd):
```
helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
helm install etcd incubator/etcd
```
This will install etcd into the `default` namespace.
To interact with etcd, find the service with: `kubectl get svc etcd-etcd`.
For example, if installing using the example above, the etcd host address would be:
`etcd-etcd.default.svc.cluster.local:2379`
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for etcd.
Create the following YAML file named `etcd.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.etcd
version: v1
metadata:
- name: endpoints
value: <REPLACE-WITH-COMMA-DELIMITED-ENDPOINTS> # Required. Example: "etcd-etcd.default.svc.cluster.local:2379"
- name: dialTimeout
value: <REPLACE-WITH-DIAL-TIMEOUT> # Required. Example: "5s"
- name: operationTimeout
value: <REPLACE-WITH-OPERATION-TIMEOUT> # Optional. default: "10S"
```
{{% alert title="Warning" color="warning" %}}
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 %}}
## Apply the configuration
### In Kubernetes
To apply the etcd state store to Kubernetes, use the `kubectl` CLI:
```
kubectl apply -f etcd.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`.

View File

@ -5,27 +5,10 @@ linkTitle: "GCP Firestore"
description: Detailed information on the GCP Firestore state store component
---
## Setup a GCP Firestone state store
## Component format
{{< tabs "Self-Hosted" "Google Cloud" >}}
To setup GCP Firestore state store create a component of type `state.gcp.firestore`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
{{% codetab %}}
You can use the GCP Datastore emulator to run locally using the instructions [here](https://cloud.google.com/datastore/docs/tools/datastore-emulator).
You can then interact with the server using `localhost:8081`.
{{% /codetab %}}
{{% codetab %}}
Follow the instructions [here](https://cloud.google.com/datastore/docs/quickstart) to get started with setting up Firestore in Google Cloud.
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Firestore.
Create the following YAML file named `firestore.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
@ -65,16 +48,39 @@ 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 %}}
## Apply the configuration
## Spec metadata fields
### In Kubernetes
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| type | Y | The credentials type | `"serviceaccount"`
| project_id | Y | The ID of the GCP project to use | `"project-id"`
| private_key_id | Y | The ID of the prvate key to use | `"private-key-id"`
| client_email | Y | The email address for the client | `"eample@example.com"`
| client_id | Y | The client id value to use for authentication | `"client-id"`
| auth_uri | Y | The authentication URI to use | `"https://accounts.google.com/o/oauth2/auth"`
| token_uri | Y | The token URI to query for Auth token | `"https://oauth2.googleapis.com/token"`
| auth_provider_x509_cert_url | Y | The auth provider certificate URL | `"https://www.googleapis.com/oauth2/v1/certs"`
| client_x509_cert_url | Y | The client certificate URL | `"https://www.googleapis.com/robot/v1/metadata/x509/x"`
| entity_kind | N | The entity name in Filestore. Defaults to `"DaprState"` | `"DaprState"`
To apply the Firestore state store to Kubernetes, use the `kubectl` CLI:
## Setup GCP Firestone
```
kubectl apply -f firestore.yaml
```
{{< tabs "Self-Hosted" "Google Cloud" >}}
### Running locally
{{% codetab %}}
You can use the GCP Datastore emulator to run locally using the instructions [here](https://cloud.google.com/datastore/docs/tools/datastore-emulator).
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`.
You can then interact with the server using `localhost:8081`.
{{% /codetab %}}
{{% codetab %}}
Follow the instructions [here](https://cloud.google.com/datastore/docs/quickstart) to get started with setting up Firestore in Google Cloud.
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -5,31 +5,9 @@ linkTitle: "Hazelcast"
description: Detailed information on the Hazelcast state store component
---
## Setup a Hazelcast state store
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Hazelcast locally using Docker:
```
docker run -e JAVA_OPTS="-Dhazelcast.local.publicAddress=127.0.0.1:5701" -p 5701:5701 hazelcast/hazelcast
```
You can then interact with the server using the `127.0.0.1:5701`.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install Hazelcast on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/hazelcast).
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Hazelcast.
Create the following YAML file named `hazelcast.yaml`:
To setup Hazelcast state store create a component of type `state.hazelcast`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -51,16 +29,34 @@ 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 %}}
## Apply the configuration
## Spec metadata fields
### In Kubernetes
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| hazelcastServers | Y | A comma delimited string of servers | `"hazelcast:3000,hazelcast2:3000"`
| hazelcastMap | Y | Hazelcast Map configuration | `"foo-map"`
To apply the Hazelcast state store to Kubernetes, use the `kubectl` CLI:
## Setup Hazelcast
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Hazelcast locally using Docker:
```
kubectl apply -f hazelcast.yaml
docker run -e JAVA_OPTS="-Dhazelcast.local.publicAddress=127.0.0.1:5701" -p 5701:5701 hazelcast/hazelcast
```
### Running locally
You can then interact with the server using the `127.0.0.1:5701`.
{{% /codetab %}}
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`.
{{% codetab %}}
The easiest way to install Hazelcast on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/hazelcast).
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -5,42 +5,9 @@ linkTitle: "Memcached"
description: Detailed information on the Memcached state store component
---
## Setup a Memcached state store
## Component format
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Memcached locally using Docker:
```
docker run --name my-memcache -d memcached
```
You can then interact with the server using `localhost:11211`.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install Memcached on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/memcached):
```
helm install memcached stable/memcached
```
This will install Memcached into the `default` namespace.
To interact with Memcached, find the service with: `kubectl get svc memcached`.
For example, if installing using the example above, the Memcached host address would be:
`memcached.default.svc.cluster.local:11211`
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Memcached.
Create the following YAML file named `memcached.yaml`:
To setup Memcached state store create a component of type `state.memcached`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -64,16 +31,46 @@ 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 %}}
## Apply the configuration
## Spec metadata fields
### In Kubernetes
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| hosts | Y | Comma delimited endpoints | `"memcached.default.svc.cluster.local:11211"`
| maxIdleConnections | N | The max number of idle connections. Defaults to `"2"` | `"3"`
| timeout | N | The timeout for the calls. Defaults to `"1000ms"` | `"1000ms"`
To apply the Memcached state store to Kubernetes, use the `kubectl` CLI:
## Setup Memcached
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Memcached locally using Docker:
```
kubectl apply -f memcached.yaml
docker run --name my-memcache -d memcached
```
### Running locally
You can then interact with the server using `localhost:11211`.
{{% /codetab %}}
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`.
{{% codetab %}}
The easiest way to install Memcached on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/memcached):
```
helm install memcached stable/memcached
```
This installs Memcached into the `default` namespace.
To interact with Memcached, find the service with: `kubectl get svc memcached`.
For example, if installing using the example above, the Memcached host address would be:
`memcached.default.svc.cluster.local:11211`
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -5,46 +5,10 @@ linkTitle: "MongoDB"
description: Detailed information on the MongoDB state store component
---
## Setup a MongoDB state store
## Component format
{{< tabs "Self-Hosted" "Kubernetes" >}}
To setup MongoDB state store create a component of type `state.mongodb`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
{{% codetab %}}
You can run MongoDB locally using Docker:
```
docker run --name some-mongo -d mongo
```
You can then interact with the server using `localhost:27017`.
{{% /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):
```
helm install mongo stable/mongodb
```
This will install 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:
`mongo-mongodb.default.svc.cluster.local:27017`
Follow the on-screen instructions to get the root password for MongoDB.
The username will be `admin` by default.
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for MongoDB.
Create the following YAML file named `mongodb.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
@ -78,44 +42,63 @@ 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 %}}
### Example
The following example uses the Kubernetes secret store to retrieve the username and password:
If you wish to use MongoDB as an actor store, append the following to the yaml.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.mondodb
version: v1
metadata:
- name: host
value: <REPLACE-WITH-HOST>
- name: username
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
- name: password
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
...
```
## Apply the configuration
### In Kubernetes
To apply the MondoDB state store to Kubernetes, use the `kubectl` CLI:
```
kubectl apply -f mongodb.yaml
- name: actorStateStore
value: "true"
```
### 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`.
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| host | Y | The host to connect to | `"mongo-mongodb.default.svc.cluster.local:27017"`
| username | N | The username of the user to connect with | `"admin"`
| password | N | The password of the user | `"password"`
| databaseName | N | The name of the database to use. Defaults to `"daprStore"` | `"daprStore"`
| collectionName | N | The name of the collection to use. Defaults to `"daprCollection"` | `"daprCollection"`
| 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. Defautls to `"5s"` | `"5s"`
## Setup MongoDB
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run MongoDB locally using Docker:
```
docker run --name some-mongo -d mongo
```
You can then interact with the server using `localhost:27017`.
{{% /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):
```
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:
`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.
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})

View File

@ -5,9 +5,54 @@ linkTitle: "MySQL"
description: Detailed information on the MySQL state store component
---
## Create a MySQL Store
## Component format
Dapr can use any MySQL instance - containerized, running on your local dev machine, or a managed cloud service. If you already have a MySQL store, move on to the [Create a Dapr component](#create-a-dapr-component) section.
To setup MySQL state store create a component of type `state.mysql`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.mysql
version: v1
metadata:
- name: connectionString
value: "<CONNECTION STRING>"
- name: schemaName
value: "<SCHEMA NAME>"
- name: tableName
value: "<TABLE NAME>"
- name: pemPath
value: "<PEM PATH>"
```
{{% alert title="Warning" color="warning" %}}
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 MySQL as an actor store, append the following to the yaml.
```yaml
- name: actorStateStore
value: "true"
```
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| connectionString | Y | The connection string to connect to MySQL. Do not add the schema to the connection string | [Non SSL connection](#non-ssl-connection): `"<user>:<password>@tcp(<server>:3306)/?allowNativePasswords=true"`, [Enforced SSL Connection](#enforced-ssl-connection): `"<user>:<password>@tcp(<server>:3306)/?allowNativePasswords=true&tls=custom"`|
| schemaName | N | The schema name to use. Will be created if schema does not exist. Defaults to `"dapr_state_store"` | `"custom_schema"`, `"dapr_schema"` |
| tableName | N | The table name to use. Will be created if table does not exist. Defaults to `"state"` | `"table_name"`, `"dapr_state"` |
| pemPath | N | Full path to the PEM file to use for [enforced SSL Connection](#enforced-ssl-connection) | `"/path/to/file.pem"`, `"C:\path\to\file.pem"` |
## Setup MySQL
Dapr can use any MySQL instance - containerized, running on your local dev machine, or a managed cloud service.
{{< tabs "Self-Hosted" "Kubernetes" "Azure" "AWS" "GCP" >}}
@ -72,74 +117,15 @@ If you are using [MySQL on Azure](http://bit.ly/AzureMySQLSSL) see the Azure [do
{{< /tabs >}}
## Create a Dapr component
### Non SSL connection
Create a file called `mysqlstate.yaml`, paste the following and replace the `<CONNECTION STRING>` value with your connection string. The connection string is a standard MySQL connection string. For example, `"<user>:<password>@tcp(<server>:3306)/?allowNativePasswords=true"`. Do not add the schema to the connection string. The component connects to the server first to check for the existence of the desired schema. If the schemaName is not provided the default value of **dapr_state_store** will be used. If the schema does not exist it will be created.
The tableName is also optional and if not provided will default to **state**. If the table does ont exist it will be created.
If you want to also configure MySQL to store actors, add the `actorStateStore` configuration element shown below.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.mysql
version: v1
metadata:
- name: connectionString
value: "<CONNECTION STRING>"
- name: schemaName
value: "<SCHEMA NAME>"
- name: tableName
value: "<TABLE NAME>"
- name: actorStateStore
value: "true"
```
Replace the `<CONNECTION STRING>` value with your connection string. The connection string is a standard MySQL connection string. For example, `"<user>:<password>@tcp(<server>:3306)/?allowNativePasswords=true"`.
### Enforced SSL connection
If your server requires SSL your connection string must end with `&tls=custom` for example, `"<user>:<password>@tcp(<server>:3306)/?allowNativePasswords=true&tls=custom"`. You must replace the `<PEM PATH>` with a full path to the PEM file. The connection to MySQL will require a minimum TLS version of 1.2.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.mysql
version: v1
metadata:
- name: connectionString
value: "<CONNECTION STRING>"
- name: schemaName
value: "<SCHEMA NAME>"
- name: tableName
value: "<TABLE NAME>"
- name: pemPath
value: "<PEM PATH>"
- name: actorStateStore
value: "true"
```
{{% alert title="Warning" color="warning" %}}
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 %}}
## Apply the configuration
### In Kubernetes
To apply the MySQL state store to Kubernetes, use the `kubectl` CLI:
```yaml
kubectl apply -f mysqlstate.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`.
## 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 >}})

View File

@ -5,9 +5,50 @@ linkTitle: "PostgreSQL"
description: Detailed information on the PostgreSQL state store component
---
## Create a PostgreSQL Store
## Create a Dapr component
Dapr can use any PostgreSQL instance. If you already have a running instance of PostgreSQL, move on to the [Create a Dapr component](#create-a-dapr-component) section.
Create a file called `postgres.yaml`, paste the following and replace the `<CONNECTION STRING>` value with your connection string. The connection string is a standard PostgreSQL connection string. For example, `"host=localhost user=postgres password=example port=5432 connect_timeout=10 database=dapr_test"`. See the PostgreSQL [documentation on database connections](https://www.postgresql.org/docs/current/libpq-connect.html), specifically Keyword/Value Connection Strings, for information on how to define a connection string.
If you want to also configure PostgreSQL to store actors, add the `actorStateStore` configuration element shown below.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.postgresql
version: v1
metadata:
- name: connectionString
value: "<CONNECTION STRING>"
```
{{% alert title="Warning" color="warning" %}}
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 %}}
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| connectionString | Y | The connection string for PostgreSQL | `"User ID=root;Password=myPassword;Host=localhost;Port=5432"`
| actorStateStore | N | Consider this state store for actors. Defaults to `"false"` | `"true"`, `"false"`
If you wish to use PostgreSQL as an actor store, append the following to the yaml.
```yaml
- name: actorStateStore
value: "true"
```
## Create PostgreSQL
{{< tabs "Self-Hosted" >}}
{{% codetab %}}
1. Run an instance of PostgreSQL. You can run a local instance of PostgreSQL in Docker CE with the following command:
@ -25,41 +66,11 @@ Either the default "postgres" database can be used, or create a new database for
```SQL
create database dapr_test
```
{{% /codetab %}}
## Create a Dapr component
{{% /tabs %}}
Create a file called `postgres.yaml`, paste the following and replace the `<CONNECTION STRING>` value with your connection string. The connection string is a standard PostgreSQL connection string. For example, `"host=localhost user=postgres password=example port=5432 connect_timeout=10 database=dapr_test"`. See the PostgreSQL [documentation on database connections](https://www.postgresql.org/docs/current/libpq-connect.html), specifically Keyword/Value Connection Strings, for information on how to define a connection string.
If you want to also configure PostgreSQL to store actors, add the `actorStateStore` configuration element shown below.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.postgresql
version: v1
metadata:
- name: connectionString
value: "<CONNECTION STRING>"
- name: actorStateStore
value: "true"
```
{{% alert title="Warning" color="warning" %}}
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 %}}
## Apply the configuration
### In Kubernetes
To apply the PostgreSQL state store to Kubernetes, use the `kubectl` CLI:
```yaml
kubectl apply -f postgres.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`.
## 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 >}})

View File

@ -3,10 +3,68 @@ type: docs
title: "Redis"
linkTitle: "Redis"
description: Detailed information on the Redis state store component
weight: 10
---
## Create a Redis Store
## Component format
To setup Redis state store create a component of type `state.redis`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: <HOST>
- name: redisPassword
value: <PASSWORD>
- name: enableTLS
value: <bool> # Optional. Allowed: true, false.
- name: failover
value: <bool> # Optional. Allowed: true, false.
- name: sentinelMasterName
value: <string> # Optional
- name: maxRetries
value: # Optional
- name: maxRetryBackoff
value: # Optional
```
**TLS:** If the Redis instance supports TLS with public certificates it can be configured to enable or disable TLS `true` or `false`.
**Failover:** When set to `true` enables the failover feature. The redisHost should be the sentinel host address. See [Redis Sentinel Documentation](https://redis.io/topics/sentinel)
{{% alert title="Warning" color="warning" %}}
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 Redis as an actor store, append the following to the yaml.
```yaml
- name: actorStateStore
value: "true"
```
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| redisHost | Y | Connection-string for the redis host | `localhost:6379`, `redis-master.default.svc.cluster.local:6379`
| redisPassword | Y | Password for Redis host. No Default. Can be `secretKeyRef` to use a secret reference | `""`, `"KeFg23!"`
| consumerID | N | The consumer group ID | `"myGroup"`
| enableTLS | N | If the Redis instance supports TLS with public certificates, can be configured to be enabled or disabled. Defaults to `"false"` | `"true"`, `"false"`
| maxRetries | N | Maximum number of retries before giving up. Defaults to `3` | `5`, `10`
| maxRetryBackoff | N | Minimum backoff between each retry. Defaults to `2` seconds | `3000000000`
| failover | N | Property to enabled failover configuration. Needs sentinalMasterName to be set. Defaults to `"false"` | `"true"`, `"false"`
| sentinelMasterName | N | The sentinel master name. See [Redis Sentinel Documentation](https://redis.io/topics/sentinel) | `""`, `"127.0.0.1:6379"`
| actorStateStore | N | Consider this state store for actors. Defaults to `"false"` | `"true"`, `"false"`
## Setup Redis
Dapr can use any Redis instance - containerized, running on your local dev machine, or a managed cloud service. If you already have a Redis store, move on to the [Configuration](#configuration) section.
@ -32,7 +90,7 @@ We can use [Helm](https://helm.sh/) to quickly create a Redis instance in our Ku
- name: redisHost
value: redis-master:6379
```
4. Next, we'll get our Redis password, which is slightly different depending on the OS we're using:
4. Next, we'll get the Redis password, which is slightly different depending on the OS we're using:
- **Windows**: Run `kubectl get secret --namespace default redis -o jsonpath="{.data.redis-password}" > encoded.b64`, which will create a file with your encoded password. Next, run `certutil -decode encoded.b64 password.txt`, which will put your redis password in a text file called `password.txt`. Copy the password and delete the two files.
- **Linux/MacOS**: Run `kubectl get secret --namespace default redis -o jsonpath="{.data.redis-password}" | base64 --decode` and copy the outputted password.
@ -69,46 +127,11 @@ We can use [Helm](https://helm.sh/) to quickly create a Redis instance in our Ku
{{< /tabs >}}
## Create a Dapr component
**TLS:** If the Redis instance supports TLS with public certificates it can be configured to enable or disable TLS `true` or `false`.
**Failover:** When set to `true` enables the failover feature. The redisHost should be the sentinel host address. See [Redis Sentinel Documentation](https://redis.io/topics/sentinel)
Create a file called redis.yaml, and paste the following:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
namespace: default
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: <HOST>
- name: redisPassword
value: <PASSWORD>
- name: enableTLS
value: <bool> # Optional. Allowed: true, false.
- name: failover
value: <bool> # Optional. Allowed: true, false.
```
{{% alert title="Warning" color="warning" %}}
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 title="Note" color="primary" %}}
The Dapr CLI automatically deploys a local redis instance in self hosted mode as part of the `dapr init` command.
{{% /alert %}}
## Apply the configuration
### Kubernetes
```
kubectl apply -f redis.yaml
```
### Standalone
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`.
## 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 >}})

View File

@ -5,25 +5,9 @@ linkTitle: "RethinkDB"
description: Detailed information on the RethinkDB state store component
---
## Setup RethinkDB state store
## Component format
You can run [RethinkDB](https://rethinkdb.com/) locally using Docker:
```
docker run --name rethinkdb -v "$PWD:/rethinkdb-data" -d rethinkdb:latest
```
To connect to the admin UI:
```shell
open "http://$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' rethinkdb):8080"
```
## Create a Dapr component
The next step is to create a Dapr component for RethinkDB.
Create the following YAML file named `rethinkdb.yaml`
To setup RethinkDB state store create a component of type `state.rethinkdb`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -42,17 +26,61 @@ spec:
- name: table
value: # Optional
- name: username
value: # Optional
value: <USERNAME> # Optional
- name: password
value: # Optional
value: <PASSWORD> # Optional
- name: archive
value: # Optional (whether or not store should keep archive table of all the state changes)
value: bool # Optional (whether or not store should keep archive table of all the state changes)
```
{{% alert title="Warning" color="warning" %}}
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 Redis as an actor store, append the following to the yaml.
```yaml
- name: actorStateStore
value: "true"
```
RethinkDB state store supports transactions so it can be used to persist Dapr Actor state. By default, the state will be stored in table name `daprstate` in the specified database.
Additionally, if the optional `archive` metadata is set to `true`, on each state change, the RethinkDB state store will also log state changes with timestamp in the `daprstate_archive` table. This allows for time series analyses of the state managed by Dapr.
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| address | Y | The address for RethinkDB server | `"127.0.0.1:28015"`, `"rethinkdb.default.svc.cluster.local:28015"`
| database | Y | The database to use. Alpha-numerics only | `"dapr"`
| table | N | The table name to use | `"table"`
| username | N | The username to connect with | `"user"`
| password | N | The password to connect with | `"password"`
| archive | N | Whether or not to archive the table | `"true"`, `"false"`
## Setup RethinkDB
{{< tabs "Self-Hosted" >}}
{{% codetab %}}
You can run [RethinkDB](https://rethinkdb.com/) locally using Docker:
```
docker run --name rethinkdb -v "$PWD:/rethinkdb-data" -d rethinkdb:latest
```
To connect to the admin UI:
```shell
open "http://$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' rethinkdb):8080"
```
{{% /codetab %}}
{{% /codetab %}}
## 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 >}})

View File

@ -5,17 +5,67 @@ linkTitle: "SQL Server"
description: Detailed information on the SQL Server state store component
---
## Create an Azure SQL instance
## Component format
To setup SQL Server state store create a component of type `state.sqlserver`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.sqlserver
version: v1
metadata:
- name: connectionString
value: <REPLACE-WITH-CONNECTION-STRING> # Required.
- name: tableName
value: <REPLACE-WITH-TABLE-NAME> # Required.
- name: keyType
value: <REPLACE-WITH-KEY-TYPE> # Optional. defaults to "string"
- name: keyLength
value: <KEY-LENGTH> # Optional. defaults to 200. Yo be used with "string" keyType
- name: schema
value: <SCHEMA> # Optional. defaults to "dbo"
- name: indexedProperties
value: <INDEXED-PROPERTIES> # Optional. List of IndexedProperties.
```
{{% alert title="Warning" color="warning" %}}
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 %}}
{{% alert title="Note" color="primary" %}}
Currently this component does not support state management for actors
{{% /alert %}}
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| connectionString | Y | The connection string used to connect | `"Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;"`
| tableName | Y | The name of the table to use. Alpha-numeric with underscores | `"table_name"`
| keyType | N | The type of key used. Defaults to `"string"` | `"string"`
| keyLength | N | The max length of key. Used along with `"string"` keytype. Defaults to `"200"` | `"200"`
| schema | N | The schema to use. Defaults to `"dbo"` | `"dapr"`,`"dbo"`
| indexedProperties | N | List of IndexedProperties. | `"[{"ColumnName": "column", "Property": "property", "Type": "type"}]"`
## Create Azure SQL instance
[Follow the instructions](https://docs.microsoft.com/azure/sql-database/sql-database-single-database-get-started?tabs=azure-portal) from the Azure documentation on how to create a SQL database. The database must be created before Dapr consumes it.
**Note: SQL Server state store also supports SQL Server running on VMs.**
In order to setup SQL Server as a state store, you will need the following properties:
In order to setup SQL Server as a state store, you need the following properties:
- **Connection String**: the SQL Server connection string. For example: server=localhost;user id=sa;password=your-password;port=1433;database=mydatabase;
- **Schema**: The database schema to use (default=dbo). Will be created if not exists
- **Table Name**: The database table name. Will be created if not exists
- **Schema**: The database schema to use (default=dbo). Will be created if does not exist
- **Table Name**: The database table name. Will be created if does not exist
- **Indexed Properties**: Optional properties from json data which will be indexed and persisted as individual column
### Create a dedicated user
@ -25,66 +75,7 @@ When connecting with a dedicated user (not `sa`), these authorizations are requi
- `CREATE TABLE`
- `CREATE TYPE`
## Create a Dapr component
> Currently this component does not support state management for actors
The next step is to create a Dapr component for SQL Server.
Create the following YAML file named `sqlserver.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.sqlserver
version: v1
metadata:
- name: connectionString
value: <REPLACE-WITH-CONNECTION-STRING>
- name: tableName
value: <REPLACE-WITH-TABLE-NAME>
```
{{% alert title="Warning" color="warning" %}}
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 %}}
### Example
The following example uses the Kubernetes secret store to retrieve the secrets:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: state.sqlserver
version: v1
metadata:
- name: connectionString
secretKeyRef:
name: <KUBERNETES-SECRET-NAME>
key: <KUBERNETES-SECRET-KEY>
- name: tableName
value: <REPLACE-WITH-TABLE-NAME>
```
## Apply the configuration
### In Kubernetes
To apply the SQL Server state store to Kubernetes, use the `kubectl` CLI:
```yaml
kubectl apply -f sqlserver.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`.
## 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 >}})

View File

@ -5,43 +5,9 @@ linkTitle: "Zookeeper"
description: Detailed information on the Zookeeper state store component
---
## Setup a Zookeeper state store
## Component format
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Zookeeper locally using Docker:
```
docker run --name some-zookeeper --restart always -d zookeeper
```
You can then interact with the server using `localhost:2181`.
{{% /codetab %}}
{{% codetab %}}
The easiest way to install Zookeeper on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/zookeeper):
```
helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
helm install zookeeper incubator/zookeeper
```
This will install Zookeeper into the `default` namespace.
To interact with Zookeeper, find the service with: `kubectl get svc zookeeper`.
For example, if installing using the example above, the Zookeeper host address would be:
`zookeeper.default.svc.cluster.local:2181`
{{% /codetab %}}
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Zookeeper.
Create the following YAML file named `zookeeper.yaml`:
To setup Zookeeper state store create a component of type `state.zookeeper`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration.
```yaml
apiVersion: dapr.io/v1alpha1
@ -69,16 +35,50 @@ 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 %}}
## Apply the configuration
## Spec metadata fields
### In Kubernetes
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| servers | Y | Comma delimited list of servers | `"zookeeper.default.svc.cluster.local:2181"`
| sessionTimeout | Y | The session timeout value | `"5s"`
| maxBufferSize | N | The maximum size of buffer. Defaults to `"1048576"` | `"1048576"`
| maxConnBufferSize | N | The maximum size of connection buffer. Defautls to `"1048576`" | `"1048576"`
| keyPrefixPath | N | The key prefix path in Zookeeper. No default | `"dapr"`
To apply the Zookeeper state store to Kubernetes, use the `kubectl` CLI:
## Setup Zookeeper
{{< tabs "Self-Hosted" "Kubernetes" >}}
{{% codetab %}}
You can run Zookeeper locally using Docker:
```
kubectl apply -f zookeeper.yaml
docker run --name some-zookeeper --restart always -d zookeeper
```
### Running locally
You can then interact with the server using `localhost:2181`.
{{% /codetab %}}
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`.
{{% codetab %}}
The easiest way to install Zookeeper on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/zookeeper):
```
helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
helm install zookeeper incubator/zookeeper
```
This installs Zookeeper into the `default` namespace.
To interact with Zookeeper, find the service with: `kubectl get svc zookeeper`.
For example, if installing using the example above, the Zookeeper host address would be:
`zookeeper.default.svc.cluster.local:2181`
{{% /codetab %}}
{{< /tabs >}}
## 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 >}})