mirror of https://github.com/dapr/docs.git
Changes to State Management and Pub/Sub articles and improving Redis docs. (#831)
* Updates to Service Invocation and State Management * update * Another update * Update concepts/service-invocation/README.md Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com> * Update concepts/service-invocation/README.md Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com> * Update concepts/service-invocation/README.md Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com> * Update howto/invoke-and-discover-services/README.md Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com> * Updated retries * Update README.md * Update to State Store and Pub/Sub topics * More update to State and Pub/Sub * update env topic * Update README.md * Update README.md Co-authored-by: Mukundan Sundararajan <musundar@microsoft.com> Co-authored-by: Yaron Schneider <yaronsc@microsoft.com> Co-authored-by: Mark Chmarny <mchmarny@users.noreply.github.com>
This commit is contained in:
parent
009e93ad0e
commit
75415b6b3c
|
@ -36,14 +36,4 @@ The observability tools listed below are ones that have been tested to work with
|
|||
### Distributed Tracing
|
||||
|
||||
* [How-To: Set up Zipkin](../../howto/diagnose-with-tracing/zipkin.md)
|
||||
* [How-To: Set up Application Insights](../../howto/diagnose-with-tracing/azure-monitor.md)
|
||||
|
||||
|
||||
## Implementation Status
|
||||
The table below shows the current status of each of the observabilty capabilites for the Dapr runtime and system services. N/A means not applicable.
|
||||
|
||||
| | Runtime | Operator | Injector | Placement | Sentry|
|
||||
|---------|---------|----------|----------|-----------|--------|
|
||||
|Metrics | Yes | Yes | Yes | Yes | Yes |
|
||||
|Tracing | Yes | N/A | N/A | *Planned* | N/A |
|
||||
|Logs | Yes | Yes | Yes | Yes | Yes |
|
||||
* [How-To: Set up Application Insights](../../howto/diagnose-with-tracing/azure-monitor.md)
|
|
@ -74,7 +74,7 @@ Service invocation performs automatic retries with backoff time periods in the e
|
|||
Errors that cause retries are:
|
||||
|
||||
* Network errors including endpoint unavailability and refused connections
|
||||
* Authentication errors due to a renewing certificate on the calling/callee dapr sidecars
|
||||
* Authentication errors due to a renewing certificate on the calling/callee Dapr sidecars
|
||||
|
||||
Per call retries are performed with a backoff interval of 1 second up to a threshold of 3 times.
|
||||
Connection establishment via gRPC to the target sidecar has a timeout of 5 seconds.
|
||||
|
|
|
@ -235,3 +235,6 @@ helm uninstall dapr -n dapr-system
|
|||
```
|
||||
|
||||
> **Note:** See [here](https://github.com/dapr/dapr/blob/master/charts/dapr/README.md) for details on Dapr helm charts.
|
||||
|
||||
### Installing Redis on Kubernetes
|
||||
To install Redis as a state store or as a pub/sub message bus into your Kubernetes cluster. See [Configure Redis for state management or pub/sub](../howto/configure-redis/readme.md)
|
||||
|
|
|
@ -23,19 +23,19 @@ Here you'll find a list of "How To" guides that walk you through accomplishing s
|
|||
## State Management
|
||||
|
||||
* [Setup a state store](./setup-state-store)
|
||||
* [Configuring Redis for state management ](./configure-redis)
|
||||
* [Create a service that performs stateful CRUD operations](./create-stateful-service)
|
||||
* [Query the underlying state store](./query-state-store)
|
||||
* [Create a stateful, replicated service with different consistency/concurrency levels](./stateful-replicated-service)
|
||||
* [Control your app's throttling using rate limiting features](./control-concurrency)
|
||||
* [Configuring Redis for state management ](./configure-redis)
|
||||
|
||||
## Pub/Sub
|
||||
|
||||
* [Setup Dapr Pub/Sub](./setup-pub-sub-message-broker)
|
||||
* [Setup a Pub/Sub component](./setup-pub-sub-message-broker)
|
||||
* [Configuring Redis for pub/sub](./configure-redis)
|
||||
* [Use Pub/Sub to publish messages to a given topic](./publish-topic)
|
||||
* [Use Pub/Sub to consume events from a topic](./consume-topic)
|
||||
* [Use Pub/Sub across multiple namespaces](./pubsub-namespaces)
|
||||
* [Configuring Redis for pub/sub](./configure-redis)
|
||||
* [Limit the Pub/Sub topics used or scope them to one or more applications](./pubsub-scopes)
|
||||
|
||||
## Bindings and Triggers
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
# Redis and Dapr
|
||||
# Configure Redis for state management or pub/sub
|
||||
|
||||
Dapr can use Redis in two ways:
|
||||
|
||||
1. For state persistence and restoration
|
||||
2. For enabling pub/sub async style message delivery
|
||||
1. As state store component (state.redis) for persistence and restoration
|
||||
2. As pub/sub component (pubsub.redis) for async style message delivery
|
||||
|
||||
## Creating a Redis Store
|
||||
- [Option 1: Creating a Redis Cache in your Kubernetes cluster using Helm](#Option-1:-creating-a-Redis-Cache-in-your-Kubernetes-Cluster-using-Helm)
|
||||
- [Option 2: Creating an Azure Cache for Redis service](#Option-2:-Creating-an-Azure-Cache-for-Redis-service)
|
||||
- [Configuration](#configuration)
|
||||
|
||||
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.
|
||||
|
||||
## Creating a Redis store
|
||||
|
||||
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.
|
||||
|
||||
### Option 1: Creating a Redis Cache in your Kubernetes Cluster using Helm
|
||||
|
||||
|
@ -17,22 +22,40 @@ We can use [Helm](https://helm.sh/) to quickly create a Redis instance in our Ku
|
|||
|
||||
```bash
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm repo update
|
||||
helm install redis bitnami/redis
|
||||
```
|
||||
|
||||
> Note that you need a Redis version greater than 5, which is what Dapr' pub/sub functionality requires. If you're intending on using Redis as just a state store (and not for pub/sub), also a lower version can be used.
|
||||
> Note that you need a Redis version greater than 5, which is what Dapr' pub/sub functionality requires. If you're intending on using Redis as just a state store (and not for pub/sub) a lower version can be used.
|
||||
|
||||
2. Run `kubectl get pods` to see the Redis containers now running in your cluster.
|
||||
2. Run `kubectl get pods` to see the Redis containers now running in your cluster or watch the rollout status.
|
||||
|
||||
3. Add `redis-master:6379` as the `redisHost` in your [redis.yaml](#configuration) file. For example:
|
||||
```bash
|
||||
kubectl rollout status statefulset.apps/redis-master
|
||||
kubectl rollout status statefulset.apps/redis-slave
|
||||
```
|
||||
|
||||
3. Add `redis-master.default.svc.cluster.local:6379` as the `redisHost` in your [redis.yaml](#configuration) file. For example:
|
||||
|
||||
```yaml
|
||||
metadata:
|
||||
- name: redisHost
|
||||
value: redis-master:6379
|
||||
value: redis-master.default.svc.cluster.local: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 our Redis password using a `secretKeyRef` to a Kubernetes secret that has been configured into your cluster when Redis was installed. You can see the name of the secret key with `kubectl describe secret redis`
|
||||
|
||||
Add `redis` with the key `redis-password` as the `redisPassword` secretKeyRef in your [redis.yaml](#configuration) file. For example:
|
||||
|
||||
```yaml
|
||||
- name: redisPassword
|
||||
secretKeyRef:
|
||||
name: redis
|
||||
key: redis-password
|
||||
```
|
||||
That's it! Now go to the [Configuration](#configuration) section
|
||||
|
||||
5. (Alternative) Its **not recommended**, however you can use a hard coded password instead of secretKeyRef. First we'll get the Redis password, which is slightly different depending on the OS you're using:
|
||||
|
||||
- **Windows**: Run below commands
|
||||
```powershell
|
||||
|
@ -82,16 +105,56 @@ We can use [Helm](https://helm.sh/) to quickly create a Redis instance in our Ku
|
|||
|
||||
> **NOTE:** Dapr pub/sub uses [Redis Streams](https://redis.io/topics/streams-intro) that was introduced by Redis 5.0, which isn't currently available on Azure Managed Redis Cache. Consequently, you can use Azure Managed Redis Cache only for state persistence.
|
||||
|
||||
### Other options to create a Redis Database
|
||||
### Other options to create a Redis database
|
||||
|
||||
- [AWS Redis](https://aws.amazon.com/redis/)
|
||||
- [GCP Cloud MemoryStore](https://cloud.google.com/memorystore/)
|
||||
|
||||
## Configuration
|
||||
|
||||
Dapr can use Redis as a `statestore` component (for state persistence and retrieval) or as a `messagebus` component (for pub/sub). The following yaml files demonstrates how to define each. **Note:** yaml files below illustrate secret management in plain text. In a production-grade application, follow [secret management](../../concepts/secrets/README.md) instructions to securely manage your secrets.
|
||||
Dapr can use Redis as a `statestore` component for state persistence (`state.redis`) or as a `pubsub` component (`pubsub.redis`). The following yaml files demonstrates how to define each component using either a secretKey reference (which is preferred) or a plain text password. **Note:** In a production-grade application, follow [secret management](../../concepts/secrets/README.md) instructions to securely manage your secrets.
|
||||
|
||||
### Configuring Redis for State Persistence and Retrieval
|
||||
### Configuring Redis for state persistence using a secret key reference (preferred)
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: statestore
|
||||
namespace: default
|
||||
spec:
|
||||
type: state.redis
|
||||
metadata:
|
||||
- name: redisHost
|
||||
value: <HOST e.g. redis-master.default.svc.cluster.local:6379>
|
||||
- name: redisPassword
|
||||
secretKeyRef:
|
||||
name: redis
|
||||
key: redis-password
|
||||
```
|
||||
|
||||
### Configuring Redis for Pub/Sub using a secret key reference (preferred)
|
||||
|
||||
Create a file called redis-pubsub.yaml, and paste the following:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: pubsub
|
||||
namespace: default
|
||||
spec:
|
||||
type: pubsub.redis
|
||||
metadata:
|
||||
- name: redisHost
|
||||
value: <HOST e.g. redis-master.default.svc.cluster.local:6379>
|
||||
- name: redisPassword
|
||||
secretKeyRef:
|
||||
name: redis
|
||||
key: redis-password
|
||||
```
|
||||
|
||||
### Configuring Redis for state persistence using hard coded password (not recommended)
|
||||
|
||||
Create a file called redis-state.yaml, and paste the following:
|
||||
|
||||
|
@ -110,7 +173,7 @@ spec:
|
|||
value: <PASSWORD>
|
||||
```
|
||||
|
||||
### Configuring Redis for Pub/Sub
|
||||
### Configuring Redis for Pub/Sub using hard coded password (not recommended)
|
||||
|
||||
Create a file called redis-pubsub.yaml, and paste the following:
|
||||
|
||||
|
@ -118,7 +181,7 @@ Create a file called redis-pubsub.yaml, and paste the following:
|
|||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: messagebus
|
||||
name: pubsub
|
||||
namespace: default
|
||||
spec:
|
||||
type: pubsub.redis
|
||||
|
@ -135,13 +198,11 @@ spec:
|
|||
|
||||
```bash
|
||||
kubectl apply -f redis-state.yaml
|
||||
|
||||
kubectl apply -f redis-pubsub.yaml
|
||||
```
|
||||
|
||||
### Self Hosted Mode
|
||||
### Self hosted mode
|
||||
|
||||
By default the Dapr CLI creates a local Redis instance when you run `dapr init`. However, if you want to configure a different Redis instance, create a `components` dir containing the YAML file and provide the path to the `dapr run` command with the flag `--components-path`.
|
||||
|
||||
If you initialized Dapr using `dapr init --slim`, the Dapr CLI did not create a Redis instance or a default configuration file for it. Follow [these instructions](#Creating-a-Redis-Store) to create a Redis store. Create the `redis.yaml` following the configuration [instructions](#Configuration) in a `components` dir and provide the path to the `dapr run` command with the flag `--components-path`.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Get started with Dapr and gRPC
|
||||
# Create a gRPC enabled app, and invoke Dapr over gRPC
|
||||
|
||||
Dapr implements both an HTTP and a gRPC API for local calls.gRPC is useful for low-latency, high performance scenarios and has language integration using the proto clients.
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ For this guide, we'll use Redis Streams, which is also installed by default on a
|
|||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: messagebus
|
||||
name: pubsub-name
|
||||
namespace: default
|
||||
spec:
|
||||
type: pubsub.redis
|
||||
|
@ -26,8 +26,12 @@ spec:
|
|||
value: localhost:6379
|
||||
- name: redisPassword
|
||||
value: ""
|
||||
- name: allowedTopics
|
||||
value: "deathStartStatus"
|
||||
```
|
||||
|
||||
Using the `allowedTopics` you can specify that only the `deathStartStatus` topic should be supported.
|
||||
|
||||
To deploy this into a Kubernetes cluster, fill in the `metadata` connection details in the yaml, and run `kubectl apply -f pubsub.yaml`.
|
||||
|
||||
## Publish a topic
|
||||
|
@ -35,7 +39,7 @@ To deploy this into a Kubernetes cluster, fill in the `metadata` connection deta
|
|||
To publish a message to a topic, invoke the following endpoint on a Dapr instance:
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:3500/v1.0/publish/pubsubName/deathStarStatus \
|
||||
curl -X POST http://localhost:3500/v1.0/publish/pubsub-name/deathStarStatus \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"status": "completed"
|
||||
|
@ -43,4 +47,4 @@ curl -X POST http://localhost:3500/v1.0/publish/pubsubName/deathStarStatus \
|
|||
```
|
||||
|
||||
The above example publishes a JSON payload to a `deathStartStatus` topic.
|
||||
Dapr will wrap the user payload in a Cloud Events v1.0 compliant envelope.
|
||||
Dapr wraps the user payload in a Cloud Events v1.0 compliant envelope.
|
|
@ -1,7 +1,8 @@
|
|||
# Setup a Dapr pub/sub
|
||||
# Setup a pub/sub component
|
||||
|
||||
Dapr integrates with existing message buses to provide apps with the ability to create event-driven, loosely coupled architectures where producers send events to consumers via topics.
|
||||
Currently, Dapr supports the configuration of one message bus per cluster.
|
||||
Dapr integrates with pub/sub message buses to provide apps with the ability to create event-driven, loosely coupled architectures where producers send events to consumers via topics.
|
||||
|
||||
Dapr supports the configuration of multiple, named, pub/sub components *per application*. Each pub/sub component has a name and this name is used when publishing a message topic
|
||||
|
||||
Pub/Sub message buses are extensible and can be found in the [components-contrib repo](https://github.com/dapr/components-contrib).
|
||||
|
||||
|
@ -11,7 +12,7 @@ A pub/sub in Dapr is described using a `Component` file:
|
|||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: messagebus
|
||||
name: pubsub
|
||||
namespace: default
|
||||
spec:
|
||||
type: pubsub.<NAME>
|
||||
|
@ -23,12 +24,12 @@ spec:
|
|||
...
|
||||
```
|
||||
|
||||
The type of message bus is determined by the `type` field, and things like connection strings and other metadata are put in the `.metadata` section.
|
||||
Even though you can put plain text secrets in there, it is recommended you use a [secret store](../../concepts/secrets).
|
||||
The type of pub/sub is determined by the `type` field, and things like connection strings and other metadata are put in the `.metadata` section.
|
||||
Even though you can put plain text secrets in there, it is recommended you use a [secret store](../../concepts/secrets) using a `secretKeyRef`
|
||||
|
||||
## Running locally
|
||||
|
||||
When running locally with the Dapr CLI, a component file for a Redis Streams pub/sub will be automatically created in a `components` directory in your current working directory.
|
||||
When running locally with the Dapr CLI, a component file for a Redis pub/sub is created in a `components` directory, which for Linux/MacOS is `$HOME/.dapr/components` and for Windows is `%USERPROFILE%\.dapr\components`. See [Environment Setup](../getting-started/environment-setup.md#installing-dapr-in-self-hosted-mode)
|
||||
|
||||
You can make changes to this file the way you see fit, whether to change connection values or replace it with a different pub/sub.
|
||||
|
||||
|
@ -41,7 +42,7 @@ To setup a pub/sub in Kubernetes, use `kubectl` to apply the component file:
|
|||
kubectl apply -f pubsub.yaml
|
||||
```
|
||||
|
||||
## Reference
|
||||
## Related links
|
||||
|
||||
- [Setup Redis Streams](./setup-redis.md)
|
||||
- [Setup NATS Streaming](./setup-nats-streaming.md)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Setup a Dapr state store
|
||||
# Setup a state store component
|
||||
|
||||
Dapr integrates with existing databases to provide apps with state management capabilities for CRUD operations, transactions and more.
|
||||
Currently, Dapr supports the configuration of one state store per cluster.
|
||||
|
||||
Dapr supports the configuration of multiple, named, state store components *per application*.
|
||||
|
||||
State stores are extensible and can be found in the [components-contrib repo](https://github.com/dapr/components-contrib).
|
||||
|
||||
|
|
Loading…
Reference in New Issue